Swarm mode runs multiple specialist Claude Code agents in parallel, each in its own isolated git worktree and Zellij tab. A live dashboard shows real-time status; when all agents finish, the orchestrator automatically resumes for validation, documentation, and PR creation.
┌─ Zellij Session ──────────────────────────────────────────────┐
│ │
│ Tab 1: DASHBOARD / orchestrator (always-visible control panel)│
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ AI Squad — swarm-1739847123 │ │
│ │ Feature: user auth with OAuth │ │
│ │ │ │
│ │ TAB AGENT STATUS ELAPSED NAV │ │
│ │ 2 architect-1 done 00:42 Alt-2 │ │
│ │ 3 typescript-2 running 03:15 Alt-3 │ │
│ │ 4 qa-3 pending --:-- Alt-4 │ │
│ │ │ │
│ │ 1/3 done · 1 running · 1 pending │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ Tab 2: architect-1 ← done ✓ │
│ Tab 3: typescript-2 ← running ↻ │
│ Tab 4: qa-3 ← pending │
│ │
└────────────────────────────────────────────────────────────────┘
ai-squad swarm feature "..."
│
├─ creates .swarm/{session}/
│
└─ Zellij ──────────────────────────────────────────┐
│
Tab 1: orchestrator pane ←─ Phase 1-3 ─► plan.md
dashboard pane ←─ detects plan.md
├─ creates git worktrees
├─ launches agent tabs
└─ monitors live TUI
│
Tab 2: swarm-agent-wrapper (agent 1, worktree 1) │
Tab 3: swarm-agent-wrapper (agent 2, worktree 2) │
Tab N: swarm-agent-wrapper (agent N, worktree N) │
│
all agents complete │
│ │
└─ dashboard resumes orchestrator │
Phase 6: validate │
Phase 7: document │
Phase 8: PR │
All coordination happens via plain text files in .swarm/{session}/:
.swarm/
└── swarm-1739847123/
├── session.json # session metadata
├── sentinel # timestamp file for plan.md detection
├── resume-command.txt # Phase 6 resume command (written on completion)
└── agents/
├── typescript-1/
│ ├── task.md # the agent's prompt
│ ├── branch # git branch name
│ ├── started_at # ISO8601 timestamp
│ ├── finished_at # ISO8601 timestamp (after completion)
│ ├── status # pending | running | done | error
│ ├── exit_code # 0 or non-zero
│ └── result.md # git diff --stat + git log summary
└── qa-2/
└── ...
Status files are written atomically (write to .tmp, then mv) to prevent partial reads by the dashboard.
Each agent runs in its own git worktree on a dedicated branch:
Branch: swarm/{session}/{agent}-{num}
Path: .swarm/{session}/agents/{agent}-{num}/worktree/
This means:
- Agents never conflict with each other's file changes during implementation
- Each agent starts from the same commit on the main branch
- After all agents complete,
swarm mergecleanly integrates each branch
- Zellij >= 0.41.0 —
brew install zellij - Claude Code —
claudein PATH - Not already inside a Zellij session (
ZELLIJenv var must be unset) - A git repository with at least one commit
The main command. Runs the complete 8-phase pipeline:
ai-squad swarm feature "add user authentication with OAuth"What happens:
- Creates
.swarm/{session}/coordination directory - Launches Zellij with two panes in Tab 1:
- Orchestrator pane — runs Claude Code phases 1-3 (Discover, Architect, Plan)
- Dashboard pane — waits for
plan.md, then auto-launches agent tabs
- Orchestrator writes
docs/specs/<feature-slug>/plan.mdand stops - Dashboard detects
plan.md, prompts for confirmation (10s auto-launch), creates worktrees, launches agent tabs - Live TUI shows agent status, elapsed time, exit codes
- When all agents finish, dashboard auto-resumes orchestrator for phases 6-8
When you already have a plan.md, launch all unchecked tasks with the dashboard:
ai-squad swarm fullReads tasks from $PLAN_FILE (default: docs/specs/current/plan.md).
Override: PLAN_FILE=docs/specs/my-feature/plan.md ai-squad swarm full
What happens:
- Creates
.swarm/{session}/with pre-initialised agent dirs (status=pending) - Launches Zellij with:
- Tab 1: dashboard (monitor mode — sees pre-created agent dirs, skips plan.md wait)
- Tabs 2+: one agent wrapper per task running in an isolated git worktree
Cherry-pick specific task numbers from the plan:
ai-squad swarm tasks 1 3 5Run one agent directly without a plan file:
ai-squad swarm agent @dotnet "make OrderTests.cs pass"Show the status table for the latest (or named) swarm session:
ai-squad swarm status
ai-squad swarm status swarm-1739847123Output:
AGENT STATUS EXIT BRANCH
────────────────────────── ────────── ────── ──────
typescript-1 done 0 swarm/swarm-.../typescript-1
qa-2 error 1 swarm/swarm-.../qa-2
2 total · 1 done · 0 running · 1 error · 0 pending
Merge all status=done, exit_code=0 agent branches into the current branch:
ai-squad swarm merge
ai-squad swarm merge swarm-1739847123For each agent:
- Checks branch has new commits beyond the merge base
- Runs
git merge --no-ffwith a conventional commit message - Removes the worktree and deletes the agent branch
- On conflict: aborts the merge, writes a
merge-conflictmarker, continues others - Reports
N merged · N skipped · N conflictedat the end
Inside the Zellij session:
| Keys | Action |
|---|---|
Alt-1 |
Dashboard / orchestrator tab |
Alt-2, Alt-3, ... |
Jump to agent tab N |
Alt-n / Alt-p |
Next / previous tab |
Ctrl-o d |
Detach from session (session keeps running) |
To reattach later:
zellij attach # most recent session
zellij attach <name> # by name
zellij list-sessions # show all sessionsThe dashboard (scripts/swarm-dashboard.sh) auto-detects its mode:
- Feature mode (empty
agents/dir): waits forplan.md, then launches agent tabs - Monitor mode (pre-populated
agents/dir): goes straight to live status display
Status indicators:
[ ]pending (not started yet)[↻]running[⚠]possibly stalled (running > 90s with no worktree file changes)[✓]done (exit 0)[✗]error (non-zero exit)
The dashboard respects $NO_COLOR and degrades gracefully on dumb terminals.
You're running ai-squad swarm from within an existing Zellij session. Detach first:
Ctrl-o d # detach (session keeps running in background)Upgrade:
brew upgrade zellijThe agent has been running for > 90 seconds with no file changes in its worktree. This may be normal (agent is thinking) or the agent may be waiting for input. Jump to that agent's tab with the Alt-N shortcut shown in the dashboard.
If a branch already exists from a previous interrupted run, the wrapper tries to reuse it. If the worktree directory also exists, git will refuse to create another. Fix:
git worktree remove .swarm/{session}/agents/{agent}/worktree --force
git worktree pruneIf agents modified the same files, you'll get conflicts. The merge script aborts conflicting merges and continues others. To resolve a conflict manually:
git merge --no-ff swarm/{session}/{agent}-{N}
# resolve conflicts in editor
git add .
git merge --continueThe dashboard looks for docs/specs/**/plan.md files newer than the session sentinel. If the orchestrator wrote plan.md before the session started, it won't be detected automatically. Workaround: press Ctrl-C to exit the dashboard, then run ai-squad swarm full which reads the existing plan directly.
If the dashboard exits before auto-resuming, the resume command is saved to .swarm/{session}/resume-command.txt. Copy and run it in the orchestrator pane (Tab 1).