Documentation

Everything You Need to Know

Comprehensive documentation for OpenCode Swarm — from quick start to advanced configuration.

View on GitHub

Overview

OpenCode Swarm is a plugin for OpenCode that turns a single AI coding agent into a team of nine. One agent writes the code. A different agent reviews it. Another writes and runs tests. Another catches security issues. Nothing ships until every check passes.

9 Specialized Agents

Each with a distinct role

7 Quality Gates

Every task validated

Persistent State

Resume anytime

The Agents

Swarm has nine agents. You don't interact with them directly — the architect orchestrates everything.

AgentRoleWhen It Runs
architectPlans the project, delegates tasks, enforces quality gatesAlways (coordinator)
explorerScans your codebase to understand what existsBefore planning, after each phase
smeDomain expert (security, APIs, databases, etc.)During planning, guidance cached
criticReviews the plan before any code is writtenAfter planning, before execution
coderWrites code, one task at a timeDuring execution
reviewerReviews code for correctness and securityAfter every task
test_engineerWrites and runs tests, including adversarial edge casesAfter every task
designerGenerates UI scaffolds and design tokens (opt-in)Before UI tasks
docsUpdates documentation to match what was builtAfter each phase

Architect Workflow Modes

The architect moves through these modes automatically:

1
RESUME

Checks if .swarm/plan.md exists, picks up where it left off

2
SPECIFY

Generates a feature specification with requirements and acceptance criteria

3
CLARIFY

Asks you questions (only what it can't infer)

4
DISCOVER

Explorer scans the codebase

5
CONSULT

SME agents provide domain guidance

6
PLAN

Architect writes the phased plan

7
CRITIC-GATE

Critic reviews the plan (max 2 revision cycles)

8
EXECUTE

Tasks implemented one at a time through QA pipeline

9
PHASE-WRAP

Phase completes, docs update, retrospective written

Execution Pipeline

Every task goes through this sequence. No exceptions, no overrides.

a
@coder implements (ONE task only)
b
diff + imports (contract + dependency analysis)
c
syntax_check (parse validation)
d
placeholder_scan (catches TODOs, stubs)
e
lint fix → lint check
f
build_check (does it compile?)
g
pre_check_batch (lint, secretscan, SAST, quality)
h
@reviewer (correctness pass)
i
@reviewer (security pass, if needed)
j
@test_engineer (verification tests + coverage ≥70%)
k
@test_engineer (adversarial tests)
l
Pre-commit checklist (all 4 items required)
m
Task marked complete, evidence written

If any step fails, the coder gets structured feedback and retries. After 3 failures, the architect consults the critic. After 5 total failures, it escalates to you.

Persistent Memory (.swarm/)

All state lives in a .swarm/ folder in your project:

plan.md

Your project roadmap (tasks, status, what's done, what's next)

plan.json

Machine-readable plan state

context.md

Decisions made, expert guidance, established patterns

spec.md

Feature specification (requirements, acceptance criteria)

knowledge.jsonl

Cross-project knowledge base (lessons, patterns)

events.jsonl

Structured event log (delegations, gate results)

evidence/

Review verdicts, test results, diffs for every task

checkpoints/

Git state snapshots for rollback

history/

Phase retrospectives and metrics

Close your terminal. Come back next week. Swarm reads these files and picks up exactly where it stopped.

Knowledge System

Swarm doesn't just complete tasks — it learns from every project and shares that wisdom across all your work. This is the secret sauce that makes Swarm get smarter over time.

Two-Tier Knowledge Architecture

Swarm-Level
.swarm/knowledge.jsonl

Project-specific lessons

Max 100 entries per project

High confidence
Hive-Level
~/.config/opencode/hive-knowledge.jsonl

Cross-project wisdom

Max 1000 entries globally

How Knowledge Flows

1
Retrospectives Capture Lessons

After each phase completes, Swarm runs a retrospective that identifies what worked, what failed, and why. These lessons are written to the swarm-level knowledge base.

2
Confidence & Utility Scoring

Each knowledge entry gets a confidence score (how reliable is this lesson?) and a utility score (how often is it retrieved and helpful?). Both scores update over time based on real usage.

3
Automatic Promotion to Hive

After 30 days, entries with high confidence (≥0.8) and high utility (≥0.5) are automatically promoted to the hive-level knowledge base, making them available to ALL your swarms.

4
Injection Into Future Projects

When a new swarm starts, relevant hive knowledge is injected into the context. The architect and other agents benefit from lessons learned across all your previous projects.

Automatic Knowledge Curation

Deduplication

Cosine similarity threshold of 0.6 prevents duplicate lessons from being stored.

Quarantine System

Bad rules can be retracted via retrospectives or manually quarantined. Fingerprinted to prevent re-learning.

Auto-Pruning

Low-utility entries (utility < 0.2) with minimal retrievals are automatically removed.

Knowledge Commands

/swarm knowledge quarantine <id> [reason]Manually quarantine a bad or misleading knowledge entry
/swarm knowledge restore <id>Restore a previously quarantined entry
/swarm knowledge migrateMigrate legacy lessons from context.md to knowledge.jsonl

Knowledge Configuration

{
  "knowledge": {
    "enabled": true,
    "swarm_max_entries": 100,
    "hive_max_entries": 1000,
    "auto_promote_days": 30,
    "max_inject_count": 5,
    "dedup_threshold": 0.6,
    "hive_enabled": true,
    "evergreen_confidence": 0.8,
    "evergreen_utility": 0.5,
    "low_utility_threshold": 0.2
  }
}

Why This Matters

Most AI coding tools start from scratch every session. Swarm builds institutional memory. That mistake you made on Project A? Swarm won't let you make it again on Project B. That clever pattern you discovered? It's now available to every project you start. The more you use Swarm, the smarter it gets.

Guardrails & Circuit Breakers

Every agent runs inside a circuit breaker that kills runaway behavior before it burns your credits.

SignalDefault LimitWhat Happens
Tool calls200Agent is stopped
Duration30 minAgent is stopped
Same tool repeated10xAgent warned, then stopped
Consecutive errors5Agent is stopped

Limits reset per task. Override per-agent in your config.

Supported Languages

OpenCode Swarm v6.16+ ships with language profiles for 11 languages across three quality tiers.

LanguageTierLintTestSAST
TypeScript / JavaScript1Biome / ESLintSemgrep
Python1ruffpytestSemgrep
Rust1clippycargo testSemgrep
Go1golangci-lintgo testSemgrep
Java2CheckstyleJUnitSemgrep
Kotlin2ktlintJUnitSemgrep beta
C# / .NET2dotnet formatdotnet testSemgrep
C / C++2cppcheckctestSemgrep exp.
Swift2swiftlintswift testSemgrep exp.
Dart / Flutter3dart analyzedart test
Ruby3RuboCopRSpec/minitestSemgrep exp.

Tier 1: Full pipeline. Tier 2: Strong coverage. Tier 3: Basic coverage.

Configuration

Config file location: ~/.config/opencode/opencode-swarm.json (global) or .opencode/swarm.json (project). Project config merges over global.

{
  "agents": {
    "architect": { "model": "anthropic/claude-opus-4-6" },
    "coder": { "model": "minimax-coding-plan/MiniMax-M2.5" },
    "reviewer": { "model": "zai-coding-plan/glm-5" }
  },
  "guardrails": {
    "max_tool_calls": 200,
    "max_duration_minutes": 30
  },
  "knowledge": {
    "enabled": true,
    "hive_enabled": true
  }
}

All Commands

Complete list of slash commands available in OpenCode Swarm.

/swarm statusCurrent phase, task progress, agent count
/swarm plan [N]Full plan or filtered by phase
/swarm agentsRegistered agents with models and permissions
/swarm historyCompleted phases with status
/swarm configCurrent resolved configuration
/swarm config doctor [--fix]Config validation with optional auto-fix
/swarm diagnoseHealth check for .swarm/ files and config
/swarm exportExport plan and context as portable JSON
/swarm evidence [task]Evidence bundles for a task or all tasks
/swarm archive [--dry-run]Archive old evidence with retention policy
/swarm retrieve [id]Retrieve auto-summarized tool outputs
/swarm reset --confirmClear swarm state files
/swarm specify [description]Generate or import a feature specification
/swarm clarify [topic]Clarify and refine an existing specification
/swarm analyzeAnalyze spec.md vs plan.md for coverage gaps
/swarm preflightRun phase preflight checks
/swarm sync-planForce plan.md regeneration from plan.json
/swarm benchmarkPerformance benchmarks
/swarm dark-matterDetect hidden file couplings via git analysis
/swarm knowledge quarantine <id>Quarantine a knowledge entry
/swarm knowledge restore <id>Restore a quarantined entry
/swarm knowledge migrateMigrate legacy context.md to knowledge.jsonl
/swarm rollbackRestore swarm state to a checkpoint