$npx -y skills add NeoLabHQ/context-engineering-kit --skill multi-agent-patternsDesign multi-agent architectures for complex tasks. Use when single-agent context limits are exceeded, when tasks decompose naturally into subtasks, or when specializing agents improves quality.
| 1 | # Multi-Agent Architecture Patterns for Claude Code |
| 2 | |
| 3 | Multi-agent architectures distribute work across multiple agent invocations, each with its own focused context. When designed well, this distribution enables capabilities beyond single-agent limits. When designed poorly, it introduces coordination overhead that negates benefits. The critical insight is that sub-agents exist primarily to isolate context, not to anthropomorphize role division. |
| 4 | |
| 5 | ## Core Concepts |
| 6 | |
| 7 | Multi-agent systems address single-agent context limitations through distribution. Three dominant patterns exist: supervisor/orchestrator for centralized control, peer-to-peer/swarm for flexible handoffs, and hierarchical for layered abstraction. The critical design principle is context isolation—sub-agents exist primarily to partition context rather than to simulate organizational roles. |
| 8 | |
| 9 | Effective multi-agent systems require explicit coordination protocols, consensus mechanisms that avoid sycophancy, and careful attention to failure modes including bottlenecks, divergence, and error propagation. |
| 10 | |
| 11 | ## Why Multi-Agent Architectures |
| 12 | |
| 13 | ### The Context Bottleneck |
| 14 | |
| 15 | Single agents face inherent ceilings in reasoning capability, context management, and tool coordination. As tasks grow more complex, context windows fill with accumulated history, retrieved documents, and tool outputs. Performance degrades according to predictable patterns: the lost-in-middle effect, attention scarcity, and context poisoning. |
| 16 | |
| 17 | Multi-agent architectures address these limitations by partitioning work across multiple context windows. Each agent operates in a clean context focused on its subtask. Results aggregate at a coordination layer without any single context bearing the full burden. |
| 18 | |
| 19 | ### The Parallelization Argument |
| 20 | |
| 21 | Many tasks contain parallelizable subtasks that a single agent must execute sequentially. A research task might require searching multiple independent sources, analyzing different documents, or comparing competing approaches. A single agent processes these sequentially, accumulating context with each step. |
| 22 | |
| 23 | Multi-agent architectures assign each subtask to a dedicated agent with a fresh context. All agents work simultaneously, then return results to a coordinator. The total real-world time approaches the duration of the longest subtask rather than the sum of all subtasks. |
| 24 | |
| 25 | ### The Specialization Argument |
| 26 | |
| 27 | Different tasks benefit from different agent configurations: different system prompts, different tool sets, different context structures. A general-purpose agent must carry all possible configurations in context. Specialized agents carry only what they need. |
| 28 | |
| 29 | Multi-agent architectures enable specialization without combinatorial explosion. The coordinator routes to specialized agents; each agent operates with lean context optimized for its domain. |
| 30 | |
| 31 | ## Architectural Patterns |
| 32 | |
| 33 | ### Pattern 1: Supervisor/Orchestrator |
| 34 | |
| 35 | The supervisor pattern places a central agent in control, delegating to specialists and synthesizing results. The supervisor maintains global state and trajectory, decomposes user objectives into subtasks, and routes to appropriate workers. |
| 36 | |
| 37 | ``` |
| 38 | User Request -> Supervisor -> [Specialist A, Specialist B, Specialist C] -> Aggregation -> Final Output |
| 39 | ``` |
| 40 | |
| 41 | **When to use:** Complex tasks with clear decomposition, tasks requiring coordination across domains, tasks where human oversight is important. |
| 42 | |
| 43 | **Advantages:** Strict control over workflow, easier to implement human-in-the-loop interventions, ensures adherence to predefined plans. |
| 44 | |
| 45 | **Disadvantages:** Supervisor context becomes bottleneck, supervisor failures cascade to all workers, "telephone game" problem where supervisors paraphrase sub-agent responses incorrectly. |
| 46 | |
| 47 | **Claude Code Implementation:** Create a main command that orchestrates by calling specialized subagents using the Task tool. The supervisor command contains the coordination logic and calls subagents for specialized work. |
| 48 | |
| 49 | ```markdown |
| 50 | <!-- Example supervisor command structure --> |
| 51 | 1. Analyze the user request and decompose into subtasks |
| 52 | 2. For each subtask, dispatch to appropriate specialist: |
| 53 | - Use Task tool to spawn subagent with focused context |
| 54 | - Pass only relevant context to each subagent |
| 55 | 3. Collect and synthesize results from all subagents |
| 56 | 4. Return unified response to user |
| 57 | ``` |
| 58 | |
| 59 | **The Telephone Game Problem:** Supervisor architectures can perform worse when supervisors paraphrase sub-agent responses incorrectly, losing fidelity. The fix: allow sub-agents to pass responses directly when synthesis would lose important details. In Claude Code, this means letting subagents write directly to shared files or return their output verbatim rather than having the supervisor rewrite everything. |
| 60 | |
| 61 | ### Patt |