The only multi-agent framework that actually works.
Structured phases. Persistent memory. One task at a time. QA on everything.
Why Swarm? β’ How It Works β’ Installation β’ Agents β’ Configuration
You: "Build me an authentication system"
Other Frameworks:
βββ Agent 1 starts auth module...
βββ Agent 2 starts user model... (conflicts with Agent 1)
βββ Agent 3 starts database... (wrong schema)
βββ Agent 4 starts tests... (for code that doesn't exist yet)
βββ Result: Chaos. Conflicts. Context lost. Start over.
OpenCode Swarm:
βββ Architect analyzes request
βββ Explorer scans codebase
βββ Security SME provides auth guidance
βββ Architect creates phased plan with acceptance criteria
βββ Phase 1: User model β QA β Tests β β
βββ Phase 2: Auth logic β QA β Tests β β
βββ Phase 3: Session management β QA β Tests β β
βββ Result: Working code. Documented decisions. Resumable progress.
|
|
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER: "Add user authentication with JWT" β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PHASE 0: Check for .swarm/plan.md β
β Exists? Resume. New? Continue. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PHASE 1: Clarify (if needed) β
β "Do you need refresh tokens? What's the session duration?" β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PHASE 2: Discover β
β @explorer scans codebase β structure, languages, patterns β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PHASE 3: Consult SMEs (serial, cached) β
β @sme_security β auth best practices β
β @sme_api β JWT patterns, refresh flow β
β Guidance saved to .swarm/context.md β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PHASE 4: Plan β
β Creates .swarm/plan.md with phases, tasks, acceptance criteriaβ
β β
β Phase 1: Foundation [3 tasks] β
β Phase 2: Core Auth [4 tasks] β
β Phase 3: Session Management [3 tasks] β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PHASE 5: Execute (per task) β
β β
β βββββββββββ ββββββββββββ βββββββββββ ββββββββββββ β
β β @coder β β β@security β β β@auditor β β β @test β β
β β 1 task β β review β β verify β β generate β β
β βββββββββββ ββββββββββββ βββββββββββ ββββββββββββ β
β β β β
β βββββ If rejected: retry with feedback βββββββββ β
β β
β Update plan.md: [x] Task complete β
β Next task... β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PHASE 6: Phase Complete β
β Re-scan with @explorer β
β Update context.md with learnings β
β Archive to .swarm/history/ β
β "Phase 1 complete. Ready for Phase 2?" β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Other frameworks lose everything when the session ends. Swarm doesn't.
.swarm/
βββ plan.md # Your project roadmap
βββ context.md # Everything a new Architect needs
βββ history/
βββ phase-1.md # What was done, what was learned
βββ phase-2.md
# Project: Auth System
Current Phase: 2
## Phase 1: Foundation [COMPLETE]
- [x] Task 1.1: Create user model [SMALL]
- [x] Task 1.2: Add password hashing [SMALL]
- [x] Task 1.3: Database migrations [MEDIUM]
## Phase 2: Core Auth [IN PROGRESS]
- [x] Task 2.1: Login endpoint [MEDIUM]
- [ ] Task 2.2: JWT generation [MEDIUM] (depends: 2.1) β CURRENT
- Acceptance: Returns valid JWT with user claims
- Attempt 1: REJECTED - Missing expiration
- [ ] Task 2.3: Token validation middleware [MEDIUM]
- [BLOCKED] Task 2.4: Refresh tokens
- Reason: Waiting for decision on rotation strategy# Project Context: Auth System
## Technical Decisions
- Using bcrypt (cost 12) for password hashing
- JWT expires in 15 minutes, refresh in 7 days
- Storing refresh tokens in Redis
## SME Guidance Cache
### Security (Phase 1)
- Never log tokens or passwords
- Use constant-time comparison for tokens
- Implement rate limiting on login
### API (Phase 1)
- Return 401 for invalid credentials (not 404)
- Include token expiry in response body
## Patterns Established
- Error handling: Custom ApiError class with status codes
- Validation: Zod schemas in /validators/Start a new session tomorrow? The Architect reads these files and picks up exactly where you left off.
Most frameworks use one model for everything. Same blindspots everywhere.
Swarm lets you mix models strategically:
{
"agents": {
"architect": { "model": "anthropic/claude-sonnet-4-5" },
"explorer": { "model": "google/gemini-2.0-flash" },
"coder": { "model": "anthropic/claude-sonnet-4-5" },
"_sme": { "model": "google/gemini-2.0-flash" },
"security_reviewer": { "model": "openai/gpt-4o" },
"auditor": { "model": "google/gemini-2.0-flash" }
}
}| Role | Optimized For | Why Different Models? |
|---|---|---|
| Architect | Deep reasoning | Needs to plan complex work |
| Explorer | Fast scanning | Speed over depth |
| Coder | Implementation | Best coding model you have |
| SMEs | Domain knowledge | Fast recall, not deep reasoning |
| Security Reviewer | Finding flaws | Different vendor catches different bugs |
| Auditor | Verification | Independent perspective |
If Claude writes code and GPT reviews it, GPT catches Claude's blindspots. This is why real teams have code review.
Run different model configurations simultaneously. Perfect for:
- Cloud vs Local: Premium cloud models for critical work, local models for quick tasks
- Fast vs Quality: Quick iterations with fast models, careful work with expensive ones
- Cost Tiers: Cheap models for exploration, premium for implementation
{
"swarms": {
"cloud": {
"name": "Cloud",
"agents": {
"architect": { "model": "anthropic/claude-sonnet-4-5" },
"coder": { "model": "anthropic/claude-sonnet-4-5" },
"_sme": { "model": "google/gemini-2.0-flash" },
"_qa": { "model": "openai/gpt-4o" }
}
},
"local": {
"name": "Local",
"agents": {
"architect": { "model": "ollama/qwen2.5:32b" },
"coder": { "model": "ollama/qwen2.5:32b" },
"_sme": { "model": "ollama/qwen2.5:14b" },
"_qa": { "model": "ollama/qwen2.5:14b" }
}
}
}
}| Swarm | Agents |
|---|---|
cloud (default) |
architect, explorer, coder, sme_*, etc. |
local |
local_architect, local_explorer, local_coder, local_sme_*, etc. |
The first swarm (or one named "default") creates unprefixed agents. Additional swarms prefix all agent names.
In OpenCode, you'll see multiple architects to choose from:
architect- Cloud swarm (default)local_architect- Local swarm
Each architect automatically delegates to its own swarm's agents.
# Add to opencode.json
{
"plugin": ["opencode-swarm"]
}
# Or install via CLI
bunx opencode-swarm install| Agent | Role |
|---|---|
architect |
Central coordinator. Plans phases, delegates tasks, manages QA, maintains project memory. |
| Agent | Role |
|---|---|
explorer |
Fast codebase scanner. Identifies structure, languages, frameworks, key files. |
| Agent | Domain |
|---|---|
sme_web |
Flutter, React, Vue, Angular, JS/TS, HTML/CSS |
sme_api |
REST, GraphQL, OAuth, JWT, webhooks |
sme_database |
SQL Server, PostgreSQL, MySQL, MongoDB, Redis |
sme_devops |
Docker, Kubernetes, CI/CD, Terraform |
sme_security |
STIG, hardening, CVE, encryption, PKI |
sme_python |
Python ecosystem, libraries, patterns |
sme_powershell |
PowerShell scripting, modules, remoting |
sme_windows |
Windows internals, registry, services, WMI |
sme_linux |
Linux, systemd, package management |
sme_network |
TCP/IP, firewalls, DNS, TLS |
sme_azure |
Azure services, Entra ID, ARM/Bicep |
sme_vmware |
vSphere, ESXi, PowerCLI |
sme_oracle |
Oracle Database, SQL/PLSQL |
sme_active_directory |
AD, LDAP, Group Policy, Kerberos |
sme_ui_ux |
UI/UX design, accessibility |
| Agent | Role |
|---|---|
coder |
Implements ONE task at a time with full context |
test_engineer |
Generates tests for each completed task |
| Agent | Role |
|---|---|
security_reviewer |
Vulnerability assessment per task |
auditor |
Correctness verification per task |
Create ~/.config/opencode/opencode-swarm.json:
{
"agents": {
"architect": { "model": "anthropic/claude-sonnet-4-5" },
"explorer": { "model": "google/gemini-2.0-flash" },
"coder": { "model": "anthropic/claude-sonnet-4-5" },
"_sme": { "model": "google/gemini-2.0-flash" },
"_qa": { "model": "google/gemini-2.0-flash" },
"test_engineer": { "model": "google/gemini-2.0-flash" }
}
}_smeβ All 15 SME agents_qaβ security_reviewer + auditor
Override specific agents:
{
"_sme": { "model": "google/gemini-2.0-flash" },
"sme_security": { "model": "anthropic/claude-sonnet-4-5" }
}{
"sme_vmware": { "disabled": true },
"sme_oracle": { "disabled": true }
}| Feature | OpenCode Swarm | AutoGen | CrewAI | LangGraph |
|---|---|---|---|---|
| Execution | Serial (predictable) | Parallel (chaotic) | Parallel | Configurable |
| Planning | Phased with acceptance criteria | Ad-hoc | Role-based | Graph-based |
| Memory | Persistent .swarm/ files |
Session only | Session only | Checkpoints |
| QA | Per-task (security + audit) | Optional | Optional | Manual |
| Model mixing | Per-agent configuration | Limited | Limited | Manual |
| Resume projects | β Native | β | β | Partial |
| SME domains | 15 specialized | Generic | Generic | Generic |
| Task granularity | One at a time | Batched | Batched | Varies |
- Plan before code - Documented phases with acceptance criteria
- One task at a time - Focused work, quality output
- QA everything immediately - Security + audit per task, not per project
- Cache SME knowledge - Don't re-ask answered questions
- Persistent memory -
.swarm/files survive sessions - Serial execution - Predictable, debuggable, no race conditions
- Heterogeneous models - Different perspectives catch different bugs
- User checkpoints - Confirm before proceeding to next phase
- Failure tracking - Document rejections, escalate after 3 attempts
- Resumable by design - Any Architect can pick up any project
MIT
Stop hoping your agents figure it out. Start shipping code that works.