CommunityCoding & Developmentgithub.com

dshvadskiy/swarm

Coordinate a parallel multi-agent swarm (coordinator, isolated workers, and independent verifier) for broad, divisible tasks or read-only audits. Uses Paseo MCP tools (worktrees, create_agent, send_agent_prompt) when running in Paseo, and falls back to native kiro-cli subagents when standalone. Use when the user asks to "swarm", invokes /swarm, or wants to parallelize builds, migrations, or audits across independent modules, files, or packages with independent verification.

What is swarm?

swarm is a Claude Code agent skill that coordinate a parallel multi-agent swarm (coordinator, isolated workers, and independent verifier) for broad, divisible tasks or read-only audits. Uses Paseo MCP tools (worktrees, create_agent, send_agent_prompt) when running in Paseo, and falls back to native kiro-cli subagents when standalone. Use when the user asks to "swarm", invokes /swarm, or wants to parallelize builds, migrations, or audits across independent modules, files, or packages with independent verification.

Works with✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/dshvadskiy/kiro-swarm/tree/HEAD/skills/swarm

Installed? Explore more Coding & Development skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Swarm Orchestration Skill

Turn the current session into a coordinator that extracts repo rules up front, splits a broad task into independent slices, delegates them to parallel workers, integrates their results, and runs an adversarial independent verifier before reporting done.

When to Use (and Skip)

  • Use when work splits cleanly into 2–6 independent slices: separate packages/modules, multi-file migrations, parallel read-only codebase audits, or concurrent implementation + test + documentation tracks.
  • Skip for single-file edits, tightly coupled refactors where every step depends on the previous one, or trivial 1–2 step tasks — handle those directly instead of burning extra quota.

Pre-Flight: Repo Charter & Context Extraction

Fresh-context workers and subagents do not inherit your earlier conversation. Before spawning anyone:

  1. Read project instruction and charter files if present: AGENTS.md, CLAUDE.md, .kiro/steering/*, README.md, and relevant build manifests (package.json, Cargo.toml, pyproject.toml, etc.).
  2. Extract:
    • Exact build, typecheck, lint, and targeted test commands
    • Forbidden commands (e.g., heavy full test suites, restarting running daemons)
    • Shared conventions and coordinator-only files
  3. Record all of these in the shared board (/tmp/kiro-swarm-<slug>.md) and embed the relevant subset in every worker brief.

Swarm Modes

Pick the mode that matches the user's goal:

1. Read-Only Audit Swarm (/swarm audit ...)

  • Fan out 2–5 parallel swarm-researcher tracks by domain (e.g., architecture/data-flow, bugs/edge cases, security, test coverage gaps, performance).
  • Zero file edits and no worktrees needed (all tracks run in the current workspace).
  • Synthesize findings into one executive report backed by exact file:line citations, and manually spot-check top findings before reporting.

2. Build / Migration Swarm (/swarm build ... / /swarm migrate ...)

  • Fan out 2–5 parallel swarm-worker slices (do not exceed 6 unless the user explicitly asks).
  • Isolate concurrent authors in separate git worktrees (or strictly disjoint paths when builds cannot conflict).
  • Merge worker branches into the target branch in dependency order, then run swarm-verifier before declaring done.

Roles & Model Tiering

  1. Coordinator (you): Breaks the goal into disjoint slices, defines shared interfaces/contracts up front, maintains the shared board, relays decisions, integrates branches, and drives verification. Avoid doing heavy parallel coding while workers are active.
  2. Workers (swarm-worker / swarm-researcher): Own bounded files, directories, or research tracks. Two authoring workers must never own overlapping files in the same working tree.
  3. Verifier (swarm-verifier): Fresh-context, read-only auditor invoked after all worker changes are integrated.

Role-Based Model Tiering (Vendor-Agnostic)

  • Coordinator & Verifier: Prefer a stronger reasoning model for planning, slicing, contract judgment, and adversarial diff review.
  • Workers & Researchers: Prefer a faster, cost-efficient coding model for parallel bulk execution and exploration.
  • In Paseo, inspect list_profiles and pick a strong profile for coordinator/verifier and a fast/worker profile for parallel slices. In standalone kiro-cli, pass --coordinator-model, --worker-model, --researcher-model, or --verifier-model to install.sh (or leave unset to inherit the active session model).

Custom Agents

Companion global agents are installed under ~/.kiro/agents/:

  • swarm-coordinator — orchestrator profile (tools: ["*"]); select directly via /agent swarm-coordinator or kiro-cli --agent swarm-coordinator
  • swarm-researcher — strictly read-only exploration and audit (read, grep, glob, web_search, web_fetch)
  • swarm-worker — scoped implementation worker (read, write, shell, grep, glob, web_search, web_fetch)
  • swarm-verifier — read-only diff auditor and test runner (read, shell, grep, glob)

Shared Swarm Board

To give all workers shared visibility without polluting the git repository, create a temporary board file at /tmp/kiro-swarm-<slug>.md before spawning workers:

  • Record: Goal, Base Branch / Commit, Repo Charter (verification + forbidden commands + conventions), Shared Contracts & Interfaces, Roster (worker → owned paths / branch / status), and Open Decisions.
  • Tell every worker the board path so they can read shared decisions.
  • As coordinator, keep the board updated as workers complete or when an interface changes.

Backend Selection

Check which orchestration tools exist in your current session and pick the matching mode:

Mode A: Paseo MCP Backend (Preferred when running inside Paseo)

Use this mode when Paseo MCP tools (create_agent, create_workspace, send_agent_prompt, list_profiles, list_providers) are available.

  1. Discover providers/profiles:
    • Call list_profiles (and list_providers if needed).
    • Pick the profiles/providers the user requested, or apply role-based tiering (stronger profile for verifier, fast/worker profile for parallel workers/researchers). Default to kiro when no override is requested.
  2. Isolate workspaces:
    • Read-only workers (researchers, auditors, reviewers): omit workspaceId so they share your current workspace.
    • Authoring workers (editing/building code in parallel): call create_workspace with:
      • isolation: "worktree"
      • mode: "branch-off"
      • branchName: swarm/<slug>/<worker-name>
      • baseBranch: the current branch (or explicit base ref)
    • Pass the returned workspaceId to create_agent.
  3. Spawn workers in parallel:
    • Call create_agent once per slice in parallel:
      • title: [Swarm] <worker-name>
      • provider: chosen provider/model (from profile or provider catalog)
      • workspaceId: isolated worktree ID for authors, omitted for readers
      • notifyOnFinish: true (default)
      • initialPrompt: include the target role expectations (swarm-researcher or swarm-worker) and use the Worker Brief Template below (or select the matching Kiro custom agent/mode via settings.modeId when exposed by the provider).
  4. Wait reactively — never poll:
    • Finish your turn and wait for Paseo's automatic finish notifications (which fire on completion, error, or permission request).
    • If a worker needs steering, clarification, or a cross-worker contract update, use send_agent_prompt (activeTurnBehavior: "queue" by default; use "steer" or "interrupt" only if it cannot wait).
    • If two workers need to coordinate directly, relay the decision yourself (preferred) or share the peer's agentId so they can message via send_agent_prompt.
  5. Land, adversarially verify (max 2 retry rounds), and clean up:
    • Inspect each authoring worker's branch/commits.
    • Merge or cherry-pick each worker branch into your working branch in dependency order, resolving any integration conflicts.
    • Spawn [Swarm] verifier in your workspace (using swarm-verifier expectations and a strong reasoning profile if available). Instruct it to never trust worker-claimed results, independently re-run typecheck/lint/targeted tests, and evaluate every requirement item-by-item (PASS/FAIL + overall VERDICT: PASS or VERDICT: FAIL).
    • Bounded retry loop (max 2 rounds): If the verifier returns VERDICT: FAIL, send targeted fix prompts to the owning worker (or fix small integration glue directly), re-merge, and re-run the verifier. If it still fails after 2 fix-and-reverify rounds, stop and escalate to the user with the verifier's exact diagnostics.
    • Only after VERDICT: PASS, archive worker agents (archive_agent) and archive temporary worktrees (archive_workspace). Delete /tmp/kiro-swarm-<slug>.md when finished.

Mode B: Standalone kiro-cli Backend (Fallback)

Use this mode when Paseo MCP tools are not present and you are running standalone kiro-cli.

  1. Choose isolation level:
    • Read-only tracks or strictly disjoint files without conflicting builds: Spawn parallel subagents in the current repo, enforcing non-overlapping file lists in each brief.
    • Concurrent code edits that run builds/tests: Create one git worktree per authoring worker before spawning:
      git worktree add -b swarm/<slug>/<worker-name> /tmp/kiro-swarm-<slug>/<worker-name> HEAD
      
      Instruct each subagent to work strictly inside /tmp/kiro-swarm-<slug>/<worker-name> and commit its changes on its branch when done.
  2. Spawn workers in parallel:
    • Invoke subagent delegation in parallel with the Worker Brief Template below, targeting swarm-researcher for read-only exploration/audits and swarm-worker for implementation (falling back to built-in context-gatherer / general-task-execution only if custom agents are unavailable).
  3. Integrate, adversarially verify (max 2 retry rounds), and clean up:
    • Merge worker branches into your current branch (git merge --no-ff swarm/<slug>/<worker-name> or cherry-pick), resolving conflicts cleanly.
    • Spawn a fresh swarm-verifier subagent (falling back to validation only if unavailable) to audit every requirement against the integrated diff and independently re-run typecheck, lint, and targeted tests.
    • Bounded retry loop (max 2 rounds): If the verifier returns VERDICT: FAIL, dispatch targeted fixes and re-verify up to 2 rounds; escalate to the user with exact diagnostics if it still fails.
    • Only after VERDICT: PASS, clean up temporary worktrees and branches:
      git worktree remove /tmp/kiro-swarm-<slug>/<worker-name>
      git branch -d swarm/<slug>/<worker-name>
      
      and remove /tmp/kiro-swarm-<slug>.md.

Worker Brief Template

Include every section below in each worker's prompt so it starts with zero ambiguity:

## Swarm Assignment: <worker-name>

- **Overall Goal:** <1–2 sentence objective>
- **Swarm Board:** `/tmp/kiro-swarm-<slug>.md` (read before starting for shared contracts)
- **Working Directory / Branch:** `<path and branch, or "read-only in current workspace">`
- **You Own:** <exact files, directories, or research questions>
- **Out of Scope (DO NOT EDIT):** <files owned by other workers or shared files reserved for the coordinator>
- **Contracts / Interfaces to Match:** <types, schemas, APIs, naming conventions>
- **Repo Rules & Forbidden Commands:** <extracted from AGENTS.md / charter>
- **Verification Required Before Finishing:** <exact targeted build/typecheck/lint/test commands>
- **Done Looks Like:** <concrete deliverable; for worktree authors: commit your changes on your branch>

When finished, reply concisely with:
1. Summary of changes or findings
2. Exact files touched (or commit hash)
3. Verification commands run and their results
4. Any blockers, assumptions, or follow-ups for other workers

Guardrails

  • Never delete or archive a worktree until its commits are merged/landed into the target branch.
  • Never push to a remote or open a PR unless the user explicitly requested it.
  • Never skip integrated verification — passing isolated worker checks does not prove the merged result builds and passes together.
  • Never exceed 2 fix-and-reverify loops — escalate to the user with diagnostics instead of burning quota.
  • Respect repository test rules — run targeted test files, typecheck, and lint rather than blindly running full heavy test suites unless asked.
  • Be honest about quota — announce the proposed worker roster (count + slices) before spawning if the task would require more than 4 workers.

Related Skills