surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
Swarm Coordination Patterns
Comprehensive guidance for coordinating multi-agent swarms to prevent conflicts and enable proactive monitoring.
When to Activate
Activate this skill when:
- Orchestrating multiple agents working on the same codebase
- Implementing features that require parallel agent execution
- Designing workflows where agents might edit overlapping files
- Debugging swarm coordination issues
Core Concepts
The Problem with Uncoordinated Swarms
When multiple agents work in parallel without coordination:
- File Conflicts: Multiple agents edit the same file simultaneously
- Merge Conflicts: Changes overwrite each other
- Endless Loops: Agents "fix" each other's code in circles
- Wasted Work: Duplicate effort on same files
Three-Pillar Solution
This skill teaches three complementary patterns:
- Status Polling (Fix 1): Orchestrator proactively monitors agent progress
- File Claiming (Fix 2): Agents claim ownership before editing
- Checkpoint Orchestration (Fix 5): Plan first, detect conflicts, then implement
Key Files
Coordination Files
.claude/swarm-status.json- Central status tracking.claude/file-claims.md- File ownership registry.claude/swarm-plans/- Agent implementation plans
Status File Format
{
"swarm_id": "swarm-20250115-abc123",
"task": "Implement user authentication",
"started": "2025-01-15T10:00:00Z",
"phase": "implementing",
"agents": {
"auth-impl": {"status": "working", "last_update": "2025-01-15T10:05:00Z"},
"db-schema": {"status": "completed", "last_update": "2025-01-15T10:03:00Z"}
},
"execution_order": [
{"batch": 1, "agents": ["db-schema"], "parallel": false},
{"batch": 2, "agents": ["auth-impl", "api-routes"], "parallel": true}
]
}
File Claims Format
# File Claims Registry
| Agent ID | File Path | Claimed At | Status |
|----------|-----------|------------|--------|
| auth-impl | src/auth/handler.ts | 2025-01-15T10:00:00Z | claimed |
| auth-impl | src/auth/types.ts | 2025-01-15T10:00:00Z | claimed |
| db-schema | src/db/schema.ts | 2025-01-15T10:00:00Z | released |
References
references/status-polling.md- Detailed polling patternsreferences/file-claiming.md- File ownership conventionsreferences/checkpoint-flow.md- Phase-based orchestrationexamples/simple-swarm.md- Basic two-agent swarmexamples/complex-swarm.md- Multi-phase feature implementation
Quick Start
- Use
/swarm [task]command for full orchestrated flow - For manual coordination, create the three coordination files
- Include file claiming instructions in all implementation agents
- Launch status-checker every 30-60 seconds during execution