Swarm MCP
Use this skill when the swarm MCP server is available and coordination with other agents is useful.
If swarm tools are not mounted, say so clearly. Normal workers should fall back to local work only when safe. Gateway/lead sessions should restore swarm tools, use a spawner surface, or ask the operator before doing medium/large implementation locally.
Role argument: $role.
If the user invoked this skill with a role argument, follow the matching role reference. If no role was provided, use the generalist flow and load role references only when choosing collaborators or accepting delegated work.
Default Flow
- Call
register, unless a hook already did it.
- Call
bootstrap for {instance, peers, unread_messages, tasks}. Use swarm_status when you need a compact next-action summary with task/lock warnings.
- Handle unread messages before claiming work. If your live interface was woken by a peer prompt, call
bootstrap or poll_messages first; the durable instruction is in swarm messages.
- Use
claim_next_task for the highest-priority compatible task unless you already know a specific task_id for claim_task.
- Edit normally — plugin-supported runtimes (Hermes, Claude Code, Codex) check write tools against peer-held locks. Call
lock_file only when you need a wider critical section (see Locking below).
- Coordinate through
request_task, dispatch (gateway only), send_message, prompt_peer, peek_peer, broadcast, and KV.
- Finish with
complete_task when you can provide structured handoff details; use terminal update_task as a plain-string fallback.
Locking
lock_file is a deliberate tool for declaring a critical section wider than a single write tool call. It is not ordinary per-edit safety; plugin hooks only enforce existing peer-held locks at write time.
Reach for lock_file when:
- You will do a Read → multiple Edits sequence and a stale peer write between them would break your
old_string anchors.
- You are refactoring across several files and want peers to wait.
- You are reserving files (e.g. as a planner) so an assigned implementer can claim them without a race.
Do not call lock_file for an ordinary single Edit/Write. In plugin-supported runtimes, the PreToolUse/equivalent hook checks write tools against existing peer-held locks and denies on real conflict. It does not acquire a lock for you; solo sessions and no-conflict writes proceed normally.
Runtimes without a swarm plugin (e.g. ad-hoc OpenCode sessions) need to call lock_file / unlock_file themselves. Even then, prefer locking critical sections over per-edit ceremony — the per-edit race window is too narrow to be the real failure mode; the actual hazard is stale-read → edit, which only a wider lock protects.
When you do hold a lock, include a note describing the scope and expected duration so peers know what they're waiting on. Release with unlock_file as soon as the critical section ends; terminal update_task releases any remaining edit locks automatically.
If bootstrap returns work_tracker, use only that configured tracker for this repo/scope and identity. Do not pick a tracker just because an MCP happens to be loaded; load references/work-trackers.md when tracker linkage matters.
For planner sessions, the server maintains owner/planner automatically. Check it with kv_get to see whether you currently own planner duties.
Role Routing
planner: load references/planner.md and register with identity:<work|personal> role:planner
implementer: load references/implementer.md and register with identity:<work|personal> role:implementer
reviewer: load references/reviewer.md and register with identity:<work|personal> role:reviewer
researcher: load references/researcher.md and register with identity:<work|personal> role:researcher
generalist or no role: register without a role: token unless the user specified one, then handle mixed work using the core workflow
When the role is unclear, do not invent one. Ask one short question or proceed as a generalist if the task is already actionable.
Core Rules
- Priority: Tasks have an integer
priority field (higher = more urgent). list_tasks returns tasks sorted by priority. Claim the highest-priority open task first.
- Unread-message guard:
claim_task and claim_next_task refuse to claim new open work while you have unread direct messages. Call poll_messages and handle corrections before retrying. Override only when intentionally ignoring those messages.
- Dependencies: Tasks can have a
depends_on field (array of task IDs). A task with unmet dependencies starts as blocked and auto-transitions to open when all deps complete. If a dependency fails, downstream tasks are auto-cancelled.
- Approval gates: Tasks can be set to
approval_required status. They remain gated until approved (transitions to open) or explicitly cancelled. Use this for true approval checkpoints, not routine code review.
- Idempotency: Tasks can have an
idempotency_key field that prevents duplicate creation on retry.
Yield, Wait, Or Idle
Use swarm as an event-driven coordination fabric, not a token-burning poll loop.
- Working: you own a task, review, investigation, edit, lock, dependency, or delegated result to monitor.
- Yield checkpoint: at natural boundaries, call
bootstrap or poll_messages before claiming more work, after update_task, after a peer handoff, and before your final response.
- Monitoring: call
wait_for_activity only while you still own an active coordination obligation, such as a dependency, review, lock release, peer response, or gateway/planner delegation.
- Idle: if you have no active task, no delegated work to monitor, no pending dependency, and no instruction to stay warm, do not call
wait_for_activity in a loop. Finish the turn and remain promptable if the runtime/workspace keeps the session alive.
Use send_message for durable notes to busy peers. Use prompt_peer when a specific peer's live agent interface should be nudged, not only when you want to leave inbox mail; it records the full swarm message first, then best-effort injects a short wake prompt telling the peer to check messages. Use peek_peer when you need a read-only look at a peer's published workspace handle. Do not use force=true unless the update is urgent, corrective, or blocking.
Deregister only when you are actually exiting, ending a one-shot session, or otherwise will not remain available. Plugin-managed sessions usually handle deregistration at runtime finalization.
References
| Topic |
Reference |
Load When |
| Bootstrap and registration fields |
references/bootstrap.md |
You need to decide directory, scope, file_root, or label |
| Planner workflow |
references/planner.md |
The session should plan, delegate, monitor, or recover work |
| Implementer workflow |
references/implementer.md |
The session should claim tasks and edit code |
| Reviewer workflow |
references/reviewer.md |
The session should review completed work or inspect risk |
| Researcher workflow |
references/researcher.md |
The session should investigate and publish findings |
| Gateway workflow |
references/gateway.md |
The session has mode:gateway and needs to dispatch, spawn, place, or monitor workers |
| Work tracker linkage |
references/work-trackers.md |
Work should be linked to Linear, Jira, GitHub Issues, or another configured tracker |
| KV and shared coordination state |
references/coordination.md |
You need to read/write progress/, plan/, owner/, queue, or handoff keys |
| Specialists, generalists, and team conventions |
references/roles-and-teams.md |
You need to route work by role: or team: labels |
| Identity, auth, and design-tool routing |
../../docs/identity-boundaries.md |
You need to route work across personal/work identities, Figma/Linear, or external Codex/OpenCode/Claude design workers |
swarm-mcp CLI reference |
references/cli.md |
You are about to write or invoke a helper script, inspect swarm state from a plain terminal, or control swarm-ui through the CLI |
Do Not
- Assume other sessions share your exact working directory unless
scope and file_root make that true
- Invent role-routing behavior that is not visible from labels, messages, tasks, or instructions
- Hold file locks longer than the critical section they were taken for
- Call
lock_file reflexively before every edit — that's the plugin hook's job in plugin-supported runtimes
- Use
assignee for a stale or unknown instance
- Confuse direct messages with task handoff; use
request_task for structured delegated work
- Try to claim
blocked tasks — they will become open automatically
- Use whatever tracker MCP is available when the configured same-identity tracker is missing or ambiguous
- Shell out to the
swarm-mcp CLI for normal coordination primitives from inside your agent loop — use the MCP tools, including dispatch for gateway task/spawn routing. Use the CLI bridge only from operator scripts, hooks, or gateway sessions where the MCP tools are unavailable.
Collaboration Heuristics
- Prefer
request_task when the work should be tracked and completed
- Prefer explicit
review tasks over passive review scans
- Prefer
send_message for durable targeted notes that do not need task state
- Prefer
prompt_peer when a specific peer should get a live-interface nudge; it records the swarm message first, then best-effort wakes the workspace handle to make the peer check messages
- Prefer
peek_peer when inspecting a peer's recent workspace output is enough and no durable message or nudge is needed
- Prefer
broadcast for short status updates that help everyone
- Prefer
request_task or tracker comments for findings that must survive the current swarm session
- Prefer a matching
role: token when choosing a specialist
- Prefer a matching
team: token when the swarm uses soft teams
- Fall back to any matching specialist, then to a generalist, when the ideal collaborator is unavailable
- Use
wait_for_activity as a blocking monitor while you are responsible for a result, not as idle availability. Peers may wake you with a short prompt to call poll_messages or bootstrap.
- If you are acting as a planner, watch
owner/planner on kv_updates so you can resume from plan/latest after failover
- For long-running concrete tasks, use
report_progress so others can inspect task-local progress without interrupting; include blocked_reason and expected_next_update_at only when useful
- Messages prefixed with
[auto] are system notifications (task assignments, completions, stale-agent recovery) — treat them like any other actionable message
- When you receive a
[signal:complete] broadcast, the planner is signaling all planned work is done. Finish current work, publish final status, then idle or deregister if you are exiting.
- In gateway/lead mode, no live worker is a spawn problem, not a native-subagent fallback. Load
references/gateway.md before dispatching, spawning, setting placement, or using completion_wait_seconds. Worker/generalist sessions do not spawn new workers; they request tracked work, message the planner/gateway, or continue locally when safe.
CLI Fallback
Swarm coordination inside an agent loop should use MCP tools. The dispatch MCP tool is the first-class gateway path: it creates/reuses a task, wakes a live worker when one exists, or spawns through the configured Spawner backend when no worker is live. It is enforced server-side and restricted to gateway authority.
The CLI bridge remains for hooks, operator shells, and rare gateway fallback cases where the MCP tools are not mounted. When you must use it, resolve the command prefix in this order:
- Use the exact
SWARM_MCP_BIN value if set by the launcher.
- Otherwise use
swarm-mcp from PATH.
- If neither works, use herdr directly if available, or ask the operator to start the worker.
Do not ask ordinary worker sessions to run dispatch, ui spawn, or raw workspace-backend pane/node creation. Spawn authority belongs to mode:gateway sessions and operator surfaces; non-gateway MCP callers should expect dispatch to reject them.
For synchronous CLI wrappers, swarm-mcp dispatch --wait-for-completion <seconds> mirrors MCP completion_wait_seconds: it still reports the normal dispatch handoff/spawn status, plus a completion object when the task reaches done, failed, or cancelled, or a timeout snapshot when it does not.
Structured Results Convention
When completing a task, prefer complete_task:
{
"task_id": "<task-id>",
"status": "done",
"summary": "What was done and why.",
"files_changed": ["src/foo.ts"],
"tests": [{ "command": "bun test", "status": "passed" }],
"followups": []
}
Fall back to terminal update_task with a plain string when structured handoff is not useful.
Source: Volpestyle/swarm-mcp — distributed by TomeVault.
1---2name: swarm-mcp3description: Join and coordinate through the swarm MCP server. Use when registering a Claude Code session, coordinating multiple agents, using swarm tasks/messages/KV/locks, or bootstrapping planner, implementer, reviewer, researcher, or generalist roles. Use when this capability is needed.4---56# Swarm MCP78Use this skill when the `swarm` MCP server is available and coordination with other agents is useful.910If swarm tools are not mounted, say so clearly. Normal workers should fall back to local work only when safe. Gateway/lead sessions should restore swarm tools, use a spawner surface, or ask the operator before doing medium/large implementation locally.1112Role argument: `$role`.1314If the user invoked this skill with a role argument, follow the matching role reference. If no role was provided, use the generalist flow and load role references only when choosing collaborators or accepting delegated work.1516## Default Flow17181. Call `register`, unless a hook already did it.192. Call `bootstrap` for `{instance, peers, unread_messages, tasks}`. Use `swarm_status` when you need a compact next-action summary with task/lock warnings.203. Handle unread messages before claiming work. If your live interface was woken by a peer prompt, call `bootstrap` or `poll_messages` first; the durable instruction is in swarm messages.214. Use `claim_next_task` for the highest-priority compatible task unless you already know a specific `task_id` for `claim_task`.225. Edit normally — plugin-supported runtimes (Hermes, Claude Code, Codex) check write tools against peer-held locks. Call `lock_file` only when you need a wider critical section (see Locking below).236. Coordinate through `request_task`, `dispatch` (gateway only), `send_message`, `prompt_peer`, `peek_peer`, `broadcast`, and KV.247. Finish with `complete_task` when you can provide structured handoff details; use terminal `update_task` as a plain-string fallback.2526## Locking2728`lock_file` is a deliberate tool for declaring a critical section wider than a single write tool call. It is not ordinary per-edit safety; plugin hooks only enforce existing peer-held locks at write time.2930**Reach for `lock_file` when:**31- You will do a Read → multiple Edits sequence and a stale peer write between them would break your `old_string` anchors.32- You are refactoring across several files and want peers to wait.33- You are reserving files (e.g. as a planner) so an assigned implementer can claim them without a race.3435**Do not call `lock_file` for an ordinary single Edit/Write.** In plugin-supported runtimes, the `PreToolUse`/equivalent hook checks write tools against existing peer-held locks and denies on real conflict. It does not acquire a lock for you; solo sessions and no-conflict writes proceed normally.3637**Runtimes without a swarm plugin** (e.g. ad-hoc OpenCode sessions) need to call `lock_file` / `unlock_file` themselves. Even then, prefer locking critical sections over per-edit ceremony — the per-edit race window is too narrow to be the real failure mode; the actual hazard is stale-read → edit, which only a wider lock protects.3839When you do hold a lock, include a `note` describing the scope and expected duration so peers know what they're waiting on. Release with `unlock_file` as soon as the critical section ends; terminal `update_task` releases any remaining edit locks automatically.4041If `bootstrap` returns `work_tracker`, use only that configured tracker for this repo/scope and identity. Do not pick a tracker just because an MCP happens to be loaded; load `references/work-trackers.md` when tracker linkage matters.4243For planner sessions, the server maintains `owner/planner` automatically. Check it with `kv_get` to see whether you currently own planner duties.4445## Role Routing4647- `planner`: load `references/planner.md` and register with `identity:<work|personal> role:planner`48- `implementer`: load `references/implementer.md` and register with `identity:<work|personal> role:implementer`49- `reviewer`: load `references/reviewer.md` and register with `identity:<work|personal> role:reviewer`50- `researcher`: load `references/researcher.md` and register with `identity:<work|personal> role:researcher`51- `generalist` or no role: register without a `role:` token unless the user specified one, then handle mixed work using the core workflow5253When the role is unclear, do not invent one. Ask one short question or proceed as a generalist if the task is already actionable.5455## Core Rules5657- **Priority**: Tasks have an integer `priority` field (higher = more urgent). `list_tasks` returns tasks sorted by priority. Claim the highest-priority open task first.58- **Unread-message guard**: `claim_task` and `claim_next_task` refuse to claim new open work while you have unread direct messages. Call `poll_messages` and handle corrections before retrying. Override only when intentionally ignoring those messages.59- **Dependencies**: Tasks can have a `depends_on` field (array of task IDs). A task with unmet dependencies starts as `blocked` and auto-transitions to `open` when all deps complete. If a dependency fails, downstream tasks are auto-cancelled.60- **Approval gates**: Tasks can be set to `approval_required` status. They remain gated until approved (transitions to `open`) or explicitly cancelled. Use this for true approval checkpoints, not routine code review.61- **Idempotency**: Tasks can have an `idempotency_key` field that prevents duplicate creation on retry.6263## Yield, Wait, Or Idle6465Use swarm as an event-driven coordination fabric, not a token-burning poll loop.6667- **Working**: you own a task, review, investigation, edit, lock, dependency, or delegated result to monitor.68- **Yield checkpoint**: at natural boundaries, call `bootstrap` or `poll_messages` before claiming more work, after `update_task`, after a peer handoff, and before your final response.69- **Monitoring**: call `wait_for_activity` only while you still own an active coordination obligation, such as a dependency, review, lock release, peer response, or gateway/planner delegation.70- **Idle**: if you have no active task, no delegated work to monitor, no pending dependency, and no instruction to stay warm, do not call `wait_for_activity` in a loop. Finish the turn and remain promptable if the runtime/workspace keeps the session alive.7172Use `send_message` for durable notes to busy peers. Use `prompt_peer` when a specific peer's live agent interface should be nudged, not only when you want to leave inbox mail; it records the full swarm message first, then best-effort injects a short wake prompt telling the peer to check messages. Use `peek_peer` when you need a read-only look at a peer's published workspace handle. Do not use `force=true` unless the update is urgent, corrective, or blocking.7374Deregister only when you are actually exiting, ending a one-shot session, or otherwise will not remain available. Plugin-managed sessions usually handle deregistration at runtime finalization.7576## References7778| Topic | Reference | Load When |79|-------|-----------|-----------|80| Bootstrap and registration fields | `references/bootstrap.md` | You need to decide `directory`, `scope`, `file_root`, or `label` |81| Planner workflow | `references/planner.md` | The session should plan, delegate, monitor, or recover work |82| Implementer workflow | `references/implementer.md` | The session should claim tasks and edit code |83| Reviewer workflow | `references/reviewer.md` | The session should review completed work or inspect risk |84| Researcher workflow | `references/researcher.md` | The session should investigate and publish findings |85| Gateway workflow | `references/gateway.md` | The session has `mode:gateway` and needs to dispatch, spawn, place, or monitor workers |86| Work tracker linkage | `references/work-trackers.md` | Work should be linked to Linear, Jira, GitHub Issues, or another configured tracker |87| KV and shared coordination state | `references/coordination.md` | You need to read/write `progress/`, `plan/`, `owner/`, queue, or handoff keys |88| Specialists, generalists, and team conventions | `references/roles-and-teams.md` | You need to route work by `role:` or `team:` labels |89| Identity, auth, and design-tool routing | `../../docs/identity-boundaries.md` | You need to route work across personal/work identities, Figma/Linear, or external Codex/OpenCode/Claude design workers |90| `swarm-mcp` CLI reference | `references/cli.md` | You are about to write or invoke a helper script, inspect swarm state from a plain terminal, or control `swarm-ui` through the CLI |9192## Do Not9394- Assume other sessions share your exact working directory unless `scope` and `file_root` make that true95- Invent role-routing behavior that is not visible from labels, messages, tasks, or instructions96- Hold file locks longer than the critical section they were taken for97- Call `lock_file` reflexively before every edit — that's the plugin hook's job in plugin-supported runtimes98- Use `assignee` for a stale or unknown instance99- Confuse direct messages with task handoff; use `request_task` for structured delegated work100- Try to claim `blocked` tasks — they will become `open` automatically101- Use whatever tracker MCP is available when the configured same-identity tracker is missing or ambiguous102- Shell out to the `swarm-mcp` CLI for normal coordination primitives from inside your agent loop — use the MCP tools, including `dispatch` for gateway task/spawn routing. Use the CLI bridge only from operator scripts, hooks, or gateway sessions where the MCP tools are unavailable.103104## Collaboration Heuristics105106- Prefer `request_task` when the work should be tracked and completed107- Prefer explicit `review` tasks over passive review scans108- Prefer `send_message` for durable targeted notes that do not need task state109- Prefer `prompt_peer` when a specific peer should get a live-interface nudge; it records the swarm message first, then best-effort wakes the workspace handle to make the peer check messages110- Prefer `peek_peer` when inspecting a peer's recent workspace output is enough and no durable message or nudge is needed111- Prefer `broadcast` for short status updates that help everyone112- Prefer `request_task` or tracker comments for findings that must survive the current swarm session113- Prefer a matching `role:` token when choosing a specialist114- Prefer a matching `team:` token when the swarm uses soft teams115- Fall back to any matching specialist, then to a generalist, when the ideal collaborator is unavailable116- Use `wait_for_activity` as a blocking monitor while you are responsible for a result, not as idle availability. Peers may wake you with a short prompt to call `poll_messages` or `bootstrap`.117- If you are acting as a planner, watch `owner/planner` on `kv_updates` so you can resume from `plan/latest` after failover118- For long-running concrete tasks, use `report_progress` so others can inspect task-local progress without interrupting; include `blocked_reason` and `expected_next_update_at` only when useful119- Messages prefixed with `[auto]` are system notifications (task assignments, completions, stale-agent recovery) — treat them like any other actionable message120- When you receive a `[signal:complete]` broadcast, the planner is signaling all planned work is done. Finish current work, publish final status, then idle or deregister if you are exiting.121- In gateway/lead mode, no live worker is a spawn problem, not a native-subagent fallback. Load `references/gateway.md` before dispatching, spawning, setting `placement`, or using `completion_wait_seconds`. Worker/generalist sessions do not spawn new workers; they request tracked work, message the planner/gateway, or continue locally when safe.122123## CLI Fallback124125Swarm coordination inside an agent loop should use MCP tools. The `dispatch` MCP tool is the first-class gateway path: it creates/reuses a task, wakes a live worker when one exists, or spawns through the configured Spawner backend when no worker is live. It is enforced server-side and restricted to gateway authority.126127The CLI bridge remains for hooks, operator shells, and rare gateway fallback cases where the MCP tools are not mounted. When you must use it, resolve the command prefix in this order:1281291. Use the exact `SWARM_MCP_BIN` value if set by the launcher.1302. Otherwise use `swarm-mcp` from `PATH`.1313. If neither works, use herdr directly if available, or ask the operator to start the worker.132133Do not ask ordinary worker sessions to run `dispatch`, `ui spawn`, or raw workspace-backend pane/node creation. Spawn authority belongs to `mode:gateway` sessions and operator surfaces; non-gateway MCP callers should expect `dispatch` to reject them.134135For synchronous CLI wrappers, `swarm-mcp dispatch --wait-for-completion <seconds>` mirrors MCP `completion_wait_seconds`: it still reports the normal dispatch handoff/spawn status, plus a `completion` object when the task reaches `done`, `failed`, or `cancelled`, or a timeout snapshot when it does not.136137## Structured Results Convention138139When completing a task, prefer `complete_task`:140141```json142{143 "task_id": "<task-id>",144 "status": "done",145 "summary": "What was done and why.",146 "files_changed": ["src/foo.ts"],147 "tests": [{ "command": "bun test", "status": "passed" }],148 "followups": []149}150```151152Fall back to terminal `update_task` with a plain string when structured handoff is not useful.153154---155> Source: [Volpestyle/swarm-mcp](https://github.com/Volpestyle/swarm-mcp) — distributed by [TomeVault](https://tomevault.io).156<!-- tomevault:4.0:skill_md:2026-06-16 -->