claude-swarm

作者 affaan-m已验证

Multi-agent orchestration for Claude Code — decompose tasks, coordinate agents, visualize everything in a rich terminal UI

304
Stars
77
Forks
Python
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/affaan-m/claude-swarm

快速入门

使用 claude-swarm 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

Claude Swarm

PyPI Python 3.11+ License: MIT Tests

Multi-agent orchestration for Claude Code — decompose complex tasks into parallel subtasks, coordinate agents in real-time, and visualize everything in a rich terminal UI.

Built with the Claude Agent SDK for the Claude Code Hackathon (Feb 10-16, 2026).

How It Works

You: "Refactor auth module from Express middleware to Next.js API routes"

Claude Swarm:
  Phase 1:   Opus 4.6 decomposes task into dependency graph
  Phase 2:   Parallel agents execute subtasks with live dashboard
  Phase 2.5: Opus 4.6 Quality Gate reviews all agent outputs
  Phase 3:   Results summary with costs and session replay
  1. Task Decomposition — Describe a complex task. Opus 4.6 analyzes your codebase and breaks it into a dependency graph of subtasks
  2. Parallel Agent Spawning — Independent subtasks run simultaneously via Claude Agent SDK. Dependent tasks wait.
  3. Real-time Coordination — File conflict detection prevents agents from stepping on each other. Budget enforcement stops runaway costs.
  4. Opus Quality Gate — After agents complete, Opus 4.6 reviews the combined output for correctness, consistency, and completeness
  5. Rich Terminal UIhtop-style dashboard showing agent progress, tool usage, costs, and file conflicts in real-time
  6. Session Replay — Every swarm execution is recorded. Replay any session to review what each agent did.

Quick Start

# See it in action instantly (no API key needed!)
pip install claude-swarm
claude-swarm --demo

# Or install from source
git clone https://github.com/affaan-m/claude-swarm
cd claude-swarm
pip install -e .

# Set your API key for real usage
export ANTHROPIC_API_KEY="sk-ant-..."

# Run a swarm
claude-swarm "Refactor auth module from Express middleware to Next.js API routes"

# Dry run (shows plan without executing)
claude-swarm --dry-run "Add user authentication with JWT"

# Custom budget, agents, and retries
claude-swarm --budget 3.0 --max-agents 6 --retry 2 "Build a REST API for user management"

# Disable quality gate for faster execution
claude-swarm --no-quality-gate "Quick fix: update README"

Architecture

┌───────────────────────────────────────────────┐
│              Claude Swarm CLI                  │
│                                                │
│  Phase 1: Decompose                            │
│  ┌─────────────────────────────────────────┐   │
│  │  Opus 4.6 Task Decomposer              │   │
│  │  "Add auth" -> [create routes,          │   │
│  │   add middleware, write tests, review]   │   │
│  └──────────────┬──────────────────────────┘   │
│                 │ dependency graph              │
│  Phase 2: Execute                              │
│  ┌──────────────▼──────────────────────────┐   │
│  │       Swarm Orchestrator                │   │
│  │                                         │   │
│  │  Wave 1: ┌────────┐ ┌────────┐         │   │
│  │          │ Agent 1 │ │ Agent 2 │  (parallel)│
│  │          │ coder   │ │ coder   │         │  │
│  │          └────┬────┘ └────┬────┘         │  │
│  │  Wave 2:      └─────┬─────┘              │  │
│  │               ┌─────▼─────┐              │  │
│  │               │  Agent 3  │  (depends)   │  │
│  │               │  tester   │              │  │
│  │               └─────┬─────┘              │  │
│  │  Wave 3:      ┌─────▼─────┐              │  │
│  │               │  Agent 4  │  (depends)   │  │
│  │               │  reviewer │              │  │
│  │               └───────────┘              │  │
│  │                                          │  │
│  │  File Locks: {auth.ts -> Agent 1}       │  │
│  │  Budget: $0.23 / $5.00                  │  │
│  │  Retries: task-2 (attempt 2/3)          │  │
│  └──────────────────────────────────────────┘  │
│                                                │
│  Phase 2.5: Quality Gate                       │
│  ┌──────────────────────────────────────────┐  │
│  │  Opus 4.6 reviews combined agent output  │  │
│  │  Score: 8/10 | Verdict: PASS            │  │
│  └──────────────────────────────────────────┘  │
│                                                │
│  Phase 3: Results                              │
│  ┌──────────────────────────────────────────┐  │
│  │  4/4 tasks completed | $0.45 | 32s      │  │
│  │  Session: swarm-a1b2c3d4                 │  │
│  └──────────────────────────────────────────┘  │
└────────────────────────────────────────────────┘

Features

FeatureDescription
Dependency-aware schedulingTasks only start when their dependencies complete
File conflict detectionPessimistic file locking prevents agents from editing the same file simultaneously
Budget enforcementHard cost limit — cancels remaining tasks when budget is exceeded
Cost trackingReal-time per-agent and total cost monitoring
Opus Quality GatePhase 2.5 — Opus 4.6 reviews all agent outputs for correctness and consistency
Smart model selectionOpus 4.6 for planning + quality review, Haiku for worker agents (3x cheaper)
Task retryFailed tasks are automatically retried with configurable attempt limits
Demo mode--demo flag shows animated TUI without API key (great for presentations)
Session recordingEvery swarm execution recorded as JSONL events
Session replayclaude-swarm replay <id> to review what each agent did
YAML configDeclarative swarm topologies via swarm.yaml
Progress visualizationLive htop-style dashboard with Rich

CLI Reference

# Main command
claude-swarm [OPTIONS] TASK

Options:
  -d, --cwd TEXT            Working directory (default: .)
  -n, --max-agents INTEGER  Max concurrent agents (default: 4)
  -m, --model TEXT          Decomposition model (default: opus)
  -b, --budget FLOAT        Max budget in USD (default: 5.0)
  -r, --retry INTEGER       Max retries for failed tasks (default: 1)
  -c, --config PATH         Path to swarm.yaml
  --demo                    Run demo simulation (no API key needed)
  --dry-run                 Show plan without executing
  --quality-gate/--no-quality-gate  Enable/disable Opus quality review (default: on)
  --no-ui                   Disable rich terminal UI
  -v, --version             Show version

# Subcommands
claude-swarm sessions              # List past sessions
claude-swarm replay <session-id>   # Replay a session's events

YAML Configuration

Create swarm.yaml in your project root to define custom agent types:

swarm:
  name: full-stack-review
  max_concurrent: 4
  budget_usd: 5.0
  model: opus

agents:
  security-reviewer:
    description: Reviews code for OWASP vulnerabilities
    model: opus
    tools: [Read, Grep, Glob]
    prompt: |
      Analyze the code for SQL injection, XSS, CSRF...

  tester:
    description: Writes and runs tests
    model: haiku
    tools: [Read, Write, Edit, Bash]
    prompt: |
      Write comprehensive tests. Ensure 80% coverage...

connections:
  - from: coder
    to: security-reviewer
  - from: coder
    to: tester
  - from: [security-reviewer, tester]
    to: reviewer

Claude Swarm auto-detects swarm.yaml or .claude/swarm.yaml in your project.

How Opus 4.6 Is Used

Claude Swarm demonstrates strategic model selection with two critical Opus 4.6 touchpoints:

Phase 1: Task Decomposition (Planning)

Opus 4.6 handles the hardest reasoning task — analyzing your codebase, understanding the architecture, identifying dependencies between subtasks, and producing a parallelizable execution plan. This requires deep understanding of code relationships and optimal task splitting.

Phase 2: Worker Execution

Haiku handles the parallelizable work — each agent follows focused instructions from the plan. Using Haiku here is 3x cheaper while maintaining 90% of Sonnet's capability for focused tasks.

Phase 2.5: Quality Gate (Review)

After all agents complete, Opus 4.6 reviews the combined output. It checks for integration issues between agents' work, missed edge cases, security concerns, and whether the original task was fully addressed. This catches problems that individual agents can't see.

This mirrors real engineering team structure: a senior architect designs the plan, junior engineers execute in parallel, and the senior reviews the combined result.

Tech Stack

  • Python 3.11+ with anyio for structured async concurrency
  • claude-agent-sdk (v0.1.35+) for Claude Code subprocess control
  • Rich for terminal UI (Live dashboard with panels and tables)
  • Click for CLI framework
  • Pydantic for data validation
  • NetworkX for dependency graph topological sorting

Development

# Clone and install
git clone https://github.com/affaan-m/claude-swarm
cd claude-swarm
pip install -e ".[dev]"

# Run tests (44 passing)
pytest tests/ -v

# Lint
ruff check src/ tests/

Project Structure

src/claude_swarm/
  cli.py           CLI entry point (Click group + subcommands)
  types.py         Core dataclasses (SwarmTask, SwarmPlan, etc.)
  decomposer.py    Opus 4.6 task decomposition
  orchestrator.py  Parallel execution with file locks, budget, retries
  quality_gate.py  Opus 4.6 quality review of agent outputs
  demo.py          Demo simulation with animated TUI
  config.py        YAML swarm topology configuration
  session.py       JSONL event recording and replay
  ui.py            Rich terminal dashboard

License

MIT — Affaan Mustafa

Acknowledgments

常见问题

What is claude-swarm?

claude-swarm is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by affaan-m. Multi-agent orchestration for Claude Code — decompose tasks, coordinate agents, visualize everything in a rich terminal UI. It has 304 GitHub stars.

Is claude-swarm safe to use?

Yes. claude-swarm passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install claude-swarm?

Clone the repository with "git clone https://github.com/affaan-m/claude-swarm" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is claude-swarm written in?

claude-swarm is primarily written in Python. It is open-source under affaan-m on GitHub, so you can review or fork the full source.

Are there alternatives to claude-swarm?

Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh claude-swarm against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI 智能体
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情