Claude Skills Guide

Claude Code Agent Swarm Coordination Strategies

Running multiple Claude Code agents simultaneously transforms your development workflow from sequential task execution into parallel processing. This guide covers practical strategies for coordinating agent swarms, managing shared state, and building reliable multi-agent pipelines.

The Case for Agent Swarms

Single-agent workflows handle individual tasks well, but production scenarios often require parallel execution. Processing hundreds of PDF documents, running test suites across multiple modules, or generating documentation for a large codebase benefits from concurrent agent execution. The tdd skill demonstrates this naturally—when you run test generation across twenty files, coordinating multiple agents reduces completion time from minutes to seconds.

Claude Code supports spawning multiple subagents within a single session via structured tool calls. Understanding how to coordinate these agents effectively separates basic usage from professional-grade automation.

Strategy One: Fan-Out/Fan-In Pattern

The fan-out/fan-in pattern spawns multiple agents to handle independent tasks, then aggregates results. This works when tasks share no dependencies and can execute in any order.

In a Claude Code orchestrator session, you can instruct Claude to spawn subagents that each handle one file using the /pdf skill:

Spawn 3 subagents:
- Subagent 1: Use /pdf to extract text from contract-part1.pdf
- Subagent 2: Use /pdf to extract text from contract-part2.pdf  
- Subagent 3: Use /pdf to extract text from contract-part3.pdf
Then aggregate all results into a single summary.

The key is identifying truly independent work units. If you’re processing a directory of invoices with the pdf skill, each invoice processes independently. Spawn an agent per file, then combine outputs using a final aggregation agent.

Instruct the orchestrator to split the work across two subagents, each handling a batch of invoices:

Spawn two subagents:
- Subagent 1: Process invoices/invoice-001.pdf through invoice-010.pdf using /pdf
- Subagent 2: Process invoices/invoice-011.pdf through invoice-020.pdf using /pdf

Strategy Two: Hierarchical Agent Trees

Rather than flat parallelism, structure agents in a tree hierarchy. Parent agents delegate work to children and handle result aggregation. This reduces the coordination burden on any single agent.

Root Agent (coordinator)
├── Child Agent A (frontend)
│   ├── /frontend-design analyze components/
│   └── /frontend-design generate storybook/
└── Child Agent B (backend)
    ├── /tdd generate tests for api/
    └── /xlsx export database schema/

The root agent maintains context about what each child does, enabling intelligent task distribution. When the xlsx skill generates a spreadsheet report, the parent knows the output format and can route it appropriately without explicit hand-coding.

Strategy Three: Message Passing via Shared Memory

Agents need a communication channel beyond direct spawning. Shared memory files or a dedicated coordination skill enables message passing between agents.

Create a coordination file:

# coordination.txt
STATUS: processing
CURRENT_PHASE: 1_of_3
ACTIVE_AGENTS: ["agent-1", "agent-2", "agent-3"]
RESULTS: []

Each agent reads and writes to this file. The **supermemory** skill can track this state automatically, providing a cleaner interface than raw file operations.

# Agent 1 updates status
/supermemory store agent-1-status: completed processing 50 files

# Agent 2 retrieves progress
/supermemory What are the current statuses of all agents?

Strategy Four: Event-Driven Coordination

Trigger agent spawns based on file system events or message queue updates. This pattern works well for watch folders or continuous integration pipelines.

When a new PDF arrives in the watched directory, the orchestrator spawns a subagent:

A new file has arrived: {new_file}
Spawn a subagent to use /pdf to extract metadata from {new_file} and update index.json.

The pdf skill integrates cleanly here since it handles single-file and batch operations equally well. Combine with a file watcher, and you have an automated document processing pipeline.

Strategy Five: Checkpointing and Recovery

Long-running agent swarms need fault tolerance. Implement checkpoint logic so failed agents can resume without restarting the entire pipeline.

# checkpoint.json
{
  "completed_agents": ["agent-1", "agent-2"],
  "failed_agents": ["agent-3"],
  "pending_agents": ["agent-4", "agent-5"],
  "last_checkpoint": "2026-03-14T10:30:00Z"
}

When an agent fails, read the checkpoint, identify the failed agent, and spawn a replacement:

Subagent 3 failed on document-003.pdf at step 2.
Spawn a replacement subagent to resume processing document-003.pdf starting from step 2.

Practical Example: Documentation Pipeline

Consider generating documentation for a monorepo with multiple packages. Each package requires different handling:

  1. Frontend packages use the frontend-design skill for component documentation
  2. Backend packages use the tdd skill for API documentation
  3. Data packages use the xlsx skill for schema exports

The orchestrator coordinates the work and spawns specialized subagents:

Coordinate documentation generation across 5 packages:
- Spawn a frontend docs subagent: use /frontend-design to generate docs for ./packages/ui/
- Spawn a backend docs subagent: generate API documentation for ./packages/api/
- Spawn a data docs subagent: use /xlsx to export schemas from ./packages/data/

Each specialized agent operates independently, then the coordinator aggregates outputs into a unified documentation site.

Common Pitfalls to Avoid

Over-spawning creates resource contention. Start with two to four agents and scale based on observed performance. Claude Code agents consume memory and CPU; more isn’t always faster.

Ignoring shared state causes race conditions. If multiple agents write to the same file without coordination, you’ll lose data. Use file locking or the supermemory skill for atomic operations.

No timeout strategy leaves hung agents blocking progress. Set explicit timeout expectations:

Include explicit timeout instructions in your subagent prompts:

Process this file. If you cannot complete within 60 seconds, report failure and stop.

Skill Recommendations for Coordination

Several skills enhance multi-agent workflows:

The docx skill also proves valuable when generating coordination reports or status documents that agents share during execution.

Conclusion

Agent swarm coordination transforms Claude Code from a single assistant into a parallel processing platform. Start with the fan-out/fan-in pattern for independent tasks, scale to hierarchical trees for complex projects, and implement checkpointing for production reliability. The key insight: treat agents as disposable workers that communicate through structured channels, and your automation pipelines will scale horizontally with minimal overhead.

Built by theluckystrike — More at zovo.one