Documentation Index
Fetch the complete documentation index at: https://docs.swarms.world/llms.txt
Use this file to discover all available pages before exploring further.
Swarms CLI Tutorial: From Zero to Multi-Agent
If you can usegit, curl, or gh, you already know how to use the Swarms CLI. This tutorial walks through every command in order, from a clean install to running a four-agent debate on a real task. By the end you’ll be productive without ever leaving the terminal.
We’ll cover:
- Installing and verifying the CLI
- Scaffolding a project with
swarms init - Talking to a single agent with
swarms chat - Running one-shot tasks with
swarms agent - Discovering models with the new
swarms modelscommand - Auto-generating swarms with
swarms autoswarm - Running deep multi-agent analyses with
swarms heavy-swarmandswarms llm-council - Loading whole teams from YAML and markdown files
- Power-user tricks: streaming, autosave, MCP servers, environment scoping
- The rotating
swarms tipsengine and how to use it - Recovering from errors — the CLI’s built-in classifier and typo-corrector
1. Install and Verify
The CLI ships with the main package. One line installs both:⚡ Pro tip, 🪄 Hint, etc.) rotate on every invocation. They are not noise — they surface real CLI capabilities you might have missed.
2. Scaffold a Project: swarms init
init is the interactive wizard. It walks you through:
- Picking a project directory
- Picking a
WORKSPACE_DIR(where agents read and write files) - Adding API keys for any providers you have access to
- Writing a
.envfile - Validating the result
<project_dir>/.env— your API keys<project_dir>/workspace/— the workspace directory
setup-check passes, suggesting your real first command (usually swarms chat).
To verify the environment at any time:
3. Your First Conversation: swarms chat
The fastest way to talk to a model:
max_loops="auto"), drops you into an interactive REPL, and streams responses back. Type exit or hit Ctrl-C to leave — your session state is autosaved so you can resume later.
Customize the persona:
--task flag seeds the first message; from there the conversation is interactive.
4. One-Shot Agents: swarms agent
When you don’t want a REPL — say, in a shell script or CI job — use swarms agent:
| Flag | What it does |
|---|---|
--max-loops auto | Let the agent decide when it’s done (autonomous mode) |
--streaming-on | Stream tokens to the terminal as they arrive |
--verbose | Show every internal step the agent takes |
--autosave --saved-state-path ./state.json | Persist agent memory between runs |
--mcp-url <url> | Auto-discover and use tools from an MCP server |
--marketplace-prompt-id <id> | Pull a pre-built system prompt from the marketplace |
--streaming-on --verbose to watch the model think token by token.
5. Discover Models: swarms models
Before you change --model-name, you need to know what to put there. The CLI ships a model-discovery command backed by the LiteLLM registry, so the list stays current as providers ship new models.
List every model, grouped by provider:
difflib fuzzy matches):
--info command suggests the closest matches.
6. Auto-Generate a Swarm: swarms autoswarm
Don’t know which architecture fits your task? Let the CLI design one:
--no-run to inspect the file before running:
7. Heavy Analysis: swarms heavy-swarm
For research-grade depth, heavy-swarm decomposes the task into specialist questions, dispatches them to multiple worker agents in parallel, then synthesizes a final answer:
--loops-per-agent iterations on its sub-question, which gives meaningfully deeper output than a single LLM call. With high loop counts this gets expensive — check costs first with swarms models --info <name> to know what you’re paying per million tokens.
For non-deterministic exploration:
8. Multi-Model Debate: swarms llm-council
llm-council runs the same task across multiple models and aggregates their responses. It’s the right shape when you want disagreement surfaced — adversarial verification, due-diligence reviews, or “is this consensus actually consensus?” questions:
9. Load a Team from a File
For repeatable workflows, define agents in a YAML or markdown file and load them with one command. YAML —agents.yaml:
.md files, each with YAML frontmatter:
10. The tips Engine
The CLI ships with ~75 categorized tips covering every command and flag. The banner rotates one per invocation, but you can also pull them on demand:
commands, agents, swarms, models, pro, trivia, env, community. Use swarms tips --all to dump every tip in every category — useful as a cheat-sheet to print and pin next to your terminal.
The prefix labels (⚡ Pro tip:, 💡 Did you know:, 🪄 Hint:, 🔥 Hot tip:, and four others) are randomized per render. It’s intentional — varied prefixes catch your eye when a tip is genuinely useful.
11. Power-User Tricks
A few patterns that pay off in real use: Pipe a task in from stdin:direnv: drop a .envrc per project, and swarms auto-loads the project’s .env because of how python-dotenv resolves the cwd.
Long autonomous loops inside tmux: detach with Ctrl-b d and the agent keeps running. Combined with --autosave, you can disconnect for hours and resume the session later.
Watch a model think:
12. Errors and Recovery
When something goes wrong, the CLI doesn’t just dump a stack trace. It classifies the error and prints targeted recovery hints:- A
401 Unauthorizedfrom a provider → “Runswarms initorswarms get-api-key” - A
model_not_founderror → “Find a valid model withswarms models --search <name>” - A missing
WORKSPACE_DIR→ “Runswarms initto scaffold one” - A
429 RateLimit→ “Slow down, use a smaller--model-name, or retry in a minute” - A network timeout → “Run
swarms setup-check --verboseto validate connectivity” - A
ModuleNotFoundError→ “Tryswarms upgradeorpip install -U swarms”
difflib.get_close_matches against the command list, so corrections work even for two-character typos.
13. Where to Go Next
You now have everything you need for daily use. A few directions to grow into:- Build a reusable agent library — Use markdown frontmatter to define agents once and load them from any project with
swarms load-markdown. - Compose pipelines as YAML —
swarms run-agents --yaml-filelets you commit the entire workflow to git. - Wire MCP tools — Any tool exposed via an MCP server (filesystem, web search, database) becomes available to any agent through
--mcp-url. - Read the API reference — When you’re ready to leave the CLI for Python code, every CLI flag maps to an Agent class parameter documented in the API Reference.
swarms init, then alternate between swarms chat for ideation and swarms agent --task '...' for one-shot work. Everything else — autoswarm, heavy-swarm, llm-council, YAML loading — composes from the same primitives once you’re comfortable with the basics.
Related
Commands Reference
Every command, every flag, with examples
Configuration
YAML, markdown, and environment configuration
Quickstart Tutorial
A hands-on multi-agent workflow you can build right now
API Reference
Map every CLI flag back to its Python API counterpart