Claude Swarm — Multi-Agent Orchestration with SDK
Python-based multi-agent orchestration built on Claude Agent SDK. Opus decomposes tasks, Haiku workers execute in parallel waves with real-time TUI dashboard and budget control.
What it is
Claude Swarm is a Python-based multi-agent orchestration system built on the Claude Agent SDK. It uses a hierarchical architecture where Claude Opus decomposes complex tasks into subtasks, and Claude Haiku workers execute them in parallel waves. It includes a real-time TUI dashboard for monitoring agent progress and budget control to cap API spending.
Claude Swarm targets developers building AI-powered automation that requires decomposing large problems into parallelizable units of work. Instead of one long-running agent, you get a coordinated team with visibility into cost and progress.
Why it saves time or tokens
A single large-context agent call processes everything sequentially and burns tokens on the full context window. Claude Swarm splits work across smaller, focused agents that each handle a narrow subtask with minimal context. Parallel execution reduces wall-clock time. Budget control prevents runaway costs by capping total spending across all agents.
How to use
- Install Claude Swarm from the repository
- Define your task decomposition strategy and worker roles
- Run the swarm with a task description and budget limit
Example
from claude_swarm import Swarm, Task
swarm = Swarm(
orchestrator_model='claude-opus-4-20250514',
worker_model='claude-haiku-3',
max_budget_usd=5.00,
max_parallel_workers=4
)
result = swarm.run(
task='Analyze the top 10 Python web frameworks. '
'For each, summarize features, performance, '
'and community size.',
output_format='markdown_table'
)
print(result.output)
print(f'Total cost: ${result.total_cost:.2f}')
| Component | Role |
|---|---|
| Orchestrator (Opus) | Decompose task into subtasks |
| Workers (Haiku) | Execute subtasks in parallel |
| TUI Dashboard | Real-time progress monitoring |
| Budget Controller | Cap spending across all agents |
| Result Merger | Combine worker outputs |
Related on TokRepo
- Multi-agent frameworks — compare multi-agent orchestration tools on TokRepo
- AI tools for agents — autonomous AI agent frameworks
Common pitfalls
- Task decomposition quality depends on the orchestrator model; vague task descriptions produce poor subtask splits
- Parallel workers sharing state requires careful coordination; design subtasks to be independent whenever possible
- Budget limits that are too tight may terminate the swarm before completing all subtasks; estimate costs before setting limits
Frequently Asked Questions
Claude Swarm uses Claude Opus as the orchestrator for task decomposition (requires strong reasoning) and Claude Haiku as workers for parallel execution (fast and cheap). You can configure different model combinations based on your cost and quality requirements.
Claude Swarm tracks token usage and estimated cost across all agent calls. You set a maximum budget in USD when creating the swarm. If the cumulative cost approaches the limit, the swarm stops spawning new workers and returns partial results with a budget warning.
Yes. Claude Swarm can decompose coding tasks like 'review all files in this directory' into per-file worker tasks. Each worker reviews one file and returns findings. The orchestrator merges the results. This pattern works for code review, refactoring, documentation, and analysis tasks.
The TUI (terminal user interface) dashboard shows real-time progress of all active workers, their status (pending, running, complete), token usage per worker, and cumulative cost. It provides visibility into the swarm without reading raw logs.
CrewAI defines agents with roles and tasks declaratively. Claude Swarm focuses on automated task decomposition and parallel execution with budget control. CrewAI is more flexible for custom agent interactions. Claude Swarm is more opinionated about the orchestrator-worker pattern and cost management.
Citations (3)
- Anthropic Docs— Claude Agent SDK for building AI agents
- Anthropic Models— Claude model family (Opus, Sonnet, Haiku)
- Anthropic Agent Patterns— Multi-agent orchestration patterns
Related on TokRepo
Source & Thanks
Created by affaan-m. Licensed under MIT.