Skip to content

seanGSISG/opencode-swarm

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Version License OpenCode Plugin Agents

🐝 OpenCode Swarm

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


The Problem with Every Other Multi-Agent System

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.

Why Swarm?

❌ Other Frameworks

  • Parallel chaos, hope it converges
  • Single model = correlated failures
  • No planning, just vibes
  • Context lost between sessions
  • QA as afterthought (if at all)
  • Entire codebase in one prompt
  • No way to resume projects

βœ… OpenCode Swarm

  • Serial execution - predictable, traceable
  • Heterogeneous models - different perspectives catch errors
  • Phased planning - documented tasks with acceptance criteria
  • Persistent memory - .swarm/ files survive sessions
  • QA per task - security + audit before anything ships
  • One task at a time - focused, quality code
  • Resumable projects - pick up exactly where you left off

How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  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?"                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Persistent Project Memory

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

plan.md - Living Roadmap

# 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

context.md - Institutional Knowledge

# 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.


Heterogeneous Models = Better Code

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.


Multiple Swarms

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

Configuration

{
  "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" }
      }
    }
  }
}

What Gets Created

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.

Usage

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.


Installation

# Add to opencode.json
{
  "plugin": ["opencode-swarm"]
}

# Or install via CLI
bunx opencode-swarm install

Agents

🎯 Orchestrator

Agent Role
architect Central coordinator. Plans phases, delegates tasks, manages QA, maintains project memory.

πŸ” Discovery

Agent Role
explorer Fast codebase scanner. Identifies structure, languages, frameworks, key files.

🧠 Domain Experts (15 SMEs)

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

πŸ’» Implementation

Agent Role
coder Implements ONE task at a time with full context
test_engineer Generates tests for each completed task

βœ… Quality Assurance

Agent Role
security_reviewer Vulnerability assessment per task
auditor Correctness verification per task

Configuration

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" }
  }
}

Category Defaults

  • _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" }
}

Disable Unused Domains

{
  "sme_vmware": { "disabled": true },
  "sme_oracle": { "disabled": true }
}

Comparison

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

Design Principles

  1. Plan before code - Documented phases with acceptance criteria
  2. One task at a time - Focused work, quality output
  3. QA everything immediately - Security + audit per task, not per project
  4. Cache SME knowledge - Don't re-ask answered questions
  5. Persistent memory - .swarm/ files survive sessions
  6. Serial execution - Predictable, debuggable, no race conditions
  7. Heterogeneous models - Different perspectives catch different bugs
  8. User checkpoints - Confirm before proceeding to next phase
  9. Failure tracking - Document rejections, escalate after 3 attempts
  10. Resumable by design - Any Architect can pick up any project

Documentation


License

MIT


Stop hoping your agents figure it out. Start shipping code that works.

About

Architect-centric agentic swarm plugin for OpenCode. Hub-and-spoke orchestration with SME consultation, code generation, and QA review.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 100.0%