opencode-swarm

ZaxbyHubMIT活跃维护

给 OpenCode 用的多智能体编排插件,以架构师为中心做中心辐射式调度,把专家咨询、代码生成和 QA 审查串成一条开发流水线。

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

v7.203.1发布于 2026-11-09 19:49 UTC522star +5 / 7 天59fork同步于 2026-11-10 11:58 UTC

怎么上手

由 README 提炼,执行前请确认
bunx opencode-swarm install
硬件要求按 README 说明

README 未说明

支持 Apple Silicon
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

给 OpenCode 加一个架构师主导的多智能体团队,用门禁流程确保 AI 写的代码真的能跑

给 OpenCode 用的多智能体编排插件,以架构师为中心做中心辐射式调度,把专家咨询、代码生成和 QA 审查串成一条开发流水线。

核心能力

  • 架构师统筹规划,coder、reviewer、test_engineer 等角色分工执行
  • 代码必须通过 reviewer 与 test engineer 双重门禁才能交付
  • 独立只读会话做整 diff 自动审查,产出锚定 diff 的结构化问题
  • Epic 模式按波次并行,各 coder 在隔离 worktree 中改代码
  • 会话状态存入 .swarm/,可随时中断续跑

容易踩的坑

需要 Bun >= 1.3.13,用 npm 安装则需 Node.js >= 22.13;OpenCode 会无限期缓存插件,升级要用 bunx opencode-swarm update 或重新 install 后重启;安装器会禁用原生 explore 和 general agent,且不会自动创建项目级配置

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v7.203.1
  1. v7.203.1最新正式版2026-11-09 · 2026-11-09 19:49 UTC

    Shell write-gate walk fixpoint

    What

    Six shell write-gate fixes, collated from #3586 + #3588 + #3591 (the residuals of the #3491 → #3590 hardening series). One defect class: the gate's static shell model admitted whenever its bounded walk stopped before the shell semantics did.

    1. Loops whose directory state alternates no longer admit iteration-2 writes (#3586). cd src; for i in 1 2; do echo x > f; cd ..; done was admitted with the write judged at iteration 1's directory, while real bash writes f at the workspace root on iteration 2. When one full loop iteration's landing differs from the loop's ENTRY state, every write the loop collected — while/until clause writes included — is withdrawn fail-closed. The comparison basis is the PRE-clause entry state, so a cd living in the re-executing clause drifts too: cd src/sub; i=0; while cd ..; [ "$i" -lt 2 ]; do i=$((i+1)); echo x > f; done (real bash writes src/f and then the escaping workspace-root f) now denies. Net-zero loop bodies (no net cd) keep admitting. The only exemption is a for whose word list is a single fully-literal word (no glob, brace, tilde, ! or expansion) in a command with no dynamic-execution builtin anywhere in the analyzed AST as seen after wrapper preprocessing (trap, alias, set, shopt, …; segment-leading eval/exec/builtin/source are unwrapped by preprocessing before this census and so do not contribute — the wrapper-collapse residual below covers what that omission means): that loop runs exactly once, so cd src; for i in x; do echo x > f; cd ..; done still admits.
    2. Two-level launcher chains surface their inner write targets (#3588). nice sudo time -o src/ok.txt true lost the inner time -o target; the detector now follows launcher-headed tails to any depth (bounded).
    3. Nested command-less sudo denies (#3588). sudo sudo -i, sudo FOO=bar sudo -i, nice sudo -i and nice sudo -z true were admitted; the launcher-uncertainty channel now re-walks nested launcher tails.
    4. Non-plain payload words under sudo -i/-s deny (#3588). Any tail word carrying whitespace, a shell operator, a quote, $, or brace/comma structure now denies; plain multiword tails (sudo -i make build) keep admitting. One shape was a verified bypass: sudo 1.9.15p5 leaves $ unescaped when it re-joins the words for the login shell's -c, so sudo -s 'touch$IFS/tmp/x' creates the file. The rest (sudo -i 'echo x > ../esc', ${IFS}, {a,b}) reach the shell as one literal word on that sudo version, so those denials are conservative: other sudo builds, including sudo-rs, have not been checked.
    5. sudo -D DIR -e FILE denies relative edit targets (#3588). cd src; sudo -D /etc -e shadow was admitted. sudo 1.9.15p5 opens edit targets against the invoking directory, and -D only moves the editor's working directory, so #3588's premise that the target lands under DIR is wrong on that version. Other sudo builds are unverified, so relative targets under -D now deny as unresolved. Absolute targets are judged as written.
    6. Plain, quoted-flag, and late-flag rm are scope-checked (#3591). Policy decision (AC10): scope containment, modeled on unlink/rmdir — every operand of a non-recursive, non-forced rm (flagless, or -i/-v) is now judged against the declared scope, so rm ../esc denies and rm src/temp.ts keeps admitting. GNU option permutation is honored — flags AFTER operands (rm foo -rf ../../outside) AND quote-spelled flags (rm "-rf" ../../outside, rm '-f' x) are classified by the same shared parse (bash strips the quotes), so quoted recursive/forced shapes hit the same guards as their unquoted twins: the protected-.git/.swarm arm, the filesystem-root guard, the traversal guard, and the build/cache allowli
  2. v7.203.02026-11-08 · 2026-11-08 22:04 UTC
    查看更新说明

    swarm-pr-feedback drives a PR to merge; new session-retrospective skill

    swarm-pr-feedback used to stop once known feedback was closed. Driving CI, merging, and reviewing the session each needed a separate instruction every session. Run on a PR, the skill now carries the PR through to the end.

    Drive to merge (new references/drive-to-merge.md)

    • Intake. The run takes this session's own review findings and every PR comment with findings, and runs the existing Stage A → Stage B → closeout gates.

    • Dispositions. It plans every unfixed item's disposition before the closeout gate. It publishes them after the push is verified, or after a verified no-change outcome, and publishes any disposition added later before it checks the merge preconditions.

    • CI to green, within a budget:

      • one rerun per infrastructure signature;
      • failures proven on the base branch become PRE_EXISTING dispositions, not PR fixes;
      • at most 2 fix attempts per signature and 5 fix cycles per run, counting CI-driven and review-driven rounds alike.

      Under Profile A each fix is a new controller generation.

    • Merge:

      • Authorization. Only the user's own words asking for the merge in the current run authorize it, or a yes to the run's own "merge now?" question; a question, negation, hypothetical, or quoted mention of merging never does. A skill invocation, [MODE: PR_FEEDBACK] signal, default prompt, monitor wake, or loop activation never authorizes a merge. An injected event or PR-monitor wake also neither answers that question nor ends the wait for it.
      • Merge command. It uses --match-head-commit on the gated head. Inside the run every gh pr, gh run, and gh repo call and every GraphQL query is bound to the PR's resolved owner and repository (--repo <owner>/<repo>); swarm-ci-monitor's merge commands carry --repo too. It passes no strategy flag on a merge-queue base, and passes the repository's single allowed method on a direct base (or asks when several are allowed).
      • Monitoring. It monitors the merge queue until the merge commit is on the base. Any merge precondition that cannot become true, an unanswered question, or a monitoring ceiling ends the run with a report and the close-out steps; stopping monitoring never dequeues the PR. The final report says whether a PR monitor is still subscribed and, if the PR did not merge, asks whether to unsubscribe it.
    • Close out, merged or not:

      1. re-verify every disposition on its live artifact;
      2. run a session retrospective;
      3. run the memory closeout.

      "Fixes only" skips CI and the merge; "don't merge" skips only the merge. Runs started by a PR-monitor wake keep their triage scope.

    Follow-up dispositions

    • references/followup-dispositions.md now states two rules explicitly:
      • anything the PR introduced is fixed in the PR;
      • a verified, consequential defect is never closed on the agent's own judgment.
    • In practice FILE means Priority items or user-approved Improvements.
    • Every ASK item, follow-up proposal, Improvement, and enhancement idea goes through its own critic call before it reaches the user, and the critic's verdict travels with the question. The closeout critic gate does not count as that call.
    • Priority FILE items also get a critic call before filing. A kill or downgrade makes one an ASK. If the critic is unavailable, the item is still filed, marked "not critic-reviewed" in the issue body and the ledger, and listed in the final report.
    • A reviewer's severity label (nit, non-blocking) never replaces verification.

    New session-retrospective skill

    • An evidence-based retrospective of the whole session, reconstructed from the harness's own history:
      • Claude Code transcript JSONL;
      • ZCode ~/.zcode/cli/db/db.sqlite, read-only;
      • Codex rollout JSONL;
      • OpenCode session store.
    • It reports:
      • what worked and what failed;
      • tool and skill friction;
      • prioritized improvement
  3. v7.202.32026-11-07 · 2026-11-07 23:42 UTC
    查看更新说明

    File-authority denial messages now bounded and home-redacted

    What changed

    Every WRITE BLOCKED: Agent "…" is not authorised to write "…" denial thrown by the shell write gate and the file-write path now renders the target through one shared bounded-and-redacted helper (sanitizeDiagnosticText(redactPath(target), 320) with the escaping-relative home fold below), replacing raw interpolation at all four throw sites (universal deny prefix, lenient verifier-config, enforced authority, and the non-shell file_write door — agent names are bounded there too).

    The shared redactPath now classifies profile shapes lexically on a normalized slash form, on every host: normalization-created home paths (/tmp/../home/<name>/…, /home//<name>/…) fold, exact profile roots (/home/<name>, /Users/<name>, C:\Users\<name>) fold, and Windows-drive and UNC profile forms fold in either separator flavor even on POSIX hosts (C:/Users/<name>/…, //server/Users/<name>/…). A folded Windows path renders ~\rest (the old ~\\rest double separator is gone); non-profile paths render exactly as before.

    The file-authority denial reason keeps its workspace-relative display: an ESCAPING relative path (normalized form starting ../, provably outside the workspace) folds its home/<name> / Users/<name> segment to ~, and every other display routes through redactPath. The denial message's target slot makes the same escaping decision on the normalized form (./../home/<name>/…, src/../../home/<name>/…, and win32 ..\Users\<name>\… all fold), so for operand-shaped targets — the non-shell file_write door — the message and reason agree. The three SHELL doors render the RESOLVED absolute target: its leading runtime profile folds, but an interior caller-supplied home/<name> segment beyond it stays visible in the message while the reason folds it (folding interior segments of resolved paths would over-redact legitimate in-workspace denial targets). Ordinary in-workspace relative paths and non-home absolutes render structurally unchanged — through redactPath's host-normalized form, as before (over-redaction is pinned against).

    Known bounds: when the workspace sits under one profile and the target under a SIBLING profile, the relative display's common-ancestor prefix already dropped the Users segment, so the sibling account name remains in the reason (the message's target slot is still folded); the escaping fold is case-sensitive (Users but not users); a drive-relative win32 spelling (C:..\Users\<name>\…, no separator after the drive) is not recognized as escaping, so the message renders it raw while the reason folds it; and the lstat-failed / symlink-junction ancestor denial arms still render the raw ancestor path (pre-existing, tracked for a follow-up).

    Diagnostic-only change: ShellWriteBlockedError.writeTarget stays exact; audit rows keep their redacted-and-truncated contract and pick up the same profile folds (ordinary paths persist unchanged); message shape is unchanged, so downstream message-parsing and the pinned denial suites are unaffected.

    Why

    Follow-up from PR #3568's final critic (#3587): a long attacker-influenced target (400+ chars) flowed unbounded and un-redacted into denial messages — including absolute user-profile paths (C:\Users\<name>\…) rendered verbatim. The PR #3567 round had fixed exactly one of the five denial-throw sites; this closes the remaining four plus the reason channel.

    Issue: #3587


    Fail the observability append closed at the safe-integer generation ceiling

    What

    The no-bump observability append (appendObservabilityStateWhileLocked) now refuses to write when the durable observabilityRevision generation sits at Number.MAX_SAFE_INTEGER: the append branch throws BLOCKED: PR workflow gate observability generation is exhausted at the safe-integer ceiling; the durable row requires a manual generation reset instead of computing

  4. v7.202.22026-11-07 · 2026-11-07 20:09 UTC
    查看更新说明

    Neutralize control characters in swarm-residue inventory names (#3542)

    What changed

    formatResidueInventoryLines in src/services/swarm-residue.ts now strips C0/C1 (Unicode Cc) control bytes from entry names before the existing backtick neutralization, matching the safeName shape that src/commands/doctor-store-integrity.ts shipped in PR #3533. The residue inventory sections of the /swarm config doctor read-only report and the close dry-run report render through this one shared renderer. A new pinning test, tests/unit/services/swarm-residue-control-char-names.test.ts, covers \n row-injection, ESC terminal-pollution, DEL, NEL, a control byte inside a directory component of a multi-segment path, VT (U+000B), and CSI (U+009F) names, pins the exact rendered output for a crafted name (and the verbatim name span for an ordinary name), and asserts the directory component survives rendering (no over-stripping).

    Why

    relPath values come from readdir of attacker-influenced trees. The old renderer only replaced backticks, so a crafted entry name containing \n could inject forged inventory rows into the report, and an ESC byte could pollute terminal rendering. Quarantine actions were never affected by this renderer defect (the quarantine move path is untouched by this change); the defect class was bounded to report-line injection and terminal pollution. PR #3533 fixed the identical class in the doctor store-integrity report — this closes the surviving copy in the residue inventory renderer.

    Migration steps

    None. The change is internal to report formatting; no config, state, or data migration is involved. The residue-inventory sections of the doctor report and the close dry-run report no longer carry raw control bytes in entry names.

    Known caveats

    • Control bytes are stripped, not escaped: a name a\nb renders as ab. This matches the shipped doctor-store-integrity behavior and is the intended minimal fix.
    • The Cc strip also covers C1 control bytes (U+0080–U+009F), consistent with the PR #3533 precedent.
    • Coverage bound: this fix covers the shared residue-inventory renderer only. Three sibling render surfaces still emit the same relPath values raw (no control-byte strip, and two of them no backtick neutralization either): the --quarantine-residue preserved list (src/commands/doctor.ts), the close clean-stage preserved-candidates warning (persisted verbatim into .swarm/close-summary.md), and the close dry-run archive/post-mortem name lists. Those sites predate this PR and are tracked for a follow-up.

    PR-workflow observability appends: fail-open lock escape and same-revision stale overwrite

    What

    Two integrity fixes to the PR-workflow gate's observability-only append path (rejection journals, skill-contract advisories, and the PR_FEEDBACK base-mismatch marker), closing #3232 and the remaining scope of #3231.

    • Advisory append honours its fail-open contract under lock contention (#3232). appendPrWorkflowSkillContractAdvisories documents that any error drops the append silently, but its protective try sat inside the session-state lock callback, so a lock-acquisition timeout (another process holding the lock for the full retry budget) escaped as a rejected promise. Its only caller is the auto-resume wake path, which then aborted before sending the resume prompt. The lock acquisition now sits inside the fail-open boundary, matching the three sibling observability writers; the wake continues and the resume prompt is sent.
    • A stale observability append can no longer erase an interleaved one (#3231). Observability appends deliberately never advance the gate state revision (#3199), so two appenders holding snapshots at the same revision were indistinguishable to the write CAS: the second, built from a snapshot that predates the first, replaced the whole row and silently erased the first app
  5. v7.202.12026-11-07 · 2026-11-07 16:01 UTC
    查看更新说明

    Shell Write Gate: Directory State, Child-Scoped Chdir Wrappers, sh -c Payload (G1)

    What changed

    • Directory-state model for the write gate (src/hooks/shell-write-detect.ts): the resolver walk now threads one DirectoryState ({cwd, prevCwd, dirStack}) through both passes instead of a bare cwd stack. cd word forms resolve-or- withdraw: bare cd / cd ~ / cd ~/x land at $HOME (withdrawn when the line reassigns HOME=), cd - lands at the modeled prevCwd (withdrawn when unmodeled or OLDPWD= is reassigned), and dynamic operands (cd $VAR) withdraw later writes — the historical literal-append could fail OPEN under a broad declared scope. pushd/popd are tracked (push, bare swap, pop; ±N/-n/stack-overflow withdraw), and cd -P src / cd -- src now track the real operand. Conditionals carry both outcomes explicitly: pipelines run components on isolated state copies with post-pipeline withdrawal, if/case branch copies diverge over the COMPLETE state (cwd + prevCwd + dirStack + withdrawal flag — #3567 feedback PRR-001) and withdraw, loops accept only a full-state fixpoint, and function bodies walk a discarded copy that inherits (never zeroes) the context withdrawal. Withdrawn writes reach the gate as resolvedPath: null with an additive unresolved marker; a withdrawn capability eval denies before any evalDirectory fallback (#3491 AC1/AC3, #3539 AC1/AC5).

    • Child-scoped env/sudo chdir through a quoted subshell transform (src/hooks/guardrails/destructive-command.ts, tool-before.ts, guardrail-explain-service.ts): chdir-bearing wrapper segments (env -C DIR, env -S '…-C DIR…', sudo -D DIR) rewrite at the gate as correctly-quoted subshells ( cd -- 'DIR' && <re-unwrapped inner> ), so the wrapped command's writes resolve under the CHILD cwd while following siblings stay at the parent cwd (bash-true). DIR is emitted through a POSIX single-quote serializer (' → '\''); expansion-bearing operands ($VAR, ~, $(…), globs) are never serialized — the segment rewrites to a withdrawal form whose inner writes withdraw. Nested chdir wrappers compose as nested subshells. The destructive arm receives an evolving per-segment directory context (inner cds tracked; unrepresentable mutations relocate to a deny-on-uncertainty sentinel), and /swarm guardrail explain shares the same preprocessing (#3491 AC2/AC4).

    • Shared sh -c payload extractor (src/hooks/guardrails/destructive-command.ts): the payload is the single quote-removed word the -c flag selects (sh's argv[2] contract: the next standalone word after the flag cluster), extracted by a quote-aware tokenizer shared with the W2 serializer. Trailing positionals (sh -c 'payload' sh) and same-kind quote concatenation ('\'') no longer defeat the unwrap, and words after the payload ($0/$1…) are never scanned as commands (#3491 AC5/AC7).

    • Review round 1 hardening (destructive-command.ts, tool-before.ts, guardrail-explain-service.ts): the uncertain-DIR withdrawal form uses a synthetic dynamic cd operand, so it withdraws UNCONDITIONALLY — the first round's synthetic cd - landed at a modeled OLDPWD after a preceding cd/pushd and admitted the wrapped writes. The destructive arm's child-cwd context is keyed per OCCURRENCE instead of per segment text (first-wins text keying let env -C src rm -rf dist; env -C .. rm -rf dist inherit the first occurrence's in-scope context). /swarm guardrail explain mirrors the gate's null-path decision tree — withdrawn/dynamic write targets answer block, and inspectable evals route through their tracked working directory exactly like the gate.

    • sh-family flag-cluster payloads (src/hooks/shell-write-detect.ts, src/hooks/guardrails/destructive-command.ts; final-critic rounds 2–5): the covered grammar is bash-true, complete over four dim

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    OpenCode Swarm

    Your AI writes the code. Swarm proves it works.

    Closing the trust gap between "the model said it's done" and "this actually works in production."

    npm version License: MIT Tests

    Website · Getting Started · Configuration · Architecture


    OpenCode Swarm is a plugin for OpenCode that turns a single AI coding session into an architect-led team of specialized core, optional, and conditional agents. Run /swarm agents for the live roster; it is generated from the current plugin configuration. One agent writes the code. A different agent reviews it. Another writes and runs tests. Another checks security. Nothing ships until every required gate passes.

    bunx opencode-swarm install
    

    This single command installs the package, registers it as an OpenCode plugin, disables conflicting default agents, and creates a ready-to-edit config at ~/.config/opencode/opencode-swarm.json. Requires Bun >= 1.3.13 (bun --version to check), or Node.js >= 22.13 for npm installs (the Node-hosted sidecar uses the built-in node:sqlite). If you must use npm: npm install -g opencode-swarm && opencode-swarm install.

    First-run note: the installer registers the plugin, writes the global plugin config, creates a project override when missing, and disables the native explore and general agents in opencode.json. If you are not using a Swarm architect, the Swarm gates, reviewers, and test agents are bypassed. Open the OpenCode agent or mode picker and choose the Swarm architect when needed.

    Why Swarm?

    Most AI coding tools let one model write code and ask that same model whether the code is good. That misses too much. Swarm separates planning, implementation, review, testing, and documentation into specialized internal roles — and enforces gated execution so agents never mutate the codebase in parallel unless their scopes are proven disjoint (v8 parallel lanes, Epic waves), and then each in its own isolated worktree.

    Key Features

    SurfaceEntry point
    swarm-implement.yml gated GitHub Actionswarm:implement issue label or workflow_dispatch — runs the implementation pipeline and opens an evidence PR
    • 🏗️ Specialized core, optional, and conditional agents — architect, coder, reviewer, test_engineer, critic, critic_finding_validator, explorer, sme, docs, designer, critic_oversight, critic_sounding_board, critic_drift_verifier, critic_hallucination_verifier, curator_init, curator_phase, council_generalist, council_skeptic, council_domain_expert. Run /swarm agents for the live roster — that is the source of truth, not this list.
    • 🔒 Gated pipeline — code never ships without reviewer + test engineer approval
    • 🔎 Independent auto-review engine — bounded whole-diff review in a fresh read-only model session, structured diff-anchored findings, optional independent validation, advisory-by-default phase review, and an evidence-backed opt-in completion gate. v7 remains opt-in; v8's default is pinned to a committed 30-diff cost burn-in.
    • 🔍 DEEP_DIVE Protocol — High-rigor, on-demand read-only codebase audit via specialized skills
    • 🔬 External Skill Curation Pipeline — Opt-in discovery, quarantine, evaluation, and promotion of external skill candidates from configured sources (disabled by default; enable via external_skills.curation_enabled: true in config). Includes 7 tools: external_skill_discover, external_skill_list, external_skill_inspect, external_skill_promote, external_skill_reject, external_skill_delete, external_skill_revoke. Candidates pass through a 3-gate validation pipeline before evaluation: prompt injection scan (12 regex patterns), unsafe instruction scan (25 patterns), and provenance integrity check (SHA-256, timestamp, URL, publisher, and hash verification).
    • 🎯 Governed Skill Optimizer — Manually-activated, single-skill optimizer (/swarm skill-opt plan|run|status|diff|approve|reject|rollback|history) that drives one allowlisted SKILL.md candidate at a time through deterministic draft → smoke → evaluation-substrate validation → manual approval → atomic activation/rollback. Bounded, restartable, reversible, and unable to mutate source/harness/security surfaces. Disabled by default (skill_opt.enabled: false); see docs/skill-optimizer.md.
    • 🌊 Epic Mode (opt-in preview) — one plan = one epic, run phase by phase as parallel waves of tasks whose declared scopes don't conflict. The delegation gate enforces the active wave; in git projects each coder works in an isolated worktree on an epic branch that /swarm epic close squash-lands as staged changes. Per-task QA always runs, and a phase reviewer + critic gate (epic_phase_review) runs before phase_complete. Epic learns per-file write risk across epics, suggests plan restructurings with a predicted speedup, and reports a scorecard (/swarm epic report). Enable with epic.mode.enabled: true; see docs/modes.md.
    • 🔄 Phase completion gates — completion-verify and drift verifier gates enforced before phase completion
    • 🔁 Resumable sessions — all state saved to .swarm/; pick up any project any day
    • 🔀 GitLab as a first-class forge (#2733) — MR and issue URLs (https://<gitlab-host>/owner/repo/-/merge_requests/N, /-/issues/N) are accepted by /swarm pr-review, pr-feedback, pr subscribe/unsubscribe, ci-monitor, publication recording, and issue ingestion, with self-hosted instance hosts derived from the remote or forge.base_url (config forge: { provider, base_url }, default auto; ambiguous remotes fail closed). Every URL-security control (HTTPS-only, private/localhost rejection, IDN protection, credential stripping) applies identically to GitLab. The glab binary resolves through the same hardened resolver contract as gh (OPENCODE_SWARM_GLAB_BINARY env override). Honest capability reporting: GitLab does not synthesize GitHub's statusCheckRollup/reviewDecision/mergeStateStatus — those surface an explicit unavailable result instead of a fabricated value, and glab-backed live MR polling is tracked as follow-up issue #2882.
    • 🖥️ PR Monitor — GitHub PR subscription and background polling via gh CLI; delivers real-time CI, review, and merge status updates via the AutomationEventBus (FR-001, opt-in via pr_monitor.enabled: true). Subscribe with /swarm pr subscribe <pr-url|owner/repo#N|N>; unsubscribe with /swarm pr unsubscribe <pr-url|owner/repo#N|N>; check status with /swarm pr status. With auto_pr_feedback: true, CI failures and merge conflicts mechanically activate PR_FEEDBACK only when no other workflow owns the session; otherwise they are durably queued for a later round.
    • 🌐 13 full language profiles (TypeScript, JavaScript, Python, Go, Rust, Java, Kotlin, C/C++, C#, Ruby, Swift, Dart, PHP) with tree-sitter parse validation across 20 grammars (adds CSS, Bash, PowerShell, INI, Regex — and .tsx / .c aliases) — extending: see docs/adding-a-language.md
    • 🛡️ Built-in security — SAST, secrets scanning, dependency audit per task
    • 🔒 Scope enforcement — Validates write targets against declared scope with cross-process persistence, TTL expiry, and scope-aware destructive command blocking. Handles both single-string and array-based path arguments (files[], paths[], targetFiles[]) to prevent scope bypass via multi-file tool calls.
    • 📝 Shell write detection — Static analysis of POSIX/PowerShell/cmd commands to detect file writes (redirects, builtins, in-place editors, network downloads, archive extraction, git destructive ops) before execution
    • 🆓 Free tier — works with OpenCode Zen's free model roster
    • ⚙️ Fully configurable — override any agent's model, disable agents, tune guardrails

    The Swarm architect coordinates all internal agents automatically. You never manually switch between internal roles. If the active OpenCode agent is not a Swarm architect, the plugin workflow is bypassed.


    Shell Write Detection

    Swarm includes comprehensive static analysis for shell commands to detect and intercept file write operations before execution.

    Shell Write Detection Features

    • POSIX shell detection — Parses commands with bash-parser AST for accurate detection of:

      • Redirect operators (>, >>, >|, <<, <<-)
      • Here-documents and here-strings
      • Write-effect builtins (cp, mv, install, ln, truncate, dd)
      • In-place editors (sed -i, perl -i, awk -i)
      • Interpreter eval (python -c, node -e, bun -e, ruby -e, php -r)
      • Network downloaders (curl -o, wget -O, scp)
      • Archive extraction (tar -x, unzip, gunzip)
      • Git destructive operations (git clean -fd, git reset --hard)
    • Windows shell detection — Uses regex heuristics for PowerShell and cmd.exe:

      • PowerShell cmdlets: Out-File, Set-Content, Add-Content, Copy-Item, Move-Item
      • cmd.exe builtins: copy, move, ren, del, rd, md
      • Redirect operators (>, >>)
    • Interactive session denial — Blocks commands that create persistent or open-ended sessions:

      • POSIX: watch, screen, tmux new-session
      • PowerShell: Start-Process
    • Cross-process scope enforcement — Declared scope is persisted to .swarm/scopes/scope-{taskId}.json with:

      • TTL expiry (default 24 hours)
      • Symlink guards (O_NOFOLLOW + realpath containment)
      • Schema versioning and fail-closed validation
      • Scope-aware destructive command blocking — Recursive delete patterns (rm -rf, rmdir /s, del /s, Remove-Item -Recurse, rsync --delete) are blocked unless ALL target paths are within the declared scope (coder agents only)

    Security Patterns

    The guardrails system blocks destructive shell commands targeting:

    • System paths (/root, /etc, C:\Windows, etc.)
    • Symlink/junction creation with external targets
    • File operations under .swarm/ directory
    • Fork bombs and infinite loops
    • Disk wiping and ransomware-grade operations

    What Actually Happens

    You say:

    Build me a JWT auth system.
    

    Swarm then:

    1. Clarifies only what it cannot infer.
    2. Scans the codebase to understand what already exists.
    3. Consults domain experts when needed and caches the guidance.
    4. Writes a phased implementation plan.
    5. Sends that plan through a critic gate before coding starts.
    6. Executes tasks through the QA pipeline — one at a time, or concurrently in isolated worktrees for plans with provably file-disjoint task groups (v8 default for new plans, #1674; serial is the automatic fallback when scopes overlap or are unknown):
    • coder writes code

    • automated checks run

    • reviewer checks correctness

    • test engineer writes and runs tests

    • architect runs regression sweep

    • failures loop back with structured feedback

      With Epic Mode on, epic_next_wave issues each phase as waves of conflict-free tasks (the same per-task pipeline runs inside every wave), and epic_phase_review runs a reviewer + critic over the whole phase before phase_complete.

    1. After each phase, docs and retrospectives are updated.

    All project state lives in .swarm/ — plans, evidence, context, knowledge, and telemetry. Resumable by design. If .swarm/ already exists, the architect goes straight into RESUME → EXECUTE instead of repeating discovery.


    Execution Modes

    Swarm has two independent mode systems:

    Session modes — toggle per session with a slash command:

    ModeSafetySpeedWhen to Use
    Balanced (default)HighMediumEveryday development
    TurboMediumFastRapid iteration; skips phase_complete Gates 1–5 (Stage A and Stage B still run for every task)
    Lean TurboHighFastParallel lanes for non-conflicting tasks (up to max_parallel_coders coders)
    Full-AutoDeterministic policy + critic oversightFastUnattended multi-interaction runs
    Epic (opt-in)High — per-task QA always runs; Turbo stays offFast on plans with many independent tasksLarge plans: one plan = one epic, run phase by phase as parallel waves of tasks with disjoint scopes

    Auto-proceed — a session toggle (/swarm auto-proceed [on|off]) that skips the "Ready for Phase N+1?" prompt at phase boundaries. Defaults to false; set as a plan default via execution_profile.auto_proceed during QA GATE SELECTION. Session override always wins. Independent of Full-Auto.

    Full-Auto reduces approval friction by deterministically allowing safe operations (read-only tools, in-scope writes, safe shell) and routing every ambiguous or high-risk action (writes to plugin/build/guardrail paths, network, dependency changes, plan/phase mutations, subagent delegation) through the read-only critic_oversight agent before it executes. Denials are returned to the agent as structured signals so it can choose a safer path; repeated denials pause the run; phase completion requires an APPROVED oversight record. See docs/modes.md for mode, permission_policy, denials, and oversight config keys, fail-closed semantics, and recovery from a paused run.

    Epic binds to the current plan and runs fully on OpenCode 1.x and OpenCode 2 (7.x plugin). On OpenCode 2 the v2 adapter ships a session-capable client, places coder worktree sessions with an eager parented create that is then moved into the worktree (#3169 Phase 3; #3558), and — since #3169 Phase 4 — dispatches human-typed /swarm commands natively, so the full flow (/swarm epic start → waves → phase review → close) is available there; the remaining live-host verification legs are tracked on #3169, and the dual-host CI lane has landed (merge-queue v2 smoke cell, weekly host-contract v2 digest, and a vendored-pin freshness notice). The epic itself is always opened by the user (human-only policy — the agent cannot start one on any host). /swarm epic start also refuses plans too small to benefit and suggests Balanced. The epic_next_wave tool then dispatches each phase as waves of tasks whose declared scopes don't conflict; in a git project each coder works in an isolated worktree on an epic branch, and /swarm epic close squash-lands the work as staged changes for you to review. Every task in a wave still runs the full per-task QA pipeline (Stage A and Stage B). Epic learns which files tasks tend to write together and uses it to plan later waves and epics. See docs/modes.md; maintainers start with src/epic/README.md.

    Project mode — persistent via execution_mode config key:

    ValueEffect
    strictMaximum safety — adds slop-detector and incremental-verify hooks
    balanced (default)Standard hooks
    fastSkips compaction service — for short sessions under context pressure

    Switch session modes with /swarm turbo [on|off], /swarm full-auto [on|off], or /swarm epic start|close (Epic needs "epic": {"mode": {"enabled": true}} in config). Control phase-boundary auto-proceed with /swarm auto-proceed [on|off]. Set project mode in config. Lean Turbo is configured in turbo.lean.* in config and composes with all session modes. See docs/modes.md.


    Quick Start

    → For a complete first-run walkthrough, see Getting Started.

    The 15-minute guide covers:

    • Installation (bunx opencode-swarm install)
    • First-run auto-configuration (architect selected automatically)
    • Running your first task
    • Troubleshooting common issues

    The installer automatically:

    • Adds opencode-swarm to the OpenCode plugin list
    • Disables the native explore and general agents to reduce routing conflicts

    It does not create a project config. .opencode/opencode-swarm.json is opt-in — create it yourself only if you want project-level overrides of the global config.


    30-Second Demo

    No animated GIF is shipped in the repo — instead, here is the exact terminal session you can record yourself with asciinema rec demo.cast (or any screen recorder). Every command below is real and runs against this repo as published.

    Recording script (copy/paste-able, ~30 seconds):

    # 1. Install the plugin (5s)
    bunx opencode-swarm install
    
    # 2. Open opencode and select a Swarm architect if it is not already active
    opencode
    
    # 3. Inside the OpenCode session, verify Swarm is live (5s)
    /swarm help
    /swarm agents
    
    # 4. Kick off a task — the architect plans, then gates fire automatically (15s)
    Build me a JWT auth helper with tests.
    
    # 5. Watch the gates land in real time (5s)
    /swarm status
    /swarm evidence
    

    ASCII storyboard of what a viewer should see:

    ┌──────────────────────────────────────────────────────────────┐
    │ $ bunx opencode-swarm install                                │
    │ ✓ installed opencode-swarm                                   │
    │                                                              │
    │ $ opencode                                                   │
    │ [Swarm] Welcome! Architect auto-selected. Type /swarm help  │
    │                                                              │
    │ > /swarm help                                                │
    │ Available commands: status, plan, agents, help, diagnose... │
    │                                                              │
    │ > Build me a JWT auth helper with tests.                     │
    │ [architect]  PLAN → critic gate → APPROVED                   │
    │ [coder]      task 1.1 implementing…                          │
    │ [reviewer]   correctness OK                                  │
    │ [test_eng.]  3 tests written, 3 pass                         │
    │ [architect]  regression sweep clean → phase_complete         │
    │                                                              │
    │ > /swarm evidence                                            │
    │ task 1.1: review ✓  tests ✓  sast ✓  secrets ✓  drift ✓      │
    └──────────────────────────────────────────────────────────────┘
    

    Each row corresponds to a real gate documented further down this README — none are simulated.


    Upgrading

    OpenCode caches plugins indefinitely. A normal OpenCode restart does not pull newer versions from npm — once a plugin is cached, OpenCode keeps using that exact copy on every subsequent launch (issue #675). The cache lives in several places depending on your platform and OpenCode version:

    • Current OpenCode cache layout: ~/.cache/opencode/node_modules/opencode-swarm/
    • Legacy Linux / devcontainers / GitHub Codespaces: ~/.config/opencode/node_modules/opencode-swarm/
    • Package cache layout: ~/.cache/opencode/packages/opencode-swarm@latest/
    • Older bare package cache layout: ~/.cache/opencode/packages/opencode-swarm/
    • Platform-specific macOS / Windows cache roots: ~/Library/Caches/opencode/..., %LOCALAPPDATA%\opencode\..., or %APPDATA%\opencode\...

    The updater also clears known OpenCode lock files (bun.lock, bun.lockb, and package-lock.json) so the next start resolves the latest package.

    To upgrade to the latest published version (clears all known layouts automatically):

    bunx opencode-swarm update     # cache-only refresh, then restart opencode
    # or
    bunx opencode-swarm install    # full reinstall (re-asserts config), then restart opencode
    

    /swarm diagnose shows the running version and, when available, the latest version on npm so you can tell at a glance whether your cache is stale.

    To disable the background staleness check entirely, set version_check: false in your opencode-swarm.json.


    Commands

    Common subcommands at a glance:

    /swarm help [command]      # List all commands or get detailed help for a specific command
    /swarm status              # Current phase and task
    /swarm show-plan [N]       # Full plan or filtered by phase
    /swarm agents              # Registered agents and models
    /swarm diagnose            # Health check
    /swarm evidence [task]     # Test and review results
    /swarm epic status         # Open epic, current wave, landing state (Epic Mode)
    /swarm reset --confirm     # Clear swarm state
    

    Use /swarm help to see all available commands categorized by function. Use /swarm help <command> for detailed usage information on a specific command.

    Nine commands display a ⚠️ warning in help output because they share names with Claude Code built-in slash commands (e.g., /plan, /reset, /status). The warning reminds you to always use /swarm <command> — the bare CC command does something different and sometimes destructive. See docs/commands.md#claude-code-command-conflicts for the full conflict registry.

    See docs/commands.md for the full reference. The live source of truth is src/commands/registry.ts, which includes canonical commands, compound commands, and deprecated aliases.

    Command Aliases

    Some commands are available under deprecated names for backwards compatibility. Using the canonical name is recommended:

    Alias (deprecated)Canonical command
    /swarm config-doctor/swarm config doctor
    /swarm diagnosis/swarm diagnose
    /swarm evidence-summary/swarm evidence summary
    /swarm doctor/swarm config doctor
    /swarm info/swarm status
    /swarm list-agents/swarm agents
    /swarm health/swarm diagnose
    /swarm plan/swarm show-plan
    /swarm close/swarm finalize
    /swarm check/swarm preflight
    /swarm clear/swarm reset-session

    Aliases are hidden from help output but still function. The canonical command should be used in scripts and documentation.


    The Agents

    Swarm registers a roster of specialized core, optional, and conditional agents. The exact count shifts as agents are added or feature-flagged, so treat /swarm agents as the live source of truth — that command lists what is actually registered in your session. You don't manually switch between them — the architect coordinates automatically.

    AgentRoleBadge
    architectOrchestrates workflow, writes plans, enforces gatesCore
    explorerScans codebase, gathers context, maps factsCore
    coderImplements one task at a time (or concurrently in isolated worktrees for provably file-disjoint task groups — v8, #1674)Core
    reviewerChecks correctness and security (also reviews a whole phase under Epic Mode via epic_phase_review)Core
    test_engineerWrites and runs tests, adversarial testingCore
    criticReviews plans before implementation begins (also challenges a whole phase under Epic Mode via epic_phase_review)Core
    critic_finding_validatorIndependently confirms, disproves, or leaves reviewer findings unverifiedCore
    critic_oversightSole quality gate in full-auto autonomous modeCore
    smeProvides domain expertise guidanceCore
    docsUpdates documentation to match implementationCore
    designerGenerates UI scaffolds and design tokensConditional
    critic_sounding_boardPre-escalation pushback to the architectOptional
    critic_drift_verifierVerifies implementation matches specOptional
    critic_hallucination_verifierVerifies APIs and citations against real sourcesOptional
    curator_initConsolidates prior knowledge at session startOptional
    curator_phaseConsolidates phase outcomes, detects workflow driftOptional
    council_generalistBroad analytical voice in the General Council (uses reviewer model)Conditional
    council_skepticAdversarial stress-tester voice in the General Council (uses critic model)Conditional
    council_domain_expertTechnical-depth voice in the General Council (uses SME model)Conditional

    Legend: Core = always available, Optional = available by default (can be disabled), Conditional = requires specific feature config (ui_review or council)

    Run /swarm status and /swarm agents to see what's active.

    graph TB
        subgraph Orchestration
            A[Architect]
        end
    
        subgraph Discovery
            E[Explorer]
        end
    
        subgraph Execution
            C[Coder]
            T[Test Engineer]
            D[Designer]
        end
    
        subgraph Quality
            R[Reviewer]
            CR[Critic]
            CO[Critic Oversight]
            CSB[Critic Sounding Board]
            CDV[Critic Drift Verifier]
            CHV[Critic Hallucination Verifier]
        end
    
        subgraph Support
            S[SME]
            DOC[Docs]
            CI[Curator Init]
            CP[Curator Phase]
        end
    
        subgraph Council
            CM[Council Member]
            CMO[Council Moderator]
        end
    
        A -->|Discover| E
        E -->|Context| A
        A -->|Consult| S
        S -->|Guidance| A
        A -->|Design| D
        D -->|Scaffold| C
        A -->|Implement| C
        C -->|Review| R
        R -->|Verify| A
        C -->|Test| T
        T -->|Results| A
        A -->|Deliberate| CM
        CM -->|Verdict| A
    

    How It Compares

    Both projects compared here have since been renamed: oh-my-opencode is now OmO and get-shit-done is now GSD Core. The table reflects them as they were when it was written (April 2026, v6.81.0) and has not been re-checked against their current releases.

    FeatureSwarmoh-my-opencode (now OmO)get-shit-done (now GSD Core)
    Multiple specialized agents✅ Core + optional + conditional roster (/swarm agents)❌❌
    Plan reviewed before coding✅❌❌
    Every task reviewed + tested✅❌❌
    Different model for review vs. code✅❌❌
    Shell write detection (POSIX/PowerShell/cmd)✅❌❌
    Scope enforcement with cross-process persistence✅❌❌
    Interactive session detection and blocking✅❌❌
    Resumable sessions✅❌❌
    Built-in security scanning✅❌❌
    Learns from mistakes✅❌❌
    Parallel tasks refused at dispatch unless their scopes are conflict-free (Epic Mode)✅❌⚠️ overlap check only falls back to sequential
    Conflict prediction from git co-change history (Epic Mode)✅❌❌
    Learns per-file risk of undeclared writes across runs (Epic Mode)✅❌❌
    Plan-restructuring suggestions with predicted speedup (Epic Mode)✅❌❌
    Per-epic scorecard: conflicts, rework, gate first-pass rates (Epic Mode)✅❌❌

    LLM Provider Guide

    Swarm works with any provider supported by OpenCode.

    Free Tier (OpenCode Zen)

    No API key required. Excellent starting point:

    {
      "agents": {
        "coder": { "model": "opencode/nemotron-3-ultra-free" },
        "reviewer": { "model": "opencode/big-pickle" },
        "explorer": { "model": "opencode/big-pickle" }
      }
    }
    

    Paid Providers

    For production, mix providers by role:

    AgentRecommendedWhy
    architectOpenCode UI selectionNeeds strongest reasoning
    coderminimax-coding-plan/MiniMax-M2.5Fast, accurate code generation
    reviewerzai-coding-plan/glm-5Different training from coder
    test_engineerminimax-coding-plan/MiniMax-M2.5Same strengths as coder
    explorergoogle/gemini-2.5-flashFast read-heavy analysis
    smekimi-for-coding/k2p5Strong domain expertise

    Provider Formats

    ProviderFormatExample
    OpenCode Zenopencode/<model>opencode/big-pickle
    Anthropicanthropic/<model>anthropic/claude-sonnet-4-20250514
    Googlegoogle/<model>google/gemini-2.5-flash
    Z.aizai-coding-plan/<model>zai-coding-plan/glm-5
    MiniMaxminimax-coding-plan/<model>minimax-coding-plan/MiniMax-M2.5
    Kimikimi-for-coding/<model>kimi-for-coding/k2p5

    Model Fallback

    Automatic fallback to a secondary model on transient errors (including provider quota exhaustion — e.g. GitHub Copilot's 429 quota exceeded monthly limit):

    {
      "agents": {
        "coder": {
          "model": "anthropic/claude-sonnet-4-20250514",
          "fallback_models": ["opencode/mimo-v2.6-flash-free"]
        }
      }
    }
    

    Fallback applies to dispatched subagents and to primary (interactive) sessions alike. For a primary session, a fallback-eligible provider failure on one turn switches the session's next message to the configured fallback (sticky for the session; announced by a MODEL FALLBACK: advisory and a model_fallback telemetry event). Recovery boundaries: session end (or a new session), 30 minutes without any message on the session, or a change to the configured model chain (the stale selection then reads as absent and the primary is retried). Switching the session's agent away from the fallback-scoped role suppresses the override while the other agent is active, but the prior role's selection persists until the idle window expires — switching back re-applies it. There is deliberately no in-session code escape (the host's model-selection surface cannot distinguish a user re-pick from the session selection). A one-shot opencode run turn that already failed cannot be re-driven mid-turn — the OpenCode host owns the request loop — so interactive (TUI/GUI) sessions pick up the fallback on their next message, while a failed one-shot invocation simply ends; re-run it after resolving the quota.

    See docs/configuration.md for full configuration reference.


    Process Remediation Model (PRM)

    Swarm monitors agent trajectories and injects course-correction guidance before loops form. Detects five failure patterns:

    1. Repetition Loop — Same agent performs the same action repeatedly
    2. Ping-Pong — Agents hand off back and forth without progress
    3. Expansion Drift — Plan scope grows beyond original task
    4. Stuck-on-Test — Coder and tests fail in a loop
    5. Context Thrashing — Agent requests increasingly large file sets

    When detected, escalation levels trigger:

    • Level 1: Advisory guidance injected
    • Level 2: Architect alert sent
    • Level 3: Hard stop directive

    Configure via:

    {
      "prm": {
        "enabled": true,
        "pattern_thresholds": {
          "repetition_loop": 2,
          "ping_pong": 2,
          "expansion_drift": 3,
          "stuck_on_test": 3,
          "context_thrash": 10
        }
      }
    }
    

    Note: Both max_trajectory_lines and escalation_enabled are enforced at runtime. max_trajectory_lines is the one knob bounding the session trajectory store — the cold-session read, the append-path compaction, and denied-call recording all use it; escalation_enabled gates the escalation ladder (advisory → hard stop). Terminal/cooldown semantics live in docs/configuration.md (Hard-stop episode state machine).

    Persistent Memory

    .swarm/plan-ledger.jsonl — authoritative source of truth (v6.44 durability model)

    .swarm/context.md — technical decisions and cached SME guidance

    .swarm/evidence/ — review/test results per task

    .swarm/telemetry.jsonl — session observability events (fire-and-forget, never blocks execution)

    .swarm/curator-summary.json — phase-level intelligence and drift reports

    .swarm/epic/ — Epic Mode: the open epic, its waves, and close reports with scorecards

    .swarm/epic-prior/ — Epic Mode: the learned project prior and past epic reports (survives /swarm close)

    Guardrails & Circuit Breakers

    Every agent runs inside a circuit breaker that prevents runaway behavior:

    SignalDefault Limit
    Tool calls200
    Duration30 min
    Same tool repeated10x
    Consecutive errors5

    Limits reset per task. Per-agent overrides available in config.

    Note: Built-in per-agent profiles override the global max_consecutive_errors to 8 for architect, coder, test_engineer, explorer, and reviewer (src/config/schema.ts DEFAULT_AGENT_PROFILES). The 5 shown above is the GuardrailsConfigSchema global default that applies only when no per-agent profile sets the value. See docs/installation.md § Guardrails Configuration for the full schema and docs/configuration.md § Per-agent override fields for how to override.

    File Authority (Per-Agent Write Permissions)

    Each agent can only write to specific paths:

    • architect — Everything (except .swarm/plan.md, .swarm/plan.json)
    • coder — src/, tests/, docs/, scripts/
    • reviewer — .swarm/evidence/
    • test_engineer — tests/, .swarm/evidence/
    • explorer, sme — Read-only

    Override via authority.rules in config.

    Quality Gates

    Built-in tools verify every task before it ships:

    • syntax_check — Tree-sitter validation across the configured language grammar map
    • placeholder_scan — Catches TODOs, stubs, incomplete code
    • sast_scan — 68 security rules across 8 languages (offline)
    • sbom_generate — Dependency tracking (CycloneDX)
    • quality_budget — Complexity, duplication, test ratio limits
    • epic_phase_review — Epic Mode only: an APPROVED phase reviewer, then an APPROVED phase critic, before phase_complete

    These quality gates run locally. No Docker is required. Config-gated features such as General Council web search can make external API calls only when you enable them and provide a Tavily or Brave Search key.

    Context Budget Guard

    The Context Budget Guard monitors how full the model's context window is getting across the whole conversation. It helps prevent context overflow before it becomes a problem.

    Default Behavior

    • Enabled automatically — No setup required. Swarm starts tracking context usage right away.
    • What it measures — The total tokens across all messages in the conversation (every text part of every message — your prompts, the model's responses, and injected content alike), divided by the model's context window. It does not measure only swarm-injected content, and it does not read max_injection_tokens. Token counts come from one canonical estimator, estimateTokens in src/hooks/utils.ts (flat ~0.33 tokens/char), unless provider-reported usage is available for the turn, which stays authoritative.
    • Where the window comes from — Your live model, not a constant. Resolution order: an explicit context_budget.model_limits entry ("<provider>/<model>", then "<model>", then "default") → the context window the OpenCode host reports for the model you are running (model.limit.context, already provider-specific, so a Copilot entry and a first-party entry for the same model resolve differently) → a static fallback table → 128000 as a last resort when nothing else is known. Set a model_limits entry only if you want a smaller working budget than your model's real window.
    • Warning threshold (0.7 ratio) — When total conversation tokens reach 70% of the model context window (e.g. ~89,600 on a 128k model, ~700,000 on a 1M model), the architect receives an advisory warning recommending a summary offload to .swarm/context.md. This is informational by itself — execution continues normally.
    • Critical threshold (0.9 ratio) — When total conversation tokens reach 90% of the model context window (e.g. ~115,200 on a 128k model, ~900,000 on a 1M model), the architect receives a critical alert recommending /swarm handoff — and, when enforce is true (the default), the guard also prunes the outgoing request (see the next bullet).
    • Hard enforcement (default on) — With enforce: true (default), crossing the critical threshold masks eligible completed tool outputs (those older than recent_window turns OR longer than tool_output_mask_threshold characters, in turns not protected by preserve_last_n_turns) and prunes lower-priority messages toward prune_target of the window (best-effort: pruning stops at the target or when no eligible removable message remains, whichever comes first). All of this happens in the outgoing request only — the current turn's message array as sent to the provider. Your persisted history is never rewritten: stored conversation, .swarm/ artifacts, and tool results on disk are untouched. External data — provider-reported usage and the live model limit — is read, never written.
    • Warnings repeat while above threshold — The warning text is prepended to the current user message on every turn above the threshold; there is no once-per-session suppression. Pruning and masking likewise re-apply each turn while usage stays above the critical threshold.
    • Who sees warnings — Only the architect receives these warnings. Other agents are unaware of the budget.

    To disable entirely, set context_budget.enabled: false in your swarm config.

    On-demand status check: architects can invoke the context_status tool at any time to read current context-window headroom (tokens used, model limit, usage percent, threshold state, model ID, provider) without triggering advisory warnings or mutating state. Works even when context_budget.enabled is false.


    Skill Propagation

    Swarm includes an intelligent skill propagation system that tracks, validates, and scores skill usage across agent delegations. When the architect delegates to subagents (coder, reviewer, test_engineer, etc.), the system:

    • Logs skill usage to .swarm/skill-usage.jsonl with session-scoped entries (agent, task ID, skill paths, timestamp)
    • Scores skill relevance based on frequency, compliance, recency, task ID diversity, and context matching
    • Provides recommendations — when delegating without a SKILLS: field, the system suggests relevant skills with relevance scores
    • Enforces compliance — optional enforcement mode can block delegations missing the SKILLS: field
    • Auto-populates skill index — maintains a ## Available Skills section in .swarm/context.md with usage counts and compliance rates
    • Supports explicit routing — .opencode/skill-routing.yaml maps agent types to specific skill paths with optional keyword descriptions

    Guardrails:

    • Relevance scoring threshold: 0.5 (skills below this are not recommended)
    • Maximum recommendations per delegation: 5
    • Scoring budget safeguard: Skipped when session exceeds 500 skill-usage entries to prevent unbounded file reads
    • Graceful degradation: Zero installed skills = zero friction — no warnings, no blocks, no auto-population

    Configuration:

    {
      "skillPropagation": {
        "enabled": true,
        "enforce": false,
        "audiences": []
      }
    }
    
    • enabled (boolean, default true) — turns skill-propagation scoring, recommendations, and warnings on or off. The mandatory explicit-skill-reference integrity check still runs even when this is false.
    • enforce (boolean, default false) — when true, blocks delegations that omit the SKILLS: field instead of only warning.
    • audiences (string array, default [], max 16 entries, de-duplicated) — extra audience tokens to broaden which skills are considered in scope for this project, in addition to the active runner's own audience. Each entry must be a lowercase domain token matching ^[a-z0-9]+(?:[._-][a-z0-9]+)*$; the reserved value swarm-plugin and any runner:* prefix are rejected.

    Skill routing file format (.opencode/skill-routing.yaml):

    version: 1
    routing:
      coder:
        - path: .claude/skills/writing-tests/SKILL.md
          keywords: ["test", "testing", "writing tests"]
        - path: .claude/skills/engineering-conventions/SKILL.md
          keywords: ["engineering", "conventions", "invariants"]
      reviewer:
        - path: .claude/skills/swarm-pr-review/SKILL.md
          keywords: ["review", "security", "audit"]
    

    Routing skills are merged with scored recommendations, with explicitly routed skills receiving a boosted score (0.9) to prioritize them.

    Skill Lifecycle Management

    Seven skill-management tools (skill_generate, skill_list, skill_apply, skill_inspect, skill_regenerate, skill_retire, skill_improve) are opt-in via the skills.enabled config flag (default false). With the flag off, the tools are host-denied for every agent except the skill_improver specialist (issue #2528): the model never receives their schema, so they are genuinely unreachable — not merely unlisted. With the flag on, the architect regains all seven. Tools remain exported and registered.

    Swarm provides tools for managing generated skill lifecycles:

    • skill_retire — Retires an active generated skill by creating a retired.marker file in its directory. Retired skills are excluded from discovery, scoring, and injection. The SKILL.md file is preserved for auditability. Use skill_retire(slug, reason?) to retire a skill, or pass a reason for tracking purposes.

    • skill_regenerate — Re-clusters the source knowledge entries for an active skill and updates the SKILL.md in place. Reads the existing SKILL.md frontmatter to identify source knowledge IDs, resolves current entries from knowledge stores, and re-renders the skill content. Falls back to fuzzy slug-based re-clustering if source IDs yield no matches. Skills whose source knowledge is entirely archived are automatically retired during regeneration.

    • Auto-retire health check — During each curator phase run, skills are automatically evaluated for retirement when:

      • The skill's violation rate exceeds 30% (based on skill-usage.jsonl compliance verdicts)
      • All of the skill's source knowledge entries have been archived

      Auto-retired skills are noted in the phase digest summary. The check is non-blocking — errors are caught and logged without failing the curator.

    • Proposal cleanup — When a draft skill proposal is activated via skill_apply, the source proposal file is deleted as part of the activation process (best-effort; permission errors are logged but do not block activation).

    Governed Skill Optimizer

    /swarm skill-opt (issue #1822 — SkillOpt 3/7) is a manually-activated, governed optimizer that drives ONE allowlisted SKILL.md candidate at a time through deterministic draft → static smoke → evaluation-substrate validation (split:'test') → manual approval → atomic activation (or rollback). The loop is bounded, restartable, reversible, and unable to mutate harness/source/security surfaces.

    Commands: /swarm skill-opt plan|run|status|diff|approve|reject|rollback|history.

    • Disabled by default. /swarm skill-opt run requires skill_opt.enabled: true AND --confirm. plan/status/diff/history are always available (read-only / proposal-only).
    • No autonomous mutation. approve/activate/reject/rollback are human-only and require --expected-content-hash to refuse a stale base.
    • Validation reuse. Uses the existing evaluation substrate (evaluateCandidateV1) — no duplicate runner/scorer. Held-out test sets are single-use (claimHeldOutTest), so a single run performs at most one validation.
    • Durable lifecycle. Append-only state machine under .swarm/evolution/skills/<slug>/<candidateId>/ with hash-chain integrity and corrupt-tail quarantine.

    See docs/skill-optimizer.md for the full architecture and the skill_opt config block.

    Governed Harness Optimizer

    /swarm harness-opt (issue #2503 — the HarnessOpt capstone) is the executing, governed optimizer over the declarative harness_evolution surface: it drives ONE governed round at a time through the evaluation substrate in a disposable worktree (the substrate fingerprints the active checkout before and after every execution), freezes the comparative task set before any round, and records durable lineage with task-cost accounting (missing host data stays unknown, never zero).

    Commands: /swarm harness-opt plan|run|compare|status|stop|history.

    • Disabled by default. run requires harness_opt.enabled: true AND --confirm; run/stop are human-only.
    • Isolation. Rounds execute in disposable worktrees; the substrate fingerprints the active checkout around every execution, so the running checkout is never mutated. A test split consumes the held-out set exactly once (substrate-enforced).
    • Comparative protocol. Baseline, ablation, and simple-agent control arms run on the same frozen task population with per-arm denominators, retained negative results, and a stream-snapshot duplicate guard.
    • Independent oracle. Acceptance backstop that rejects a token-improving candidate whose artifact quality or verification evidence falls.
    • No self-modification. Activation/rollback stay on /swarm approve-write + the harness store, which additionally re-validates recorded approved paths against the CURRENT allowlist.

    See docs/harness-optimizer.md for the full architecture and the harness_opt config block.

    External Skill Curation

    Swarm provides an opt-in, quarantine-first pipeline for discovering, validating, and promoting external skills. Disabled by default — no network calls are made until explicitly enabled.

    Enabling
    external_skills:
      curation_enabled: true
      sources:
        - type: url
          location: https://example.com/skills/
          trust_level: medium
    
    Validation Pipeline

    Every candidate passes a 3-gate pipeline before entering quarantine:

    GateNameDescription
    1Prompt Injection Scan12 regex patterns plus oversized field, invisible character, and suspicious formatting checks detect system instruction injection, role hijacking, and instruction override attempts
    2Unsafe Instruction Scan25 patterns detect shell commands, file system attacks, network exfiltration, and privilege escalation
    3Provenance IntegritySHA-256 content hash, timestamp validation, URL format checks, and publisher presence validation

    Trust level modulation: low trust promotes warning-severity findings to errors (stricter); medium and high trust levels keep warnings advisory. Error-severity findings always block regardless of trust level.

    Tool Reference
    ToolDescription
    external_skill_discoverFetch and validate a skill from a configured source
    external_skill_listList candidates with status filters
    external_skill_inspectView full candidate details
    external_skill_promotePromote validated candidate to active skill (user approval required)
    external_skill_rejectReject candidate with reason
    external_skill_deleteRemove candidate from quarantine store
    external_skill_revokeRetire a previously promoted skill
    Security Guarantees
    • Disabled by default — no network calls until explicitly enabled
    • All candidates quarantined until human review and promotion
    • TOCTOU re-validation at promotion time
    • Content hash verification prevents tampering
    • Bounded concurrent fetches (5 simultaneous) and discovery limits (50 candidates per invocation)
    • Max candidate size and count bounds
    • Source origin validation (URLs must match configured sources)
    Limitations
    • Static regex patterns only (no LLM-based detection)
    • No cryptographic signing (deferred)
    • No batch import (deferred)
    • No auto-promotion (human approval always required)

    Configuration Reference

    KeyTypeDefaultDescription
    context_budget.enabledbooleantrueEnable or disable the context budget guard entirely
    context_budget.max_injection_tokensnumber4000Separate per-turn cap on system-enhancer injection. It is NOT the guard's budget — the guard measures total conversation tokens against model_limits, not this value
    context_budget.warn_thresholdnumber0.7Ratio (0.0-1.0) of the model context window at which total conversation tokens trigger a warning advisory
    context_budget.critical_thresholdnumber0.9Ratio (0.0-1.0) of the model context window at which total conversation tokens trigger a critical alert with handoff recommendation
    context_budget.enforcebooleantrueWhen true (default), crossing the critical threshold masks large completed tool outputs and prunes lower-priority messages in the outgoing request toward prune_target. Execution is never blocked or aborted
    context_budget.prune_targetnumber0.7Ratio (0.0-1.0) of the context window the outgoing request is pruned toward when enforcement runs
    context_budget.preserve_last_n_turnsnumber4Number of recent turns protected from pruning
    context_budget.recent_windownumber10Age (in turns) beyond which a completed tool output becomes eligible for masking during enforcement; the latest preserve_last_n_turns turns are always protected
    context_budget.tracked_agentsstring[]['architect']Agents to track for context budget warnings
    context_budget.enforce_on_agent_switchbooleantrueEnforce budget limits when switching agents
    context_budget.model_limitsrecord{}Per-model token limit overrides, keyed by "<provider>/<model>", "<model>", or "default". Empty by default so the live model's own context window is used; set an entry only to impose a smaller working budget
    context_budget.unified_injection_tokensnumberundefinedOpt-in unified ceiling (tokens) for combined system-enhancer + knowledge-injector injection per turn. When set, both hooks share this budget with proportional split
    context_budget.tool_output_mask_thresholdnumber2000Character threshold (chars, not tokens): during enforcement, a completed tool output in a non-protected turn is masked when it is older than recent_window turns OR longer than this many characters (either condition)
    skills.enabledbooleanfalseGates the 7 skill-management tools (skill_generate, skill_list, skill_apply, skill_inspect, skill_regenerate, skill_retire, skill_improve) behind an opt-in flag. When false (default), these tools are host-denied for every agent except skill_improver — genuinely unreachable at request time (issue #2528).
    skill_opt.enabledbooleanfalseMaster opt-in for the governed skill optimizer (/swarm skill-opt). run also requires --confirm; plan/status/diff/history are always available. See docs/skill-optimizer.md.
    skill_opt.deadbandnumber0Promotion policy deadband forwarded to the evaluation substrate.
    skill_opt.max_roundsnumber5Hard cap on draft/smoke retries before a validation (held-out test set is single-use).
    skill_opt.max_transient_retriesnumber5Max transient-infra retries before an infra failure becomes inconclusive.
    epic.mode.enabledbooleanfalseMaster opt-in for Epic Mode (/swarm epic, epic_next_wave, epic_phase_review). The legacy turbo.epic.* path is still accepted and migrated with a warning. See docs/modes.md
    epic.mode.activation_thresholdnumber0.3Intra-component density above which a conflict component runs one task per wave
    epic.cochange.enabledbooleanfalseAdds the git co-change conflict signal to Epic planning and /swarm coupling (otherwise declared-path conflicts only)
    epic.cochange.threshold / min_co_changesnumber0.6 / 5NPMI floor and minimum co-change count for a file pair to count as coupled
    epic.sizing.*objectmin_tasks: 6, min_scope_coverage: 0.8, min_effective_speedup: 1.25, coder_fraction: 0.6/swarm epic start refuses plans below these (--force overrides and is recorded)
    epic.learning.*objectenabled: true, decay_per_epic: 0.7, half_life_days: 60, hot_excess: 0.25Per-file risk and co-write learning across waves and epics
    epic.commit_policystringepic-branchepic-branch (work on swarm/epic/<key>, landed at close) or current-branch
    epic.retain_refsbooleanfalseKeep refs/swarm/epics/<key>/* after close
    context_budget.scoring.enabledbooleanfalseEnable context scoring/ranking
    context_budget.scoring.max_candidatesnumber100Maximum items to score (10-500)
    context_budget.scoring.weightsobject{ phase: 1.0, current_task: 2.0, blocked_task: 1.5, recent_failure: 2.5, recent_success: 0.5, evidence_presence: 1.0, decision_recency: 1.5, dependency_proximity: 1.0 }Per-signal priority weights (each 0-5). Only these eight keys are read
    context_budget.scoring.decision_decayobject{ mode: 'exponential', half_life_hours: 24 }Decision relevance decay (mode: linear or exponential; half_life_hours 1-168)
    context_budget.scoring.token_ratiosobject{ prose: 0.25, code: 0.4, markdown: 0.3, json: 0.35 }Accepted for backward compatibility only; deprecated and inert at runtime — never read. Token costs always use the canonical flat estimator (estimateTokens, ~0.33 tokens/char), never per-content ratios

    Example Configurations

    Minimal (disable):

    {
      "context_budget": {
        "enabled": false
      }
    }
    

    Default (reference):

    {
      "context_budget": {
        "enabled": true,
        "max_injection_tokens": 4000,
        "warn_threshold": 0.7,
        "critical_threshold": 0.9,
        "enforce": true,
        "prune_target": 0.7,
        "preserve_last_n_turns": 4,
        "recent_window": 10,
        "tracked_agents": ["architect"],
        "enforce_on_agent_switch": true,
        "model_limits": { "default": 128000 },
        "tool_output_mask_threshold": 2000,
        "scoring": {
          "enabled": false,
          "max_candidates": 100,
          "decision_decay": { "mode": "exponential", "half_life_hours": 24 }
        }
      }
    }
    

    (Omitted keys — weights above — take the schema defaults listed in the table; only the eight documented weight keys are read.)

    Aggressive (for long-running sessions):

    {
      "context_budget": {
        "enabled": true,
        "max_injection_tokens": 2000,
        "warn_threshold": 0.5,
        "critical_threshold": 0.75,
        "enforce": true,
        "prune_target": 0.6,
        "preserve_last_n_turns": 2,
        "recent_window": 5,
        "tracked_agents": ["architect"],
        "enforce_on_agent_switch": true,
        "model_limits": { "default": 128000 },
        "tool_output_mask_threshold": 1500,
        "scoring": {
          "enabled": true,
          "max_candidates": 50,
          "weights": { "phase": 1.5, "current_task": 3.0, "recent_failure": 3.0, "recent_success": 0.3, "decision_recency": 2.0 },
          "decision_decay": { "mode": "linear", "half_life_hours": 12 }
        }
      }
    }
    

    Note on scoring.token_ratios: the key is still accepted by the config schema for backward compatibility, but it is deprecated and inert — no runtime code reads it, and per-content token ratios are deliberately not used. Token costs for both normal and scoring accounting always come from the one canonical estimator (estimateTokens in src/hooks/utils.ts, flat ~0.33 tokens/char); when the provider reports token usage, that figure stays authoritative.

    What This Does NOT Do

    • Does NOT block execution — The guard never aborts or stops the pipeline. Enforcement trims the request, not the run.
    • Does NOT modify persisted history — Masking and pruning mutate only the outgoing request for the current turn (the message array sent to the provider). Stored conversation, .swarm/ artifacts, and tool results on disk are untouched.
    • Does NOT rewrite tool results — A masked tool output is a placeholder in the current request; the tool's stored result is unchanged.
    • Does NOT interact with compaction.auto — Separate feature with separate configuration.
    • Does NOT measure only swarm-injected context — It measures the whole conversation against the model's context window, using provider-reported usage when available and the canonical flat estimator (estimateTokens, ~0.33 tokens/char) otherwise.

    Built-in Tools and Hooks

    SurfaceWhat It Does
    syntax_checkTree-sitter validation across the configured language grammar map
    placeholder_scanCatches TODOs, FIXMEs, stubs, placeholder text
    sast_scanOffline security analysis, 68 rules, 8 languages
    sbom_generateCycloneDX dependency tracking, 8 ecosystems
    build_checkRuns your project's native build/typecheck
    incremental_verifyPost-coder hook for TS/JS, Go, Rust, Python, and C#; configured by incremental_verify.*, not invoked as a registered tool
    quality_budgetEnforces complexity, duplication, and test ratio limits
    pre_check_batchRuns lint, secretscan, SAST, and quality budget in parallel (~15s vs ~60s sequential)
    phase_completeProduces a complete bounded read-only gate report, revalidates the exact plan/config/evidence snapshot under lock, and commits the phase only when every applicable gate still passes
    run_phase_reviewArchitect-only: runs the bounded final-review engine and persists complete content-addressed review evidence for phase_complete
    repair_gate_evidenceArchitect-only: rebuilds recoverable task evidence from durable requirements, recovers receipt-backed legacy marker wedges or the exact sentinel-only state emitted by the historical repair flow, requires fresh coder settlement, and refuses every other receipt-less reconstruction without changing state
    repair_knowledge_receipt_ledgerArchitect-only: validates receipt projections or salvages a corrupt authoritative ledger while requiring exact phase/session re-evaluation
    record_directive_overrideArchitect-only: records explicit critical-directive authorization separately from phase completion; unreadable authority cannot be overridden
    mutation_testApplies LLM-generated mutation patches to source files and runs tests to measure kill rate; verdict is pass/warn/fail based on configurable thresholds; used by the mutation_test gate (opt-in, off by default)
    generate_mutantsArchitect-only: generates LLM-based mutation patches (5–10 per function across 6 types: off-by-one, null substitution, operator swap, guard removal, branch swap, side-effect deletion) for direct consumption by the mutation_test tool; returns SKIP verdict on LLM failure rather than throwing
    write_mutation_evidenceArchitect-only: writes mutation gate results atomically to .swarm/evidence/{phase}/mutation-gate.json; accepts verdict (PASS/WARN/FAIL/SKIP), kill rate metrics, and optional survived mutant details; normalizes uppercase-to-lowercase before persisting
    parse_lane_candidatesArchitect-only: parses [CANDIDATE] rows and micro-lane [CLEAN] attestations from a lane output_ref; supports asserted batch families, preserves dispatch provenance, and persists sidecar JSONL records
    write_pr_review_trigger_evalArchitect-only: validates the exact mandatory PR-review micro-lane ID set, requires completed provenance for all 11 repository-agnost