Skip to content

nghiack7/claude-swarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Claude Swarm

Multi-CLI agent orchestration. One command, multiple AI models, coordinated work.

Claude Swarm orchestrates Claude Code, Codex CLI, and Gemini CLI from a single terminal. Spawn a swarm of agents with different roles and models, monitor them in real-time, and collect results β€” all locally.

Claude Swarm Demo

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  🐝 CLAUDE SWARM β€” "Build a REST API"                       β”‚
β”‚  Mode: pipeline | Agents: 1/3 done | Elapsed: 45s           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                              β”‚
β”‚  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ DONE  planner (claude/sonnet-4-6)           β”‚
β”‚    Completed in 32s | 2.1KB output                           β”‚
β”‚                                                              β”‚
β”‚  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ RUN   implementer (codex/o4-mini)           β”‚
β”‚    18s elapsed | 1.4KB output | 23 lines                     β”‚
β”‚    > Writing Express routes for /todos endpoints...          β”‚
β”‚                                                              β”‚
β”‚  β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ WAIT  reviewer (gemini/pro)                β”‚
β”‚    Waiting...                                                β”‚
β”‚                                                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Latest output (implementer):                                β”‚
β”‚  > Created src/routes/todos.ts with CRUD endpoints           β”‚
β”‚  > Added input validation with zod schemas                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Why?

Every AI coding tool runs in its own silo. Claude Code doesn't talk to Codex. Codex doesn't talk to Gemini. You copy-paste between terminals.

Claude Swarm is the layer above the agents. It coordinates them:

  • Claude plans the architecture (best at reasoning)
  • Codex writes the code (best at implementation)
  • Gemini reviews the result (independent perspective)

One command. Multiple models. Coordinated output.

Install

git clone https://github.com/nghiack7/claude-swarm.git
cd claude-swarm
npm install

Quick Start

Run a swarm (default pipeline: planner β†’ implementer β†’ reviewer)

npx tsx src/cli.ts run "Build a todo REST API with Express and TypeScript"

Custom agents with specific CLIs and models

npx tsx src/cli.ts run "Fix the auth bug in src/auth.ts" \
  --agent "analyst:claude:claude-sonnet-4-6" \
  --agent "fixer:codex:o4-mini" \
  --agent "reviewer:claude:claude-haiku-4-5-20251001"

Parallel mode (all agents run simultaneously)

npx tsx src/cli.ts run "Review this codebase for security issues" \
  --agent "security:claude" \
  --agent "deps:codex" \
  --agent "secrets:gemini" \
  --mode parallel

Check available adapters

npx tsx src/cli.ts adapters
CLI Adapters

  claude ● available (default model: claude-sonnet-4-6)
  codex  ● available (default model: o4-mini)
  gemini βœ• not found (default model: gemini-2.5-pro)

Agent Spec Format

role:cli:model    Full spec      e.g. planner:claude:claude-sonnet-4-6
role:cli          Default model  e.g. coder:codex
role              Default CLI    e.g. reviewer (uses claude)

Execution Modes

Pipeline (default)

Agents run sequentially. Each agent receives the output of all previous agents as context.

planner ──→ implementer ──→ reviewer
  output ─────→ output ───────→ output

Best for: feature building, bug fixing, any task where later steps depend on earlier ones.

Parallel

All agents run simultaneously with the same task description. No shared context between agents.

β”Œβ”€ security-reviewer
β”œβ”€ performance-auditor    (all run at once)
└─ code-quality-checker

Best for: independent reviews, multi-perspective analysis, parallelizable work.

Architecture

User
 β”‚
 β–Ό
CLI (claude-swarm run)
 β”‚
 β”œβ”€β”€β†’ Orchestrator
 β”‚     β”œβ”€β”€ Adapter: Claude Code (claude -p "...")
 β”‚     β”œβ”€β”€ Adapter: Codex CLI   (codex exec "...")
 β”‚     └── Adapter: Gemini CLI  (gemini -p "...")
 β”‚
 β”œβ”€β”€β†’ TUI Dashboard (live terminal monitoring)
 β”‚
 └──→ Broker (localhost:7899 + SQLite)
       β”œβ”€β”€ peers (discovery + status)
       β”œβ”€β”€ rooms (collaboration groups)
       β”œβ”€β”€ messages (queue + history)
       β”œβ”€β”€ tasks (delegation + tracking)
       └── scratchpad (shared memory)

Two layers:

  1. Orchestrator β€” spawns CLI processes, constructs role-specific prompts, manages lifecycle, collects output. This is the new part.
  2. Broker β€” the existing peer coordination system. MCP-connected Claude Code sessions can still discover each other, form rooms, and collaborate in real-time.

Peer Coordination (MCP)

The orchestrator is one way to use Claude Swarm. You can also use it as an MCP server for real-time peer coordination between manually-opened sessions.

Register as MCP server

claude mcp add --scope user --transport stdio claude-swarm -- npx tsx $(pwd)/src/server.ts

22 MCP Tools

Category Tools
Core list_peers, send_message, broadcast, check_messages, message_history, set_summary, set_name, set_status
Rooms create_room, join_room, leave_room, list_rooms
Tasks create_task, update_task, list_tasks
Scratchpad scratchpad_get, scratchpad_set, scratchpad_list

CLI Commands

# Orchestration
claude-swarm run <task>          # Run a multi-agent swarm
claude-swarm adapters            # List available CLI adapters

# Coordination
claude-swarm status              # Dashboard overview
claude-swarm peers               # List peers
claude-swarm rooms               # List rooms
claude-swarm send <id> <msg>     # Send direct message
claude-swarm broadcast <room> <msg>  # Broadcast to room
claude-swarm history [--room <id>] [--search <term>]
claude-swarm tasks <room_id>     # List tasks
claude-swarm scratchpad <room_id>    # Shared memory
claude-swarm kill                # Kill broker
claude-swarm help                # Help

How It Works

  1. You run claude-swarm run "your task" with agent specs
  2. The orchestrator constructs a role-specific prompt for each agent
  3. In pipeline mode, each agent's output becomes context for the next
  4. In parallel mode, all agents run simultaneously
  5. The TUI shows live progress: status, output size, latest lines
  6. When complete, a summary shows each agent's output and timing

Each agent runs as a real CLI subprocess (claude -p, codex exec, gemini -p) with full tool access. They can edit files, run tests, and interact with your codebase.

Default Pipeline

When no --agent flags are specified, Claude Swarm uses a 3-agent pipeline:

Step Role CLI Purpose
1 Planner Claude Architecture and implementation plan
2 Implementer Claude Write the code following the plan
3 Reviewer Claude Review for bugs, edge cases, improvements

Customize by passing --agent flags. Mix and match CLIs freely.

Key Design Decisions

  • Multi-CLI: Not locked to one AI provider. Claude, Codex, Gemini, and any future CLI that accepts a prompt and returns output.
  • Local-only: All traffic on 127.0.0.1. No cloud coordination, no API keys for swarm features.
  • Protocol-agnostic: The broker speaks HTTP + SQLite. Any process can participate.
  • Zero config: No YAML files needed. Agent specs are CLI flags. Defaults work out of the box.
  • Adapter pattern: Adding a new CLI is ~20 lines. Implement available() and spawn().

Adding a New CLI Adapter

Edit src/adapters.ts:

const myAdapter: CLIAdapter = {
  name: "mycli",
  defaultModel: "my-model",
  available: () => commandExists("mycli"),
  spawn: ({ prompt, model, cwd }) => {
    return spawn("mycli", ["run", prompt, "--model", model], {
      cwd, stdio: ["ignore", "pipe", "pipe"],
    });
  },
};

Then add it to the adapters registry. That's it.

Environment

Variable Default Description
CLAUDE_SWARM_PORT 7899 Broker port
CLAUDE_SWARM_DB ~/.claude-swarm.db SQLite path

vs Other Tools

Feature Claude Swarm Agent Teams AMUX Conductor
Multi-CLI (Claude+Codex+Gemini) βœ“ βœ• (Claude only) βœ• βœ•
One-command orchestration βœ“ βœ“ βœ• βœ“
Live TUI dashboard βœ“ βœ• Web UI βœ•
Per-role model selection βœ“ βœ• βœ• βœ•
Pipeline + parallel modes βœ“ Parallel only Parallel only Parallel only
MCP peer coordination βœ“ βœ• βœ• βœ•
Shared scratchpad memory βœ“ Shared tasks βœ• βœ•
Zero cloud dependency βœ“ βœ“ βœ“ βœ•
Adapter pattern (extensible) βœ“ βœ• βœ• βœ•

License

MIT

About

Local-first multi-agent coordination for Claude Code. Rooms, tasks, broadcast, shared memory. Zero cloud, zero API keys.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors