[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75WH75ZHV1M7F6WTSVWQX51":3,"skill-same:01M75WH75ZHV1M7F6WTSVWQX51":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":44},"01M75WH75ZHV1M7F6WTSVWQX51","swarm-orchestration",null,"A tmux-based persistent multi-agent swarm system with file-based inter-agent messaging","stevengonsalvez\u002Fainb-toolkit","stevengonsalvez","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F9320602?v=4","01M75W59QRYZYANWY3XG8CJB1P","Steven Gonsalvez","01M75W59RD5YW1RT67BDV0EAZF",1,"MIT","https:\u002F\u002Fgithub.com\u002Fstevengonsalvez\u002Fainb-toolkit\u002Fblob\u002Fmain\u002Fskills\u002Fswarm-orchestration\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: swarm-orchestration\ndescription: A tmux-based persistent multi-agent swarm system with file-based inter-agent messaging\nuser-invocable: true\n---\n\n# Swarm Orchestration Skill\n\nA tmux-based persistent multi-agent swarm system with file-based inter-agent messaging, leveraging Beads for task coordination.\n\n## Overview\n\nSwarm Orchestration enables Claude Code agents to work as persistent teams that:\n- **Stay alive** in tmux sessions across disconnects\n- **Communicate** via file-based inboxes (@mentions)\n- **Share work** through a task queue (via Beads)\n- **Coordinate** through a designated team leader\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────────────────┐\n│                      SWARM ORCHESTRATOR                         │\n│  .claude\u002Fswarm\u002F{team-id}\u002F                                       │\n│  ├── team.json        # Team metadata, members, state           │\n│  ├── inbox\u002F           # Inter-agent message inboxes             │\n│  │   ├── leader.jsonl                                           │\n│  │   ├── agent-1.jsonl                                          │\n│  │   └── agent-2.jsonl                                          │\n│  └── shared\u002F          # Shared context files                    │\n│      └── plan.md                                                │\n├─────────────────────────────────────────────────────────────────┤\n│                      BEADS COORDINATION                         │\n│  bd swarm create epic-id    # Create DAG structure              │\n│  bd ready --unassigned      # Work discovery                    │\n│  bd update --assignee       # Claim work                        │\n│  bd swarm status            # Progress tracking                 │\n├─────────────────────────────────────────────────────────────────┤\n│                      TMUX SESSIONS                              │\n│  swarm-{team-id}-leader     # Team leader session               │\n│  swarm-{team-id}-agent-1    # Worker agent 1                    │\n│  swarm-{team-id}-agent-2    # Worker agent 2                    │\n└─────────────────────────────────────────────────────────────────┘\n```\n\n## Isolation Modes\n\nWhen creating a swarm, you choose how agents are isolated:\n\n### Shared Mode (Default)\n\nAll agents work in the **same directory** on the **same branch**:\n\n```\n┌─────────────────────────────────────────┐\n│        Working Directory (shared)        │\n│                                          │\n│  Agent-1 writes: convex\u002Fschema.ts       │\n│  Agent-2 writes: src\u002Fhooks\u002FuseAuth.ts   │\n│  Agent-3 writes: src\u002Fpages\u002FLogin.tsx    │\n│                                          │\n│  (All writing to same filesystem)        │\n└─────────────────────────────────────────┘\n```\n\n**Pros:** Fast startup, no merge step, simpler\n**Cons:** Risk of file conflicts if tasks overlap\n**Best for:** Well-partitioned tasks, small teams\n\n### Worktree Mode\n\nEach agent gets its **own git worktree** with a **separate branch**:\n\n```\n┌───────────────────┐  ┌───────────────────┐  ┌───────────────────┐\n│  agent-1 worktree │  │  agent-2 worktree │  │  agent-3 worktree │\n│  branch: swarm-   │  │  branch: swarm-   │  │  branch: swarm-   │\n│    xxx-agent-1    │  │    xxx-agent-2    │  │    xxx-agent-3    │\n│                   │  │                   │  │                   │\n│  Full repo copy   │  │  Full repo copy   │  │  Full repo copy   │\n└─────────┬─────────┘  └─────────┬─────────┘  └─────────┬─────────┘\n          │                      │                      │\n          └──────────────────────┼──────────────────────┘\n                                 │\n                                 ▼\n                    ┌───────────────────────┐\n                    │    git merge at end   │\n                    │    (all branches)     │\n                    └───────────────────────┘\n```\n\n**Pros:** Full isolation, agents commit independently, handles conflicts\n**Cons:** Slower startup (creates worktrees), requires merge step\n**Best for:** Large teams, overlapping files, safer rollback\n\n### Choosing a Mode\n\n| Scenario | Recommended Mode |\n|----------|-----------------|\n| Tasks touch different files | Shared |\n| Tasks might touch same files | Worktree |\n| Quick prototyping | Shared |\n| Production feature work | Worktree |\n| 2-3 agents | Shared |\n| 4+ agents | Worktree |\n\n## Quick Start\n\n### Create a Swarm\n\n```bash\n# Ask about isolation mode (recommended)\n\u002Fswarm-create --epic bd-epic-platform-rebuild --agents 3\n\n# Explicit shared mode\n\u002Fswarm-create --epic bd-epic-123 --agents 3 --isolation shared\n\n# Explicit worktree mode (full isolation)\n\u002Fswarm-create --epic bd-epic-123 --agents 3 --isolation worktree\n\n# Dry run to preview\n\u002Fswarm-create --epic bd-epic-123 --agents 2 --dry-run\n```\n\n### Monitor Status\n\n```bash\n\u002Fswarm-status swarm-1738585396\n```\n\n### Inter-Agent Communication\n\n```bash\n# Read inbox\n\u002Fswarm-inbox\n\n# Send message\n\u002Fswarm-inbox --to agent-1 --msg \"Task complete\"\n\n# Broadcast\n\u002Fswarm-inbox --broadcast --msg \"Taking a break\"\n```\n\n### Shutdown\n\n```bash\n# Graceful shutdown\n\u002Fswarm-shutdown swarm-1738585396\n\n# Force shutdown\n\u002Fswarm-shutdown swarm-1738585396 --force\n```\n\n## Commands Reference\n\n| Command | Description |\n|---------|-------------|\n| `\u002Fswarm-create` | Create a new swarm team from a Beads epic |\n| `\u002Fswarm-join` | Join an existing swarm as a worker agent |\n| `\u002Fswarm-inbox` | Read\u002Fsend inter-agent messages |\n| `\u002Fswarm-status` | Display team status dashboard |\n| `\u002Fswarm-shutdown` | Gracefully terminate a swarm |\n\n## Team Structure\n\n### Team Metadata (`team.json`)\n\n```json\n{\n  \"team_id\": \"swarm-1738585396\",\n  \"created_at\": \"2026-02-03T11:23:16Z\",\n  \"epic_id\": \"bd-epic-123\",\n  \"leader\": {\n    \"session\": \"swarm-1738585396-leader\",\n    \"status\": \"active\",\n    \"role\": \"orchestrator\"\n  },\n  \"members\": [\n    {\n      \"name\": \"agent-1\",\n      \"session\": \"swarm-1738585396-agent-1\",\n      \"status\": \"active\",\n      \"current_task\": \"bd-task-001\",\n      \"worktree\": \".claude\u002Fswarm\u002Fswarm-1738585396\u002Fworktrees\u002Fagent-1\",\n      \"branch\": \"swarm-1738585396-agent-1\"\n    },\n    {\n      \"name\": \"agent-2\",\n      \"session\": \"swarm-1738585396-agent-2\",\n      \"status\": \"idle\",\n      \"current_task\": null,\n      \"worktree\": \".claude\u002Fswarm\u002Fswarm-1738585396\u002Fworktrees\u002Fagent-2\",\n      \"branch\": \"swarm-1738585396-agent-2\"\n    }\n  ],\n  \"config\": {\n    \"max_members\": 4,\n    \"inbox_poll_seconds\": 5,\n    \"idle_timeout_minutes\": 15,\n    \"isolation_mode\": \"worktree\",\n    \"base_branch\": \"feat\u002Fmy-feature\"\n  }\n}\n```\n\n**Note:** `worktree` and `branch` fields only present when `isolation_mode` is `\"worktree\"`.\n\n### Inbox Message Format\n\nMessages are stored as JSONL (one JSON object per line):\n\n```json\n{\n  \"ts\": \"2026-02-03T11:25:00Z\",\n  \"from\": \"leader\",\n  \"to\": \"agent-1\",\n  \"type\": \"task\",\n  \"payload\": {\n    \"task_id\": \"bd-task-001\",\n    \"action\": \"start\"\n  }\n}\n```\n\n### Message Types\n\n| Type | Direction | Purpose |\n|------|-----------|---------|\n| `task` | leader → agent | Assign work |\n| `status` | agent → leader | Progress update |\n| `complete` | agent → leader | Task finished |\n| `handoff` | agent → agent | Pass work |\n| `help` | agent → leader | Request assistance |\n| `broadcast` | any → all | Team announcement |\n| `shutdown` | system → all | Termination signal |\n\n## Library Functions\n\nThe core library is at `.claude\u002Futils\u002Fswarm-lib.sh`:\n\n### Team Management\n\n```bash\n# Create team\nTEAM_ID=$(swarm_create_team \"bd-epic-123\" 4)\n\n# Get team info\nswarm_get_team \"$TEAM_ID\"\n\n# List all teams\nswarm_list_teams\n\n# Update team\nswarm_update_team \"$TEAM_ID\" '{\"status\": \"active\"}'\n```\n\n### Agent Spawning\n\n```bash\n# Spawn leader\nswarm_spawn_leader \"$TEAM_ID\" \"Custom instructions\"\n\n# Spawn worker\nswarm_spawn_agent \"$TEAM_ID\" \"agent-1\" \"Custom instructions\"\n```\n\n### Messaging\n\n```bash\n# Send message\nswarm_send_message \"$TEAM_ID\" \"leader\" \"agent-1\" \"task\" '{\"task_id\": \"bd-001\"}'\n\n# Broadcast\nswarm_broadcast \"$TEAM_ID\" \"leader\" \"status\" '{\"message\": \"All hands meeting\"}'\n\n# Read inbox\nswarm_read_inbox \"$TEAM_ID\" \"agent-1\" --last 10\n\n# Clear inbox\nswarm_clear_inbox \"$TEAM_ID\" \"agent-1\"\n```\n\n### Status & Control\n\n```bash\n# Get comprehensive status\nswarm_get_status \"$TEAM_ID\"\n\n# Update member status\nswarm_update_member_status \"$TEAM_ID\" \"agent-1\" \"working\" \"bd-task-001\"\n\n# Shutdown team\nswarm_shutdown \"$TEAM_ID\"         # Graceful\nswarm_shutdown \"$TEAM_ID\" --force # Immediate\n\n# Archive team\nswarm_archive \"$TEAM_ID\"\n```\n\n## Beads Integration\n\nSwarms integrate with Beads for task management:\n\n```bash\n# Create swarm structure from epic\nbd swarm create bd-epic-123\n\n# Check swarm progress\nbd swarm status bd-epic-123 --json\n\n# Link tasks to parent epic (use --parent, NOT --epic)\nbd update bd-task-001 --parent bd-epic-123\n\n# Find ready work (for leader)\nbd ready --unassigned --json\n\n# Claim task (for worker)\nbd update bd-task-001 --assignee agent-1 --status in_progress\n\n# Complete task (for worker)\nbd close bd-task-001 --reason \"Implementation complete\"\n```\n\n## Agent Roles\n\n### Leader\n\nThe team leader (`.claude\u002Fagents\u002Fswarm\u002Fleader.md`):\n\n- **Coordinates** work distribution\n- **Monitors** agent progress\n- **Handles** blockers and escalations\n- **Facilitates** handoffs between agents\n\n### Worker\n\nWorker agents (`.claude\u002Fagents\u002Fswarm\u002Fworker.md`):\n\n- **Execute** assigned tasks\n- **Report** progress to leader\n- **Request** help when blocked\n- **Handoff** work when appropriate\n\n## Workflow Example\n\n### 1. Create Swarm\n\n```bash\n\u002Fswarm-create --epic bd-epic-auth-refactor --agents 2\n```\n\nOutput:\n```\nCreated team: swarm-1738585396\nLeader spawned: swarm-1738585396-leader\nAgent spawned: swarm-1738585396-agent-1\nAgent spawned: swarm-1738585396-agent-2\n```\n\n### 2. Leader Discovers Work\n\nLeader checks for ready tasks:\n```bash\nbd ready --unassigned --json\n# Returns: [{\"id\": \"bd-task-001\", \"title\": \"Implement JWT tokens\"}]\n```\n\n### 3. Leader Assigns Task\n\nLeader sends task to idle agent:\n```bash\nswarm_send_message \"swarm-1738585396\" \"leader\" \"agent-1\" \"task\" \\\n  '{\"task_id\": \"bd-task-001\", \"action\": \"start\"}'\n```\n\n### 4. Agent Executes\n\nAgent-1 receives task, claims it, works on it:\n```bash\n# Claim\nbd update bd-task-001 --assignee agent-1 --status in_progress\n\n# Work...\n\n# Report progress\nswarm_send_message \"swarm-1738585396\" \"agent-1\" \"leader\" \"status\" \\\n  '{\"task_id\": \"bd-task-001\", \"progress\": 50}'\n\n# Complete\nbd close bd-task-001 --reason \"JWT implementation complete\"\n\n# Notify\nswarm_send_message \"swarm-1738585396\" \"agent-1\" \"leader\" \"complete\" \\\n  '{\"task_id\": \"bd-task-001\"}'\n```\n\n### 5. Monitor Progress\n\n```bash\n\u002Fswarm-status swarm-1738585396\n```\n\n### 6. Shutdown When Done\n\n```bash\n\u002Fswarm-shutdown swarm-1738585396\n```\n\n### 7. Merge Worktrees (if using worktree mode)\n\nIf you used worktree isolation, merge agent branches back:\n\n```bash\n# Merge all agent branches to current branch\nbash .claude\u002Futils\u002Fswarm-lib.sh merge-worktrees swarm-1738585396\n\n# Keep worktrees after merge (for debugging)\nbash .claude\u002Futils\u002Fswarm-lib.sh merge-worktrees swarm-1738585396 --no-delete\n\n# Check what was merged\ngit log --oneline -10\n```\n\n## File Structure\n\n```\n.claude\u002F\n├── utils\u002F\n│   └── swarm-lib.sh           # Core library functions\n├── commands\u002F\n│   ├── swarm-create.md        # Create swarm command\n│   ├── swarm-join.md          # Join swarm command\n│   ├── swarm-inbox.md         # Inbox operations\n│   ├── swarm-status.md        # Status dashboard\n│   └── swarm-shutdown.md      # Shutdown command\n├── agents\u002Fswarm\u002F\n│   ├── leader.md              # Leader agent definition\n│   └── worker.md              # Worker agent definition\n├── skills\u002Fswarm-orchestration\u002F\n│   └── SKILL.md               # This documentation\n└── swarm\u002F                     # Runtime data (created per-team)\n    └── swarm-{id}\u002F\n        ├── team.json\n        ├── inbox\u002F\n        │   ├── leader.jsonl\n        │   └── agent-*.jsonl\n        └── shared\u002F\n```\n\n## Troubleshooting\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| \"Team not found\" | Check team ID exists: `swarm_list_teams` |\n| \"Session already exists\" | Previous swarm not cleaned up: `\u002Fswarm-shutdown` |\n| \"At max capacity\" | Increase `max_members` in team.json or use fewer agents |\n| tmux not available | Install: `brew install tmux` |\n| jq not available | Install: `brew install jq` |\n| Beads not available | Install Beads plugin or work without task tracking |\n| Agent stuck at shell prompt | Claude may not auto-start due to dotenv\u002Fzsh prompts. Attach (`tmux attach -t \u003Csession>`) and manually run `claude --dangerously-skip-permissions` |\n| Detection timeout | Increase timeout in `wait_for_claude_ready()` or check for blocking prompts (dotenv, etc.) |\n\n### Debugging\n\n```bash\n# Check tmux sessions\ntmux list-sessions | grep swarm\n\n# View agent output\ntmux attach -t swarm-1738585396-agent-1\n\n# Check inbox contents\ncat .claude\u002Fswarm\u002Fswarm-1738585396\u002Finbox\u002Fagent-1.jsonl | jq .\n\n# Check team state\ncat .claude\u002Fswarm\u002Fswarm-1738585396\u002Fteam.json | jq .\n```\n\n## Limitations\n\n- **Single machine** - All agents run on same host\n- **File-based messaging** - Not real-time, polling-based\n- **Manual recovery** - No automatic agent restart\n- **Max 4 agents** - Default limit per team (configurable)\n\n## Future Enhancements\n\nPotential improvements for future versions:\n\n- [ ] Automatic agent health monitoring and restart\n- [ ] Cost tracking per agent\n- [ ] WebSocket-based real-time messaging option\n- [ ] Cross-machine agent distribution\n- [ ] Visual dashboard UI\n- [ ] Integration with more task trackers (GitHub Issues, Jira)\n\n## Related Skills\n\n- **tmux-monitor** - Monitor tmux sessions\n- **spawn-agent** - Spawn individual agents\n- **beads** - Task tracking integration\n- **orchestrator** - Original multi-agent orchestration\n","# Swarm Orchestration Skill\n\nA tmux-based persistent multi-agent swarm system with file-based inter-agent messaging, leveraging Beads for task coordination.\n\n## Overview\n\nSwarm Orchestration enables Claude Code agents to work as persistent teams that:\n- **Stay alive** in tmux sessions across disconnects\n- **Communicate** via file-based inboxes (@mentions)\n- **Share work** through a task queue (via Beads)\n- **Coordinate** through a designated team leader\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────────────────┐\n│                      SWARM ORCHESTRATOR                         │\n│  .claude\u002Fswarm\u002F{team-id}\u002F                                       │\n│  ├── team.json        # Team metadata, members, state           │\n│  ├── inbox\u002F           # Inter-agent message inboxes             │\n│  │   ├── leader.jsonl                                           │\n│  │   ├── agent-1.jsonl                                          │\n│  │   └── agent-2.jsonl                                          │\n│  └── shared\u002F          # Shared context files                    │\n│      └── plan.md                                                │\n├─────────────────────────────────────────────────────────────────┤\n│                      BEADS COORDINATION                         │\n│  bd swarm create epic-id    # Create DAG structure              │\n│  bd ready --unassigned      # Work discovery                    │\n│  bd update --assignee       # Claim work                        │\n│  bd swarm status            # Progress tracking                 │\n├─────────────────────────────────────────────────────────────────┤\n│                      TMUX SESSIONS                              │\n│  swarm-{team-id}-leader     # Team leader session               │\n│  swarm-{team-id}-agent-1    # Worker agent 1                    │\n│  swarm-{team-id}-agent-2    # Worker agent 2                    │\n└─────────────────────────────────────────────────────────────────┘\n```\n\n## Isolation Modes\n\nWhen creating a swarm, you choose how agents are isolated:\n\n### Shared Mode (Default)\n\nAll agents work in the **same directory** on the **same branch**:\n\n```\n┌─────────────────────────────────────────┐\n│        Working Directory (shared)        │\n│                                          │\n│  Agent-1 writes: convex\u002Fschema.ts       │\n│  Agent-2 writes: src\u002Fhooks\u002FuseAuth.ts   │\n│  Agent-3 writes: src\u002Fpages\u002FLogin.tsx    │\n│                                          │\n│  (All writing to same filesystem)        │\n└─────────────────────────────────────────┘\n```\n\n**Pros:** Fast startup, no merge step, simpler\n**Cons:** Risk of file conflicts if tasks overlap\n**Best for:** Well-partitioned tasks, small teams\n\n### Worktree Mode\n\nEach agent gets its **own git worktree** with a **separate branch**:\n\n```\n┌───────────────────┐  ┌───────────────────┐  ┌───────────────────┐\n│  agent-1 worktree │  │  agent-2 worktree │  │  agent-3 worktree │\n│  branch: swarm-   │  │  branch: swarm-   │  │  branch: swarm-   │\n│    xxx-agent-1    │  │    xxx-agent-2    │  │    xxx-agent-3    │\n│                   │  │                   │  │                   │\n│  Full repo copy   │  │  Full repo copy   │  │  Full repo copy   │\n└─────────┬─────────┘  └─────────┬─────────┘  └─────────┬─────────┘\n          │                      │                      │\n          └──────────────────────┼──────────────────────┘\n                                 │\n                                 ▼\n                    ┌───────────────────────┐\n                    │    git merge at end   │\n                    │    (all branches)     │\n                    └───────────────────────┘\n```\n\n**Pros:** Full isolation, agents commit independently, handles conflicts\n**Cons:** Slower startup (creates worktrees), requires merge step\n**Best for:** Large teams, overlapping files, safer rollback\n\n### Choosing a Mode\n\n| Scenario | Recommended Mode |\n|----------|-----------------|\n| Tasks touch different files | Shared |\n| Tasks might touch same files | Worktree |\n| Quick prototyping | Shared |\n| Production feature work | Worktree |\n| 2-3 agents | Shared |\n| 4+ agents | Worktree |\n\n## Quick Start\n\n### Create a Swarm\n\n```bash\n# Ask about isolation mode (recommended)\n\u002Fswarm-create --epic bd-epic-platform-rebuild --agents 3\n\n# Explicit shared mode\n\u002Fswarm-create --epic bd-epic-123 --agents 3 --isolation shared\n\n# Explicit worktree mode (full isolation)\n\u002Fswarm-create --epic bd-epic-123 --agents 3 --isolation worktree\n\n# Dry run to preview\n\u002Fswarm-create --epic bd-epic-123 --agents 2 --dry-run\n```\n\n### Monitor Status\n\n```bash\n\u002Fswarm-status swarm-1738585396\n```\n\n### Inter-Agent Communication\n\n```bash\n# Read inbox\n\u002Fswarm-inbox\n\n# Send message\n\u002Fswarm-inbox --to agent-1 --msg \"Task complete\"\n\n# Broadcast\n\u002Fswarm-inbox --broadcast --msg \"Taking a break\"\n```\n\n### Shutdown\n\n```bash\n# Graceful shutdown\n\u002Fswarm-shutdown swarm-1738585396\n\n# Force shutdown\n\u002Fswarm-shutdown swarm-1738585396 --force\n```\n\n## Commands Reference\n\n| Command | Description |\n|---------|-------------|\n| `\u002Fswarm-create` | Create a new swarm team from a Beads epic |\n| `\u002Fswarm-join` | Join an existing swarm as a worker agent |\n| `\u002Fswarm-inbox` | Read\u002Fsend inter-agent messages |\n| `\u002Fswarm-status` | Display team status dashboard |\n| `\u002Fswarm-shutdown` | Gracefully terminate a swarm |\n\n## Team Structure\n\n### Team Metadata (`team.json`)\n\n```json\n{\n  \"team_id\": \"swarm-1738585396\",\n  \"created_at\": \"2026-02-03T11:23:16Z\",\n  \"epic_id\": \"bd-epic-123\",\n  \"leader\": {\n    \"session\": \"swarm-1738585396-leader\",\n    \"status\": \"active\",\n    \"role\": \"orchestrator\"\n  },\n  \"members\": [\n    {\n      \"name\": \"agent-1\",\n      \"session\": \"swarm-1738585396-agent-1\",\n      \"status\": \"active\",\n      \"current_task\": \"bd-task-001\",\n      \"worktree\": \".claude\u002Fswarm\u002Fswarm-1738585396\u002Fworktrees\u002Fagent-1\",\n      \"branch\": \"swarm-1738585396-agent-1\"\n    },\n    {\n      \"name\": \"agent-2\",\n      \"session\": \"swarm-1738585396-agent-2\",\n      \"status\": \"idle\",\n      \"current_task\": null,\n      \"worktree\": \".claude\u002Fswarm\u002Fswarm-1738585396\u002Fworktrees\u002Fagent-2\",\n      \"branch\": \"swarm-1738585396-agent-2\"\n    }\n  ],\n  \"config\": {\n    \"max_members\": 4,\n    \"inbox_poll_seconds\": 5,\n    \"idle_timeout_minutes\": 15,\n    \"isolation_mode\": \"worktree\",\n    \"base_branch\": \"feat\u002Fmy-feature\"\n  }\n}\n```\n\n**Note:** `worktree` and `branch` fields only present when `isolation_mode` is `\"worktree\"`.\n\n### Inbox Message Format\n\nMessages are stored as JSONL (one JSON object per line):\n\n```json\n{\n  \"ts\": \"2026-02-03T11:25:00Z\",\n  \"from\": \"leader\",\n  \"to\": \"agent-1\",\n  \"type\": \"task\",\n  \"payload\": {\n    \"task_id\": \"bd-task-001\",\n    \"action\": \"start\"\n  }\n}\n```\n\n### Message Types\n\n| Type | Direction | Purpose |\n|------|-----------|---------|\n| `task` | leader → agent | Assign work |\n| `status` | agent → leader | Progress update |\n| `complete` | agent → leader | Task finished |\n| `handoff` | agent → agent | Pass work |\n| `help` | agent → leader | Request assistance |\n| `broadcast` | any → all | Team announcement |\n| `shutdown` | system → all | Termination signal |\n\n## Library Functions\n\nThe core library is at `.claude\u002Futils\u002Fswarm-lib.sh`:\n\n### Team Management\n\n```bash\n# Create team\nTEAM_ID=$(swarm_create_team \"bd-epic-123\" 4)\n\n# Get team info\nswarm_get_team \"$TEAM_ID\"\n\n# List all teams\nswarm_list_teams\n\n# Update team\nswarm_update_team \"$TEAM_ID\" '{\"status\": \"active\"}'\n```\n\n### Agent Spawning\n\n```bash\n# Spawn leader\nswarm_spawn_leader \"$TEAM_ID\" \"Custom instructions\"\n\n# Spawn worker\nswarm_spawn_agent \"$TEAM_ID\" \"agent-1\" \"Custom instructions\"\n```\n\n### Messaging\n\n```bash\n# Send message\nswarm_send_message \"$TEAM_ID\" \"leader\" \"agent-1\" \"task\" '{\"task_id\": \"bd-001\"}'\n\n# Broadcast\nswarm_broadcast \"$TEAM_ID\" \"leader\" \"status\" '{\"message\": \"All hands meeting\"}'\n\n# Read inbox\nswarm_read_inbox \"$TEAM_ID\" \"agent-1\" --last 10\n\n# Clear inbox\nswarm_clear_inbox \"$TEAM_ID\" \"agent-1\"\n```\n\n### Status & Control\n\n```bash\n# Get comprehensive status\nswarm_get_status \"$TEAM_ID\"\n\n# Update member status\nswarm_update_member_status \"$TEAM_ID\" \"agent-1\" \"working\" \"bd-task-001\"\n\n# Shutdown team\nswarm_shutdown \"$TEAM_ID\"         # Graceful\nswarm_shutdown \"$TEAM_ID\" --force # Immediate\n\n# Archive team\nswarm_archive \"$TEAM_ID\"\n```\n\n## Beads Integration\n\nSwarms integrate with Beads for task management:\n\n```bash\n# Create swarm structure from epic\nbd swarm create bd-epic-123\n\n# Check swarm progress\nbd swarm status bd-epic-123 --json\n\n# Link tasks to parent epic (use --parent, NOT --epic)\nbd update bd-task-001 --parent bd-epic-123\n\n# Find ready work (for leader)\nbd ready --unassigned --json\n\n# Claim task (for worker)\nbd update bd-task-001 --assignee agent-1 --status in_progress\n\n# Complete task (for worker)\nbd close bd-task-001 --reason \"Implementation complete\"\n```\n\n## Agent Roles\n\n### Leader\n\nThe team leader (`.claude\u002Fagents\u002Fswarm\u002Fleader.md`):\n\n- **Coordinates** work distribution\n- **Monitors** agent progress\n- **Handles** blockers and escalations\n- **Facilitates** handoffs between agents\n\n### Worker\n\nWorker agents (`.claude\u002Fagents\u002Fswarm\u002Fworker.md`):\n\n- **Execute** assigned tasks\n- **Report** progress to leader\n- **Request** help when blocked\n- **Handoff** work when appropriate\n\n## Workflow Example\n\n### 1. Create Swarm\n\n```bash\n\u002Fswarm-create --epic bd-epic-auth-refactor --agents 2\n```\n\nOutput:\n```\nCreated team: swarm-1738585396\nLeader spawned: swarm-1738585396-leader\nAgent spawned: swarm-1738585396-agent-1\nAgent spawned: swarm-1738585396-agent-2\n```\n\n### 2. Leader Discovers Work\n\nLeader checks for ready tasks:\n```bash\nbd ready --unassigned --json\n# Returns: [{\"id\": \"bd-task-001\", \"title\": \"Implement JWT tokens\"}]\n```\n\n### 3. Leader Assigns Task\n\nLeader sends task to idle agent:\n```bash\nswarm_send_message \"swarm-1738585396\" \"leader\" \"agent-1\" \"task\" \\\n  '{\"task_id\": \"bd-task-001\", \"action\": \"start\"}'\n```\n\n### 4. Agent Executes\n\nAgent-1 receives task, claims it, works on it:\n```bash\n# Claim\nbd update bd-task-001 --assignee agent-1 --status in_progress\n\n# Work...\n\n# Report progress\nswarm_send_message \"swarm-1738585396\" \"agent-1\" \"leader\" \"status\" \\\n  '{\"task_id\": \"bd-task-001\", \"progress\": 50}'\n\n# Complete\nbd close bd-task-001 --reason \"JWT implementation complete\"\n\n# Notify\nswarm_send_message \"swarm-1738585396\" \"agent-1\" \"leader\" \"complete\" \\\n  '{\"task_id\": \"bd-task-001\"}'\n```\n\n### 5. Monitor Progress\n\n```bash\n\u002Fswarm-status swarm-1738585396\n```\n\n### 6. Shutdown When Done\n\n```bash\n\u002Fswarm-shutdown swarm-1738585396\n```\n\n### 7. Merge Worktrees (if using worktree mode)\n\nIf you used worktree isolation, merge agent branches back:\n\n```bash\n# Merge all agent branches to current branch\nbash .claude\u002Futils\u002Fswarm-lib.sh merge-worktrees swarm-1738585396\n\n# Keep worktrees after merge (for debugging)\nbash .claude\u002Futils\u002Fswarm-lib.sh merge-worktrees swarm-1738585396 --no-delete\n\n# Check what was merged\ngit log --oneline -10\n```\n\n## File Structure\n\n```\n.claude\u002F\n├── utils\u002F\n│   └── swarm-lib.sh           # Core library functions\n├── commands\u002F\n│   ├── swarm-create.md        # Create swarm command\n│   ├── swarm-join.md          # Join swarm command\n│   ├── swarm-inbox.md         # Inbox operations\n│   ├── swarm-status.md        # Status dashboard\n│   └── swarm-shutdown.md      # Shutdown command\n├── agents\u002Fswarm\u002F\n│   ├── leader.md              # Leader agent definition\n│   └── worker.md              # Worker agent definition\n├── skills\u002Fswarm-orchestration\u002F\n│   └── SKILL.md               # This documentation\n└── swarm\u002F                     # Runtime data (created per-team)\n    └── swarm-{id}\u002F\n        ├── team.json\n        ├── inbox\u002F\n        │   ├── leader.jsonl\n        │   └── agent-*.jsonl\n        └── shared\u002F\n```\n\n## Troubleshooting\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| \"Team not found\" | Check team ID exists: `swarm_list_teams` |\n| \"Session already exists\" | Previous swarm not cleaned up: `\u002Fswarm-shutdown` |\n| \"At max capacity\" | Increase `max_members` in team.json or use fewer agents |\n| tmux not available | Install: `brew install tmux` |\n| jq not available | Install: `brew install jq` |\n| Beads not available | Install Beads plugin or work without task tracking |\n| Agent stuck at shell prompt | Claude may not auto-start due to dotenv\u002Fzsh prompts. Attach (`tmux attach -t \u003Csession>`) and manually run `claude --dangerously-skip-permissions` |\n| Detection timeout | Increase timeout in `wait_for_claude_ready()` or check for blocking prompts (dotenv, etc.) |\n\n### Debugging\n\n```bash\n# Check tmux sessions\ntmux list-sessions | grep swarm\n\n# View agent output\ntmux attach -t swarm-1738585396-agent-1\n\n# Check inbox contents\ncat .claude\u002Fswarm\u002Fswarm-1738585396\u002Finbox\u002Fagent-1.jsonl | jq .\n\n# Check team state\ncat .claude\u002Fswarm\u002Fswarm-1738585396\u002Fteam.json | jq .\n```\n\n## Limitations\n\n- **Single machine** - All agents run on same host\n- **File-based messaging** - Not real-time, polling-based\n- **Manual recovery** - No automatic agent restart\n- **Max 4 agents** - Default limit per team (configurable)\n\n## Future Enhancements\n\nPotential improvements for future versions:\n\n- [ ] Automatic agent health monitoring and restart\n- [ ] Cost tracking per agent\n- [ ] WebSocket-based real-time messaging option\n- [ ] Cross-machine agent distribution\n- [ ] Visual dashboard UI\n- [ ] Integration with more task trackers (GitHub Issues, Jira)\n\n## Related Skills\n\n- **tmux-monitor** - Monitor tmux sessions\n- **spawn-agent** - Spawn individual agents\n- **beads** - Task tracking integration\n- **orchestrator** - Original multi-agent orchestration\n",{"name":5,"description":7,"user-invocable":24},true,"main","9cf32d1e636db09530158af14ba301bfa5d401e9","skills\u002Fswarm-orchestration","https:\u002F\u002Fgithub.com\u002Fstevengonsalvez\u002Fainb-toolkit","https:\u002F\u002Fgithub.com\u002Fstevengonsalvez","stevengonsalvez.com","2026-11-12 00:50:59",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":24},[34,37,40],{"tool":35,"command":36},"npx","npx skills add stevengonsalvez\u002Fainb-toolkit --skill swarm-orchestration",{"tool":38,"command":39},"bunx","bunx skills add stevengonsalvez\u002Fainb-toolkit --skill swarm-orchestration",{"tool":41,"command":42},"pnpm","pnpm dlx skills add stevengonsalvez\u002Fainb-toolkit --skill swarm-orchestration","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fstevengonsalvez\u002Fainb-toolkit\u002Fblob\u002Fmain\u002Fskills\u002Fswarm-orchestration\u002FSKILL.md",[],[46,53,60,66,73,80],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M75WK9B8DKVJBJJ4CX2QMJMX","well-formed","Fixture skill that satisfies every mechanical rule, used to prove the conformance check passes a clean tree instead of failing everything.","https:\u002F\u002Fgithub.com\u002Fstevengonsalvez\u002Fainb-toolkit\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fagentskills\u002Fclean\u002Fwell-formed\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M75WK6ZGDXJJN8879K49QEYG","underscore-tools","Fixture skill that spells the tool allowlist key with an underscore instead of the hyphen the spec requires.","https:\u002F\u002Fgithub.com\u002Fstevengonsalvez\u002Fainb-toolkit\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fagentskills\u002Fbroken\u002Funderscore-tools\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M75WK524MVT2H9E27ZCEA3HR","no-frontmatter","https:\u002F\u002Fgithub.com\u002Fstevengonsalvez\u002Fainb-toolkit\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fagentskills\u002Fbroken\u002Fno-frontmatter\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M75WJWZBMKR8R60PG3T3MCCC","long-description","Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling. Fixture skill with a deliberately oversized description used to prove the conformance check rejects anything past the 1024 character ceiling.","https:\u002F\u002Fgithub.com\u002Fstevengonsalvez\u002Fainb-toolkit\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fagentskills\u002Fbroken\u002Flong-description\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M75WJVRH3J22WKED7E5D01S8","some-other-name","Fixture skill whose frontmatter name does not match its parent directory name.","https:\u002F\u002Fgithub.com\u002Fstevengonsalvez\u002Fainb-toolkit\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fagentskills\u002Fbroken\u002Fdir-mismatch\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M75WJTC7H5FRP6S129VBSMZC","bad_Name","Fixture skill whose name uses an underscore and a capital letter, so it violates the agentskills.io name pattern.","https:\u002F\u002Fgithub.com\u002Fstevengonsalvez\u002Fainb-toolkit\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fagentskills\u002Fbroken\u002Fbad_Name\u002FSKILL.md",[],[]]