Documentation

Swarm Engine runs multiple AI agents on the same task -- researchers find the relevant code, implementers write the changes, reviewers catch the mistakes. This is the full reference for configuring agents, choosing patterns, mixing backends, and getting the most out of every run.

Installation

Swarm Engine requires Node.js 20+ and at least one AI coding tool (Claude Code, Codex, or Gemini CLI).

Install globallybash
$ npm install -g swarm-engine
$ swarm install    # Set up Claude Code integration
$ swarm doctor     # Verify everything works

swarm install configures Claude Code by symlinking agents, slash commands, and hooks into ~/.claude/. swarm doctor checks your Node version, CLI tools, and integration setup.

Quickstart

Run your first multi-agent orchestration:

Your first orchestrationbash
# Run a full research > implement > review cycle
$ swarm orchestrate "add rate limiting to the API"

# Preview the plan without executing
$ swarm orchestrate "add rate limiting" --dry-run

# Use a different pattern
$ swarm orchestrate "fix auth bypass" --pattern red-team

# Run a single agent
$ swarm run researcher "how does the auth middleware work?"

Full Walkthrough

Here's a complete session from scratch -- initializing a project, previewing a plan, running an orchestration, and inspecting the results.

Step 1: Initialize your projectbash
$ cd my-api
$ swarm init --yes

  Project: my-api
  Backend: claude
  Pattern: hybrid
  Budget: $5.00
  Created .swarm/
Step 2: Preview the plan (no cost, instant)bash
$ swarm plan "add rate limiting to POST /api/users"

  Execution Plan: hybrid
  Task: add rate limiting to POST /api/users

    Phase 1: research [parallel]
      researcher-code     -- researcher (claude-sonnet-4-6)
      researcher-context  -- researcher (claude-sonnet-4-6)

    Phase 2: implement [sequential]
      implementer         -- implementer (claude-opus-4-6)

    Phase 3: review [parallel]
      reviewer-security   -- security-reviewer (claude-opus-4-6)
      reviewer-convention -- reviewer (claude-sonnet-4-6)

    Est. cost:     $0.18
    Est. duration: 94s
    Est. tokens:   28,400
    Quality:       87%
Step 3: Run itbash
$ swarm orchestrate "add rate limiting to POST /api/users"

  Swarm Engine - hybrid pattern

  Phase 1: research ━━━━━━━━━━━━━━━━━━━━ 100%  38s
    ✓ researcher-code       claude-sonnet-4-6   3.2K tokens
    ✓ researcher-context    claude-sonnet-4-6   1.8K tokens

  Phase 2: implement ━━━━━━━━━━━━━━━━━━━ 100%  1m 42s
    ✓ implementer           claude-opus-4-6     12.1K tokens

  Phase 3: review ━━━━━━━━━━━━━━━━━━━━━━ 100%  52s
    ✓ reviewer-security     claude-opus-4-6     4.8K tokens
    ✓ reviewer-convention   claude-sonnet-4-6   3.1K tokens

  ┌──────────────────────────────────────────────┐
  │  ✓ Orchestration complete                    │
  │  Pattern: hybrid (3 phases, 5 agents)        │
  │  Tokens: 24,900 | Cost: $0.21 | Time: 3m 12s│
  └──────────────────────────────────────────────┘

  Changes:
    src/middleware/rate-limit.ts    | 48 +++
    src/routes/users.ts            |  3 +-
    tests/middleware/rate-limit.test.ts | 62 +++

  Template name (or Enter to skip):
Step 4: Check what the engine learnedbash
$ swarm memory search "rate limiting"

  Found 1 result(s):

  Rate limiting implementation outcome [outcome]
    Completed hybrid orchestration for rate limiting on POST /api/users...
    repo: my-api

Project Setup

Initialize Swarm Engine in a project for custom agents and templates:

Initialize projectbash
$ cd my-project
$ swarm init

  Project: my-project
  Available backends:
    claude  ✓
    codex   ✓
    gemini  -

  Created:
    .swarm/config.yml
    .swarm/agents/
    .swarm/templates/

The agent resolution chain loads from three locations (project overrides global):

  1. .swarm/agents/ in your project (highest priority)
  2. ~/.claude/agents/ user-level agents
  3. Built-in agents shipped with the engine

Architecture

How the pieces fit together:

System overviewtext
  ┌─────────────────────────────────────────────────────────────┐
    CLI / Slash Command / VS Code                              
    swarm orchestrate "task"  |  /swarm "task"  |  @swarm task  
  └────────────────────────────┬────────────────────────────────┘┌────────────────────────────▼────────────────────────────────┐
    Planner                                                    
    Pattern selection → Cost estimation → Plan search           
    Heuristic injection → Adaptive replanning                   
  └────────────────────────────┬────────────────────────────────┘┌────────────────────────────▼────────────────────────────────┐
    DAG Executor                                               
    Phase 1 (parallel) → Phase 2 (sequential) → Phase 3 ...    
    Error retry · Cascade escalation · Agent dropout            
  └──┬──────────┬──────────┬──────────┬────────────────────────┘
     │          │          │          │
  ┌──▼──┐  ┌──▼──┐  ┌──▼──┐  ┌──▼──┐    Backends
  │Claude│  │Codex│  │Gemin│  │AI SD│    (pluggable)
  └──┬──┘  └──┬──┘  └──┬──┘  └──┬──┘
     │          │          │          │
  ┌──▼──────────▼──────────▼──────────▼────────────────────────┐
    Memory & Learning                                        
    Traces → Heuristics → Knowledge compounding               
    SQLite + FTS5  |  Obsidian vault (optional)                
  └─────────────────────────────────────────────────────────────┘

The flow: your task enters through the CLI, slash command, or VS Code. The Planner selects a pattern, estimates cost, searches for the best plan variant, and injects lessons from past runs. The DAG Executor runs each phase in order, dispatching agents in parallel within a phase. Each agent runs on its configured Backend. After completion, the results feed back into Memory for future runs.

Orchestration

An orchestration is a DAG (directed acyclic graph) of phases. Each phase contains one or more agents that run in parallel. Phases execute sequentially, with output from earlier phases feeding into later ones.

Hybrid pattern flowtext
Phase 1: research  [parallel]
    researcher-code     claude-sonnet-4-6  Explore codebase
    researcher-context  claude-sonnet-4-6  Check memory
           |
Phase 2: implement [parallel]
    implementer         claude-opus-4-6    Build the feature
           |
Phase 3: review    [parallel]
    reviewer-security   claude-opus-4-6    OWASP, injection
    reviewer-perf       claude-sonnet-4-6  Perf regression
    reviewer-convention claude-sonnet-4-6  Code style

The engine handles agent lifecycle, error recovery with retry, adaptive replanning, cost tracking, and output aggregation between phases.

Patterns

Patterns are predefined orchestration workflows. Each defines a sequence of phases, which agents to use, and how they connect.

PatternPhasesBest For
hybridResearch → Implement → ReviewGeneral features, most tasks
tddWrite Tests → Implement → Verify → ReviewTest-driven development
red-teamBuild → Attack → HardenSecurity-sensitive code
spikeApproach A + B → Judge → IntegrateUncertain approach, need to compare
discoverHypothesize → Experiment → BuildComplex, novel problems
review-cycleImplement → Challenge → Fix (loop)Quality-critical code
researchParallel fan-out investigationUnderstanding codebases

Composing Patterns

Chain patterns together with the pipe operator:

Pattern compositionbash
# TDD then red-team the result
$ swarm orchestrate "add payment processing" --pattern "tdd | red-team"

# Research first, then TDD
$ swarm orchestrate "migrate to new ORM" --pattern "research | tdd"

Agents

26 specialized agents ship with the engine. Each has a defined role, model preference, tool access, and prompt.

Core Agents

researcher mid
implementer expensive
reviewer expensive
tester expensive
debugger expensive
refactorer expensive
documenter cheap
planner expensive
orchestrator expensive
integrator mid
judge expensive
guardian mid
sentinel mid
grounding expensive
librarian mid
devils-advocate expensive

Specialized Reviewers

security expensive
performance mid
data-integrity expensive
api-contracts mid
testing mid
accessibility mid
dependencies cheap
error-handling mid
concurrency expensive
documentation cheap
List available agentsbash
$ swarm agents list
$ swarm agents list --json  # Machine-readable

Model Configuration

Every agent specifies which model it runs on. The model field takes the actual model name from any provider.

Agent model in frontmattermarkdown
---
name: security-reviewer
model: claude-opus-4-6       # The actual model this agent runs on
backend: claude
---

---
name: codex-reviewer
model: o3                    # OpenAI model
backend: codex
---

---
name: gemini-researcher
model: gemini-2.5-pro        # Google model
backend: gemini
---

Overriding Models

LevelHowScope
Agent definitionmodel: claude-opus-4-6 in frontmatterThat agent everywhere
Project configagents.reviewer.model: claude-sonnet-4-6 in .swarm.ymlThat agent in this project
Templatemodel in agent assignmentThat agent in that template
CLI flag--model claude-opus-4-6All agents in this run
Adaptive replannerAutomaticAdjusts at runtime based on task complexity
Override model from CLIbash
# Force all agents to use Opus
$ swarm orchestrate "add auth" --model claude-opus-4-6

# Force all agents to use Haiku (cheapest)
$ swarm orchestrate "add docs" --model claude-haiku-4-5-20251001

# Single agent with a specific model
$ swarm run researcher "explore codebase" -m claude-opus-4-6

Tiers

The planner uses a tier to estimate cost and decide when to upgrade or downgrade models. Tiers are auto-inferred from the model name, so you rarely need to set them manually.

TierWhen to useClaudeOpenAIGoogle
cheapQuick tasks, boilerplate, scanningclaude-haiku-4-5gpt-4o-mini, o4-minigemini-2.5-flash
midMost tasks, general implementationclaude-sonnet-4-6gpt-4o, gpt-4.1gemini-2.5-flash
expensiveHard reasoning, security, architectureclaude-opus-4-6o3gemini-2.5-pro

You can set tier explicitly in the frontmatter to override the auto-inference, but the default behavior covers most cases:

Optional: explicit tiermarkdown
---
name: my-agent
model: o3
backend: codex
tier: expensive   # Optional. Auto-inferred from model name if omitted.
---
i
The adaptive replanner uses tiers to make runtime decisions. If a task is simpler than expected, it may swap an expensive agent for a mid one to save cost. If a task is struggling, it may escalate from mid to expensive.

Backends

Different agents can use different AI backends in the same orchestration. Swarm Engine supports four backends, each with its own CLI tool or SDK.

BackendCLI ToolModelsAPI Key
claudeClaude CodeOpus, Sonnet, HaikuVia claude auth login
codexOpenAI Codex CLIo4-mini, o3, GPT-4.1OPENAI_API_KEY
geminiGoogle Gemini CLIGemini 2.5 Pro, 2.5 FlashGEMINI_API_KEY
vercel-aiProgrammatic (no CLI)20+ providersPer-provider env vars

Installing Backends

Install backend CLIsbash
# Claude Code (required for default backend)
$ npm install -g @anthropic-ai/claude-code

# OpenAI Codex CLI
$ npm install -g @openai/codex
$ export OPENAI_API_KEY=sk-...

# Google Gemini CLI
$ npm install -g @google/gemini-cli
$ export GEMINI_API_KEY=AIza...

# Vercel AI SDK (for programmatic access to 20+ providers)
$ npm install ai @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google

# Check which backends are available
$ swarm doctor

Using Different Backends

Global backend overridebash
# Run entire orchestration on Codex
$ swarm orchestrate "add rate limiting" --backend codex

# Run entire orchestration on Gemini
$ swarm orchestrate "add logging" --backend gemini

# Run a single agent on Codex
$ swarm run researcher "explore the auth module" --backend codex

Mixing Backends Per Agent

The real power is mixing backends in the same orchestration. Set backend and model in the agent's frontmatter:

.swarm/agents/codex-reviewer.mdmarkdown
---
name: codex-reviewer
description: "Code reviewer powered by OpenAI"
model: o3
backend: codex
tools: Read, Glob, Grep, Bash
---

You are a code reviewer. Review for correctness, edge cases, and security.
.swarm/agents/gemini-researcher.mdmarkdown
---
name: gemini-researcher
description: "Research agent powered by Google Gemini"
model: gemini-2.5-pro
backend: gemini
tools: Read, Glob, Grep
---

You are a research agent. Thoroughly investigate the codebase and report findings.

Now when you run an orchestration, Claude handles implementation, Codex handles review, and Gemini handles research -- all in the same run:

Mixed backend orchestrationbash
$ swarm orchestrate "add payment processing"

  Pattern: hybrid
  Phase 1: research
    gemini-researcher     gemini   gemini-2.5-pro
  Phase 2: implement
    implementer           claude   claude-sonnet-4-6
  Phase 3: review
    codex-reviewer        codex    o3
    security-reviewer     claude   claude-opus-4-6

Vercel AI SDK (Advanced)

For programmatic access without CLI tools, use the vercel-ai backend. Specify the model in provider/model format:

Agent with Vercel AI SDKmarkdown
---
name: llama-researcher
model: groq/llama-3.3-70b-versatile
backend: vercel-ai
---

Cost Guide

Every orchestration consumes API tokens billed by the underlying providers. Here's what to expect.

Typical Costs by Pattern

PatternAgentsTokensEstimated Cost
hybrid5-625-40K$0.15 - $0.40
tdd6-835-55K$0.25 - $0.60
red-team6-840-60K$0.30 - $0.70
spike5-740-60K$0.30 - $0.65
review-cycle4-630-50K$0.20 - $0.50
research2-410-20K$0.05 - $0.15
Single agent (swarm run)15-15K$0.02 - $0.10

These are rough estimates for typical tasks. Complex tasks with large codebases will use more tokens. Simple tasks will use less.

Tier Pricing

Cost depends heavily on which tier the agents use:

TierInput (per 1M tokens)Output (per 1M tokens)Use for
cheap$0.25$1.25Scanning, docs, dependencies
mid$3.00$15.00Research, most implementation
expensive$15.00$75.00Security review, complex reasoning

Controlling Cost

Cost controlsbash
# Preview cost before running (free, instant)
$ swarm plan "add auth"

# Set a hard budget cap
$ swarm orchestrate "add auth" --budget 1

# Test with mock execution (free, no API calls)
$ swarm orchestrate "add auth" --mock

# Force cheaper models
$ swarm orchestrate "add auth" --model claude-sonnet-4-6
*
The adaptive replanner automatically downgrades agents to cheaper tiers when the task is simpler than expected, saving cost without you doing anything.

swarm orchestrate

Run a full multi-phase orchestration pattern.

Usagebash
swarm orchestrate <task> [options]
OptionDefaultDescription
-p, --patternhybridOrchestration pattern to use
-m, --modelOverride model for all agents (e.g., claude-opus-4-6, o3)
-b, --backendclaudeExecution backend
--budget5Max budget in USD
--dry-runShow plan without executing
--tuiLive terminal dashboard
--panesRun agents in tmux split panes
--mockMock execution (no API calls)
--verboseDebug-level output
--jsonMachine-readable JSON output
Examplesbash
# Full orchestration with live TUI dashboard
$ swarm orchestrate "add WebSocket support" --tui

# Test-driven with $2 budget cap
$ swarm orchestrate "add input validation" --pattern tdd --budget 2

# Red-team with agents in visible tmux panes
$ swarm orchestrate "harden the auth flow" --pattern red-team --panes

# Compose patterns: TDD then adversarial review
$ swarm orchestrate "add payment API" --pattern "tdd | red-team"

# Dry run to preview cost and plan
$ swarm orchestrate "refactor database layer" --dry-run

Running Modes

There are three ways to run an orchestration, each with different visual output:

ModeHowAgent VisibilityTerminal Support
Inline progress swarm orchestrate "task" Rich progress bars, phase status, live cost counter in your terminal Any terminal
TUI dashboard swarm orchestrate "task" --tui Full-screen dashboard with agent status, token usage, phase timeline Any terminal
tmux panes swarm orchestrate "task" --panes Each agent runs in a visible tmux split pane showing raw output Any terminal with tmux installed
Claude Code panes /swarm "task" in Claude Code Each agent spawns as a teammate in a native split pane iTerm2, VS Code terminal
*
tmux panes require brew install tmux (or your package manager). They work in any terminal.
Claude Code panes are built into Claude Code and require no extra config. They work automatically in iTerm2 and VS Code. In terminals without pane support, agents still run in the background.

swarm run

Run a single agent with a task. Useful for quick operations that don't need a full orchestration.

Usagebash
swarm run <agent> <task> [options]
OptionDefaultDescription
-m, --modelclaude-sonnet-4-6Model to use (e.g., claude-opus-4-6, o3)
-b, --backendclaudeExecution backend
--timeout300Timeout in seconds
--mockMock execution
Examplesbash
# Research a codebase question
$ swarm run researcher "how does the caching layer work?"

# Run the security reviewer on current changes
$ swarm run security-reviewer "review recent changes for vulnerabilities" -m claude-opus-4-6

# Debug a specific issue
$ swarm run debugger "why does the login endpoint return 500?"

swarm plan

Generate an execution plan without running it. Shows phases, agents, estimated cost, duration, and quality score.

Usagebash
swarm plan <task> [options]

# Options: -p/--pattern, --budget, --json
Example outputtext
$ swarm plan "add rate limiting" --pattern hybrid

Execution Plan: hybrid
Task: add rate limiting
Budget: $5

  Phase 1: research [parallel]
    researcher-code     — researcher (claude-sonnet-4-6)
    researcher-context  — researcher (claude-sonnet-4-6)

  Phase 2: implement [sequential]
    implementer         — implementer (claude-opus-4-6)

  Phase 3: review [parallel]
    reviewer-security   — security-reviewer (claude-opus-4-6)
    reviewer-perf       — performance-reviewer (claude-sonnet-4-6)
    reviewer-convention — reviewer (claude-sonnet-4-6)

  Est. cost:     $0.1842
  Est. duration: 94s
  Est. tokens:   28,400
  Quality:       87%

  Optimizations applied:
    → Downgraded reviewer-convention from expensive to mid tier (low complexity)
    → Injected 2 heuristics from similar past runs

swarm template

Manage reusable orchestration templates.

Commandsbash
# List available templates
$ swarm template list

# Run a template interactively (prompts for parameters)
$ swarm template run add-feature -i

# Run with explicit parameters
$ swarm template run bug-fix --param bug_description="login fails on mobile"

# Create template from last successful orchestration
$ swarm template create my-workflow --from-last

# Create a blank template scaffold
$ swarm template create my-workflow

swarm memory

Query and manage the knowledge base. The engine learns from every orchestration and stores decisions, patterns, and outcomes.

Commandsbash
# Search the knowledge base
$ swarm memory search "authentication"
$ swarm memory search "rate limiting" --type decision --repo my-api

# Store a new entry
$ echo "Use Redis for rate limiting, not in-memory" | swarm memory store decision "Rate limit backend choice" --repo my-api

# List recent entries
$ swarm memory list --type outcome --limit 5

# View statistics
$ swarm memory stats
i
Memory types: decision, pattern, learning, context, outcome. The engine automatically stores outcomes after each orchestration and injects relevant memories into future plans.

swarm convert

Export agents to work natively in other AI coding tools.

Commandsbash
# List conversion targets
$ swarm convert --list

# Convert agents for a specific tool
$ swarm convert --to copilot   # GitHub Copilot instructions
$ swarm convert --to cursor    # Cursor rules
$ swarm convert --to codex     # OpenAI Codex agents
$ swarm convert --to gemini    # Gemini CLI
$ swarm convert --to opencode  # OpenCode
$ swarm convert --to windsurf  # Windsurf

# Convert only agent definitions (skip commands)
$ swarm convert --to cursor --agents-only

# Custom output directory
$ swarm convert --to copilot --output ./my-copilot-config

swarm agents

Manage agent definitions. Agents are loaded from project, user, installed packs, and built-in directories.

Commandsbash
# List all registered agents
$ swarm agents list
$ swarm agents list --json

# Show full agent definition (frontmatter + prompt)
$ swarm agents show researcher

# Create a new agent scaffold
$ swarm agents new my-reviewer
$ swarm agents new my-reviewer --dir ~/.swarm/agents

# Install agents from a GitHub repo
$ swarm agents install github:myorg/my-agents

# Test an agent with mock execution
$ swarm agents test researcher "explore the auth module"

# Search GitHub for agent packs
$ swarm agents search security

swarm init

Interactive project setup wizard. Creates .swarm/ directory structure with agents, templates, and a project config file.

Usagebash
$ swarm init          # Interactive setup
$ swarm init --yes    # Accept defaults, skip prompts

Detects available backends, prompts for default pattern and budget, creates .swarm.yml, and runs swarm doctor.

swarm verify

Run project verification commands. Auto-detects TypeScript, Node.js, ESLint, Python, Go, and Rust projects.

Usagebash
$ swarm verify                   # Run all detected checks
$ swarm verify --cwd ./packages/api  # Verify a subdirectory

swarm status

Show active teams, registered agents, templates, recent orchestrations, and saved checkpoints.

Usagebash
$ swarm status              # Full status overview
$ swarm status --backends    # Available execution backends
$ swarm status --patterns    # Orchestration patterns with phase breakdown

swarm compound

Compound knowledge from orchestration outcomes into searchable solution docs, organized by problem category.

Commandsbash
# Extract solutions from recent traces
$ swarm compound extract --count 10

# Search compounded knowledge
$ swarm compound search "rate limiting"

# List by category
$ swarm compound list --category security

# Statistics and stale entries
$ swarm compound stats
$ swarm compound stale
i
Categories: bug-fix, feature, refactor, security, performance, testing, migration, integration, architecture

swarm learn

Interactive tutorial with 5 guided lessons. Progress is tracked across sessions.

Usagebash
$ swarm learn      # List lessons with completion status
$ swarm learn 1    # Lesson 1: Your First Plan
$ swarm learn 2    # Lesson 2: Run a Mock Orchestration
$ swarm learn 3    # Lesson 3: Explore Your Agents
$ swarm learn 4    # Lesson 4: Templates
$ swarm learn 5    # Lesson 5: Health Check

swarm doctor

Diagnostic tool that checks your installation.

Example outputtext
$ swarm doctor

Swarm Doctor

  ✓ Node.js 22.1.0
  ✓ jq
  ✓ Claude Code
  ✓ swarm on PATH
  ✓ CLAUDE.md configured
  ✓ ~/.swarm/ exists
  ✓ Claude Code integration installed

  Optional backends:
  ✓ Codex CLI
  - Gemini not installed (npm i -g @google/gemini-cli)

  All checks passed.

Templates

Templates are parameterized orchestrations you can reuse. They define a pattern, parameters, agent customizations, and success criteria.

templates/add-feature.ymlyaml
name: add-feature
description: "Add a new feature with tests and documentation"
parameters:
  feature:
    type: string
    description: "Feature description"
    required: true
  test_framework:
    type: string
    description: "Test framework to use"
    default: "jest"
pattern: hybrid
agents:
  researcher:
    extra_rules:
      - "Understand how similar features are implemented"
      - "Identify affected modules and side effects"
  implementer:
    extra_rules:
      - "Follow existing code patterns"
      - "Write tests using ${test_framework}"
  reviewer:
    extra_rules:
      - "Check for edge cases and error handling"
      - "Verify test coverage"
success_criteria:
  - "Feature works as described"
  - "Tests pass with good coverage"
  - "No regressions"
tags: [feature, implementation]

8 built-in templates ship with the engine: add-feature, add-endpoint, bug-fix, refactor, migration, security-audit, explore, and fix-pr.

Custom Agents

Agents are markdown files with YAML frontmatter. Create custom agents in .swarm/agents/ or ~/.claude/agents/.

.swarm/agents/api-reviewer.mdmarkdown
---
name: api-reviewer
description: "Reviews API endpoints for consistency and best practices"
model: claude-sonnet-4-6
tools: Read, Glob, Grep, Bash
disallowedTools: Write, Edit
permissionProfile: safe
maxTurns: 20
---

You are an API Review Agent. Check every endpoint for:

1. Consistent naming (REST conventions)
2. Proper HTTP status codes
3. Input validation on all parameters
4. Rate limiting configuration
5. Authentication requirements
6. Response schema consistency

## Output Format
```
## API Review
- Endpoint: [path]
  - Status: [pass/fail]
  - Issues: [list]
```
*
Agent frontmatter fields: name, description, model (actual model name, e.g., claude-sonnet-4-6, o3, gemini-2.5-pro), tier (optional: cheap/mid/expensive), tools, disallowedTools, permissionProfile (safe/default/bypassPermissions), maxTurns, backend (claude/codex/gemini/vercel-ai).

Memory & Learning

The engine has a built-in knowledge base that stores decisions, patterns, learnings, and outcomes. It learns from every orchestration and feeds that knowledge into future plans.

Storage

Memory is backed by SQLite with FTS5 full-text search. The database is created automatically on first use -- no setup required.

ComponentLocationSetup
Memory database~/.swarm/data/memory.dbAuto-created on first use
Heuristic store~/.swarm/data/heuristics.dbAuto-created on first use
Trace store~/.swarm/data/traces.dbAuto-created on first use
Obsidian vault (optional)~/swarm-vault/ or $SWARM_VAULTManual setup

All SQLite databases and the ~/.swarm/ directory are created automatically. You don't need to install SQLite separately -- it's bundled via better-sqlite3.

Obsidian Vault (Optional)

If you use Obsidian, the engine can write every memory entry as a markdown file to a vault directory. This gives you cross-machine sync (via Obsidian Sync or git), human-browsable knowledge, and graph visualization of related entries.

Set up Obsidian vaultbash
# Option 1: Use the default location
$ mkdir -p ~/swarm-vault

# Option 2: Use a custom location via environment variable
$ export SWARM_VAULT=/path/to/your/obsidian/vault

# Then open the vault directory in Obsidian

When a vault directory exists, every swarm memory store call writes both to SQLite (primary) and to the vault as a markdown file with YAML frontmatter. The vault structure looks like:

Vault directory structuretext
~/swarm-vault/
  decisions/
    2026-04-05-rate-limit-backend-choice.md
    2026-04-03-auth-session-storage.md
  patterns/
    2026-04-04-error-handling-pattern.md
  learnings/
    2026-04-05-q1-refactor-results.md
  repos/
    my-api/
      rate-limiting.md
      auth-middleware.md
i
SQLite is always the source of truth. The vault is a write-through cache for human browsing and cross-machine sync. If the vault write fails, the SQLite store still succeeds. You can delete the vault at any time without losing data.

Heuristic Learning

After each orchestration, the engine extracts lessons from execution traces. These heuristics are injected into future plans for similar tasks.

How it workstext
Run 1: "add auth" → research took 60s, implement took 120s
Run 2: "add rate limiting" → engine injects heuristic:
         "Similar tasks average 90s research. Allocate accordingly."
Run 3: "add caching" → engine now has 2 data points, refines estimate

Knowledge Compounding

Solutions are organized by problem category (auth, data, API, testing, etc.) and retrieved when similar tasks appear.

Knowledge compounding CLIbash
$ swarm compound extract   # Extract knowledge from recent traces
$ swarm compound search "auth"  # Search compounded knowledge
$ swarm compound stats    # Show category breakdown
$ swarm compound stale    # Find outdated entries

Execution Traces

Every orchestration is recorded as a trace with full timing, token usage, and outcome data. Traces feed the heuristic learning and plan optimization systems.

Cross-Tool Export

Export your agent definitions to work natively in 6 other AI coding tools. The converter translates frontmatter, prompts, and tool configurations into each tool's native format.

TargetOutputWhat's Generated
copilot.github/copilot-instructions.mdCopilot instruction files
cursor.cursor/rules/Cursor rule files
codex.codex/agents/Codex agent definitions
gemini.gemini/agents/Gemini agent configs
opencode.opencode/agents/OpenCode agent files
windsurf.windsurf/Windsurf rule files

Project Config

The .swarm.yml file in your project root configures defaults for all orchestrations in that project.

.swarm.ymlyaml
project: my-api
default_pattern: hybrid
default_backend: claude
cost_budget: 5.00
agents:
  reviewer:
    extra_rules:
      - "Check for PII in log statements"
      - "Verify all endpoints have rate limiting"
context_files:
  - docs/architecture.md
  - docs/api-spec.md

Create this file with swarm init or manually. Agent extra_rules are appended to the agent's prompt for every orchestration in this project.

Claude Code Integration

After running swarm install, Swarm Engine integrates directly into Claude Code with slash commands, agents, and hooks.

Setup

One-time setupbash
$ swarm install

  Installed:
    ~/.claude/agents/     26 agent definitions
    ~/.claude/commands/    9 slash commands
    ~/.claude/hooks/       event hooks
    ~/.claude/CLAUDE.md    swarm snippet injected

Slash Commands

In Claude Codetext
# Full orchestration (hybrid pattern by default)
/swarm "add rate limiting to the API"

# Pattern-specific commands
/research "how does the auth system work?"
/tdd "add input validation to user endpoints"
/red-team "harden the payment flow"
/review-cycle "refactor the database layer"

# Utility commands
/diff-review                # Review current git diff
/fix-pr "fix CI failures"   # Fix a failing pull request

Split Panes

When you run /swarm in Claude Code, each agent spawns as a teammate in its own split pane. This is Claude Code's native team protocol, not tmux.

TerminalPane SupportNotes
iTerm2 (macOS)Full split panesEach agent visible in its own pane
VS Code terminalFull split panesWorks in the integrated terminal
Terminal.appBackground onlyAgents run but no visible panes
Other terminalsVariesFalls back to background if unsupported

No extra configuration needed. Claude Code detects your terminal and uses native pane splitting when available. Agents always complete their work regardless of pane visibility.

*
If you want visible panes in a terminal that doesn't support Claude Code split panes, use the CLI instead: swarm orchestrate "task" --panes (uses tmux, works everywhere).

VS Code Extension

The VS Code extension adds Swarm Engine to the Copilot Chat sidebar.

In VS Code Copilot Chattext
# Use the @swarm chat participant
@swarm add rate limiting to the API

# Or use the command palette
Cmd+Shift+P → Swarm: Orchestrate

Install from the VS Code Marketplace.

Environment Variables

VariablePurposeRequired
OPENAI_API_KEYAPI key for Codex backendOnly if using --backend codex
GEMINI_API_KEYAPI key for Gemini backendOnly if using --backend gemini
GOOGLE_API_KEYAlternate key for GeminiAlternative to GEMINI_API_KEY
SWARM_VAULTPath to Obsidian vault directoryNo (defaults to ~/swarm-vault/)
SWARM_DATA_DIROverride data directoryNo (defaults to ~/.swarm/data/)

Claude Code authentication is handled through claude auth login, not environment variables.

Best Practices

Choosing a Pattern

Keeping Costs Down

Writing Custom Agents

Working with Memory

Glossary

TermDefinition
AgentA specialized AI worker with a defined role, model, tools, and prompt. Runs a single task within a phase.
BackendThe AI tool that executes an agent: Claude Code, Codex CLI, Gemini CLI, or Vercel AI SDK.
DAGDirected acyclic graph. The execution structure where phases run in dependency order.
HeuristicA lesson extracted from a past execution trace. Injected into future plans to improve estimates.
ModelThe specific AI model an agent runs on (e.g., claude-opus-4-6, o3).
OrchestrationA complete multi-agent run from start to finish, following a pattern through multiple phases.
PatternA predefined workflow defining which phases run, with what agents, in what order (e.g., hybrid, tdd, red-team).
PhaseA step in an orchestration. Contains one or more agents that run in parallel or sequentially.
TemplateA parameterized, reusable orchestration config. Like a pattern but with custom agent rules and parameters.
TierCost/capability classification: cheap (fast, simple tasks), mid (general work), expensive (hard reasoning).
TraceA recorded execution with timing, tokens, cost, and outcome. Feeds the learning system.

Troubleshooting

Installation

ProblemFix
swarm: command not foundRun npm install -g swarm-engine. If installed, check your PATH includes npm global bin: npm bin -g
swarm doctor says "Node.js < 20"Upgrade Node: nvm install 22 or brew install node
swarm doctor says "CLAUDE.md missing"Run swarm install to inject the Claude Code integration snippet
swarm doctor says "jq not found"brew install jq (macOS) or apt install jq (Linux)

Orchestration

ProblemFix
Orchestration stuck on "running"Check swarm status. An agent may be waiting for input. Use --budget to set a timeout, or Ctrl+C and check the event log at ~/.swarm/data/events.jsonl
"Unknown pattern: xyz"Check available patterns: swarm status --patterns. Built-in: hybrid, tdd, red-team, spike, discover, review-cycle, research
"Unknown agent: xyz"Check registered agents: swarm agents list. Custom agents go in .swarm/agents/
Budget exceeded mid-runNormal. The engine stops when the budget cap is hit. Increase with --budget 10 or use swarm plan to estimate first
Agent returning low confidenceThe task may be too vague or the model too weak. Try a more specific prompt or --model claude-opus-4-6

Backends

ProblemFix
"Authentication error"For Claude: claude auth login. For Codex: check OPENAI_API_KEY. For Gemini: check GEMINI_API_KEY
"Backend not available: codex"npm install -g @openai/codex then verify with swarm doctor
"Backend not available: gemini"npm install -g @google/gemini-cli then verify with swarm doctor
tmux panes not showingInstall tmux: brew install tmux. Verify: tmux -V

Memory

ProblemFix
"No results found" on searchMemory builds up over time. Run a few orchestrations first. Or store entries manually with swarm memory store
Vault not syncingCheck the vault directory exists: ls ~/swarm-vault/. Or set export SWARM_VAULT=/your/path
SQLite database lockedAnother swarm process may be running. Check with swarm status or ps aux | grep swarm