name: swarm-mcp description: 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. argument-hint: "[planner|implementer|reviewer|researcher|generalist]" arguments: [role] metadata: short-description: Coordinate work through swarm-mcp domain: agent-coordination role: workflow scope: workflow
Swarm MCP
Use this skill when the swarm MCP server is available in the current session and the task benefits from multi-agent coordination.
This skill assumes the swarm tools are already mounted. If they are not present, say so clearly and fall back to local work or direct setup help.
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.
Start Here
- Bootstrap into the swarm with
register - Inspect the current swarm with
whoami,list_instances,poll_messages, andlist_tasks - While editing, call
lock_file— its response includes any peer annotations, so a separate check call is unnecessary. Skip locking entirely when alone in scope. - Delegate or coordinate with
request_task,send_message, orbroadcast - Leave durable context with
annotateand small shared state withkv_set - Complete a task with a single
update_task(terminal status). Locks on the task's files release automatically.
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: loadreferences/planner.mdand register withrole:plannerimplementer: loadreferences/implementer.mdand register withrole:implementerreviewer: loadreferences/reviewer.mdand register withrole:reviewerresearcher: loadreferences/researcher.mdand register withrole:researchergeneralistor no role: register without arole: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.
Task Features
- Priority: Tasks have an integer
priorityfield (higher = more urgent).list_tasksreturns tasks sorted by priority. Claim the highest-priority open task first. - Unread-message guard:
claim_taskrefuses to claim new open work while you have unread direct messages. Callpoll_messagesand handle corrections before retrying. Override only when intentionally ignoring those messages. - Dependencies: Tasks can have a
depends_onfield (array of task IDs). A task with unmet dependencies starts asblockedand auto-transitions toopenwhen all deps complete. If a dependency fails, downstream tasks are auto-cancelled. - Approval gates: Tasks can be set to
approval_requiredstatus. They remain gated until approved (transitions toopen) or explicitly cancelled. Use this for true approval checkpoints, not routine code review. - Idempotency: Tasks can have an
idempotency_keyfield that prevents duplicate creation on retry.
Load References As Needed
| 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 |
| 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 |
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 |
Constraints
Must Do
- Call
registerbefore using other swarm tools - Use
whoami,list_instances,poll_messages, andlist_tasksearly in the session. Iflist_instancesreturns only you, skip per-edit locking until peers join. - Call
lock_filewhile editing when peers are present. Read the returned annotations as your pre-edit check. - Use
update_taskonce at task completion (terminal status).claim_taskalready moved the task toin_progress. - Use explicit
reviewtasks for normal review handoff - Treat
role:labels as conventions, not hard schema - Treat sessions without a
role:label token as generalists - Prefer the highest-priority open task when claiming work
- Include structured results (JSON with
files_changed,test_status,summary) when completing tasks
Must Not Do
- Assume other sessions share your exact working directory unless
scopeandfile_rootmake that true - Invent role-routing behavior that is not visible from labels, messages, tasks, or instructions
- Hold file locks longer than needed
- Use
assigneefor a stale or unknown instance - Confuse direct messages with task handoff; use
request_taskfor structured delegated work - Try to claim
blockedtasks — they will becomeopenautomatically - Shell out to the
swarm-mcpCLI from inside your agent loop — use the MCP tools. The CLI exists for helper scripts that cannot speak MCP. Seereferences/cli.mdwhen writing such a script.
Default Behavior
When the skill triggers, prefer this sequence unless the task clearly requires something else:
- Verify the swarm tools exist
registerwhoamilist_instancespoll_messageslist_tasks- Summarize active specialists, open work, and collision risks before taking action
- Act on any pending work (claim tasks, respond to messages)
- Enter an autonomous loop using
wait_for_activity— react to messages, task changes, KV updates, and instance changes as they arrive. Do not wait for user prompting between tasks.
Collaboration Heuristics
- Prefer
request_taskwhen the work should be tracked and completed - Prefer explicit
reviewtasks over passive review scans - Prefer
send_messagefor targeted coordination that does not need task state - Prefer
broadcastfor short status updates that help everyone - Prefer
annotatefor file-specific findings another agent may need later - 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_activityas your idle loop — it blocks until new messages, task changes, KV updates, or instance changes arrive, then returns the updates so you can act immediately - If you are acting as a planner, watch
owner/planneronkv_updatesso you can resume fromplan/latestafter failover - Update your progress with
kv_set("progress/<your-instance-id>", ...)while working on tasks so others can check on you without interrupting - 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 work is done — finish current work, deregister, and stop
Structured Results Convention
When completing a task, prefer a JSON result:
{
"files_changed": ["src/foo.ts"],
"test_status": "pass",
"summary": "What was done and why."
}
Fall back to a plain string if you cannot produce structured output.
