Claude Code supports full multi-agent coordination in 2026 — sync and async subagents, git worktree isolation, fork subagents with cache-identical prefixes, named teammates with direct messaging, and remote agents in separate environments. Here is exactly how each pattern works and when to use it.
Claude Code’s multi-agent system lets you orchestrate multiple AI agents that work in parallel across isolated git worktrees, communicate directly with each other, and merge their results back into your codebase — all from a single terminal session. This is not a theoretical capability. It is production-ready infrastructure that ships with Claude Code today, and an experimental agent teams feature that takes coordination further. This guide covers every agent pattern available, when to use each one, and the practical configurations that make parallel AI coding work reliably.
The Core Primitive: AgentTool
Every multi-agent capability in Claude Code flows through a single abstraction called AgentTool. AgentTool is the orchestrator that spawns, manages, and routes communication between agents. It supports five distinct agent types, each optimized for different coordination patterns:
- Sync subagents — blocking execution, parent waits for child to finish
- Async agents — background execution, parent gets notified on completion
- Fork subagents — inherit parent context for cache-identical API prefixes
- Teammates — named agents with direct inter-agent message routing
- Remote agents — separate Claude Code Runner (CCR) environments
Understanding which pattern fits your task is the difference between agents that coordinate smoothly and agents that block each other, duplicate work, or produce merge conflicts. Let us walk through each one in detail.
Sync Subagents: The Blocking Pattern
Sync subagents are the simplest multi-agent pattern. The parent agent spawns a child agent and blocks — completely pausing its own execution — until the child returns a result. This is the default behavior when you ask Claude Code to delegate a task to a subagent without specifying otherwise.
When you tell Claude Code something like “run the test suite and fix any failures,” the lead agent may spawn a sync subagent to execute the tests, wait for the results, then decide what to do next based on the output. The parent agent’s context remains untouched while the child works. When the child finishes, the parent receives a structured result and continues its own task with full awareness of what happened.
When to use sync subagents: Tasks where the parent genuinely cannot proceed without the child’s output. Test execution before deciding on fixes. Linting a file before committing it. Running a build to verify compilation before moving to the next module. Any workflow where step N depends on the result of step N-1.
When not to use sync subagents: Tasks that could run in parallel. If you have three independent modules to implement, spawning them as sync subagents means each one runs sequentially — tripling the wall-clock time for no benefit. Use async agents or teammates instead.
Sync subagents also have an automatic background transition. If a sync subagent runs longer than a configured threshold, it transitions to background execution automatically. This prevents a single slow child from locking the parent indefinitely. The parent gets notified when the background task completes and can resume processing the result.
Async Agents: Background Execution
Async agents return immediately after spawning. The parent agent continues its own work without waiting for the child to finish. When the async agent completes, the parent receives a notification with the result.
This is the pattern you want for parallel work. Suppose you need to implement a new API endpoint, write tests for it, and update the documentation. With async agents, the lead agent spawns three background workers — one for the endpoint, one for tests, one for docs — and all three run simultaneously. Each agent works in its own isolated git worktree (more on this below), so there are no file conflicts. When all three finish, the lead agent reviews and merges the results.
The practical speedup is significant. Three tasks that take 60 seconds each run in 60 seconds total with async agents instead of 180 seconds with sync subagents. For development workflows involving multiple independent files or modules, this is the pattern that delivers the most visible productivity gain.
When to use async agents: Independent tasks with no data dependencies. Implementing separate components in parallel. Running a code reviewer agent alongside a test runner agent. Any situation where multiple pieces of work can proceed without waiting for each other.
Git Worktree Isolation: How Agents Avoid Conflicts
The most critical infrastructure enabling multi-agent coordination is git worktree isolation. Every agent that Claude Code spawns gets its own git worktree — a separate working directory that shares the same .git history as your main repository but has a completely independent set of working files.
This solves the fundamental problem of parallel AI coding: if two agents edit the same file simultaneously in the same directory, you get corrupted state. With worktree isolation, Agent A edits src/api/routes.ts in /tmp/worktree-a/src/api/routes.ts while Agent B edits the same file in /tmp/worktree-b/src/api/routes.ts. Both agents see the full repository history and can read any existing file, but their writes are isolated.
Worktree isolation has several practical implications that affect how you structure multi-agent tasks:
- Shared history, isolated state: All worktrees share the same
.gitdirectory. An agent in worktree B can see commits made by Agent A if Agent A commits first. But uncommitted changes in one worktree are invisible to all other worktrees. - Automatic cleanup: If an agent finishes without making any changes, its worktree is cleaned up automatically. No manual garbage collection of temporary directories.
- Branch management: Each worktree can operate on a different branch. The lead agent manages the merge strategy after all child agents complete.
- Merge resolution: When agents working in parallel modify overlapping files, the lead agent handles merge conflicts during the integration step. This is not automatic — the lead agent applies its judgment to resolve conflicts based on the intent of each child agent’s changes.
If you have worked with structured data tools where multiple transformations need to happen without interfering, the worktree pattern follows the same principle: isolate side effects, merge results explicitly.
Fork Subagents: Cache-Optimized Delegation
Fork subagents are a performance optimization for a specific scenario: when you want a child agent to inherit the parent’s system prompt and initial context so that the API request prefix is cache-identical.
Here is why this matters. Claude’s API caches prompt prefixes. If two requests share an identical prefix — same system prompt, same initial messages — the second request reuses the cached KV computation from the first, reducing latency and cost. Fork subagents exploit this by inheriting the parent agent’s full system prompt, creating a cache-identical prefix that hits the warm cache on the API side.
In practice, this means fork subagents start faster and cost less per token than agents spawned with independent system prompts. The tradeoff is that fork subagents carry the parent’s full context, which may include information irrelevant to the child’s specific task. For narrowly-scoped tasks where context efficiency matters more than cache optimization, a regular sync or async agent with a tailored prompt may produce better results.
Recursive fork guard: Fork subagents include a built-in recursion guard that prevents infinite nesting. A forked agent cannot fork another agent that forks another agent indefinitely. The system enforces a maximum nesting depth. This is a safety mechanism that prevents runaway agent spawning from consuming unbounded resources.
When to use fork subagents: When you need to delegate a subtask that benefits from the parent’s full context — reviewing code that the parent has already analyzed, running a validation step that needs the same architectural understanding, or splitting a large task into phases where each phase needs awareness of the overall plan.
Agent Teams: The Experimental Frontier
Agent teams are the most powerful coordination pattern available in Claude Code, enabled through the experimental flag CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS. While sync/async subagents follow a strict parent-child hierarchy, agent teams create a flat coordination structure where multiple named agents work independently with their own context windows, their own worktrees, and the ability to communicate directly with each other.
The architecture works like this:
- One lead agent coordinates the overall task and delegates work to teammates
- Multiple teammates each operate in their own context window and git worktree
- Direct communication between any two agents via the
SendMessagetool, routed by agent name - Independent execution — each teammate works on their assigned subtask without blocking others
The key difference from async subagents is the communication model. Async subagents report back to the parent when done. Teammates can message each other at any point during execution. This enables coordination patterns that are impossible with pure parent-child hierarchies — for example, the documentation agent asking the API implementation agent about the shape of a response type while both are still working.
Named Agents and Message Routing
Agent teams use a named agent registry to enable targeted communication. When a teammate is spawned, it registers a human-readable name (like “test-runner” or “api-implementer”) that maps to an internal agent ID. Any agent in the team can then use SendMessage with the target agent’s name to deliver a message directly.
This naming system supports ongoing collaboration. An agent named “code-reviewer” can receive messages from the lead agent asking it to review specific files, from the “test-runner” agent reporting failures that suggest code issues, or from the “api-implementer” agent asking for a quick review of a tricky function before committing. The communication graph is fully connected — any agent can message any other agent by name.
Practical Agent Team Configuration
To enable agent teams, set the environment variable before launching Claude Code:
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
claudeOnce enabled, the lead agent gains the ability to spawn named teammates and route messages between them. A typical team for a feature implementation might look like this:
- Lead agent: Breaks down the feature, assigns subtasks, reviews and merges results
- “implementer”: Writes the core feature code in an isolated worktree
- “test-writer”: Writes comprehensive tests based on the feature spec, running in parallel
- “reviewer”: Reviews code from both the implementer and test-writer, sending feedback via SendMessage
The lead agent orchestrates the sequence: implementer and test-writer start simultaneously, reviewer begins once initial code is committed, and the lead merges all worktrees when the team signals completion.
MCP Server Requirements for Agents
Agents in Claude Code can declare dependencies on specific MCP (Model Context Protocol) servers. This is particularly relevant for agents that need access to external tools — a database query server, a deployment API, a documentation search tool, or any other MCP-compatible service.
When an agent declares a required MCP server, the system checks whether that server is available before the agent begins execution. If the server is pending (starting up, not yet connected), the system waits up to 30 seconds, polling every 500 milliseconds, for the server to become available. If the server does not become available within the timeout, the agent receives an error rather than silently proceeding without the required tool.
This dependency declaration mechanism is important for reliable multi-agent workflows. Consider a team where the “implementer” agent needs access to a database schema MCP server and the “test-writer” agent needs access to a test execution MCP server. Each agent declares its requirements, and the system ensures the right servers are available to the right agents before work begins. Without this, agents would fail mid-execution when they try to invoke a tool that is not available — wasting context window tokens and wall-clock time on work that cannot complete.
For developers who use MCP servers extensively — and if you are building with tools like Google’s A2A protocol alongside Claude Code, you likely are — the server requirement system ensures that multi-agent coordination does not break because of missing tool dependencies.
Remote Agents: Separate CCR Environments
Remote agents run in entirely separate Claude Code Runner (CCR) environments. Unlike local subagents that share the same machine and file system (with worktree isolation), remote agents operate on separate infrastructure with their own compute resources, file systems, and network contexts.
Remote agents are designed for scenarios where task isolation goes beyond file-level separation. Running untrusted code, executing long-running builds that should not consume local resources, or performing operations that require different system dependencies (like a different Node.js version or a specific database setup) are all cases where remote agents provide value over local subagents.
The coordination model for remote agents follows the same pattern as async agents: the parent spawns the remote agent, continues working, and receives a notification when the remote agent completes. The key difference is that the remote agent’s environment is fully independent — it does not share the local .git directory, worktrees, or file system. Results must be explicitly transferred back, typically through git commits pushed to a shared remote repository.
Building a Practical Multi-Agent Workflow
Let us build a concrete example: implementing a new feature with automated code review, testing, and documentation — all running in parallel.
Step 1: Define the Task Decomposition
The lead agent receives the feature request and breaks it into independent subtasks. The critical judgment here is identifying which tasks have data dependencies (must run sequentially) and which are independent (can run in parallel). For a typical feature:
- Core implementation: depends on nothing, can start immediately
- Test writing: depends on the interface contract (function signatures, types), not the implementation details
- Documentation: depends on the interface contract and high-level behavior description
- Code review: depends on implementation being complete
This means implementation, test writing, and documentation can all start in parallel if the lead agent first establishes the interface contract (types, function signatures, expected behavior) and shares it with all agents.
Step 2: Spawn Async Agents with Worktree Isolation
The lead agent spawns three async agents, each receiving the interface contract and their specific instructions. Each agent gets an isolated worktree. All three begin working simultaneously.
The implementer writes the feature code. The test writer writes unit and integration tests against the interface contract. The documentation writer updates API docs and adds usage examples. None of them block each other. If the test writer needs clarification about an edge case, they can send a message to the implementer via SendMessage (if agent teams are enabled) or flag it for the lead agent to resolve.
Step 3: Sequential Review and Integration
Once all three async agents complete, the lead agent spawns a sync subagent for code review. This is intentionally sequential — the reviewer needs the completed implementation and tests to provide meaningful feedback. The reviewer checks for type safety, error handling, edge cases, and consistency between the implementation and tests.
If the reviewer identifies issues, the lead agent can spawn additional async agents to fix specific problems in parallel, or handle small fixes itself. Once the review passes, the lead agent merges all worktrees into the main branch, resolving any conflicts.
Step 4: Final Verification
A final sync subagent runs the full test suite against the merged code, verifying that the parallel work integrates correctly. This is the gate before the lead agent reports the task as complete.
This entire workflow — implementation, testing, documentation, review, and verification — runs in roughly the time of the longest single task plus the sequential review and verification steps. For a feature that takes 3 minutes to implement, 2 minutes to test-write, and 1 minute to document, the parallel phase takes 3 minutes instead of 6. The sequential review and verification add another 2 minutes. Total: 5 minutes instead of 8+ minutes for fully sequential execution.
Agent Coordination Patterns That Work
After extensive use of Claude Code’s multi-agent system in production codebases, several coordination patterns consistently deliver results:
The Scout-Implement-Verify Pattern
Spawn a sync “scout” agent first to analyze the codebase and produce a plan. Then spawn async agents to implement different parts of the plan in parallel. Finally, run a sync verification agent to confirm everything works together. This pattern works well for refactoring tasks, where understanding the existing code is a prerequisite for safe changes. The comparison to how you might use different AI coding tools for different phases of work is direct — except here, the same tool handles all phases with native coordination.
The Continuous Reviewer Pattern
With agent teams enabled, spawn a named “reviewer” agent that runs continuously alongside the implementation agents. Every time an implementer commits code to their worktree, they message the reviewer. The reviewer provides feedback in near-real-time, catching issues before they propagate. This mimics the experience of pair programming but with an AI reviewer that can examine the entire codebase context.
The Specialist Team Pattern
For complex features that span multiple domains — frontend, backend, database migrations, API contracts — spawn specialist agents with domain-specific instructions. A “frontend-specialist” agent receives the UI design spec and component requirements. A “backend-specialist” agent receives the API contract and data model. A “migration-specialist” agent handles database schema changes. All three work in parallel in isolated worktrees. The lead agent coordinates the merge order (migrations first, then backend, then frontend) to maintain consistency.
Performance Considerations and Limits
Multi-agent coordination in Claude Code is not free. Each agent consumes its own context window, which means API token costs scale linearly with the number of agents. Three parallel agents use roughly three times the tokens of a single agent working sequentially. The tradeoff is wall-clock time: you pay more in tokens but finish faster.
Practical limits to be aware of:
- Context window per agent: Each agent has its own context window. Large codebases may require careful scoping of what each agent reads to stay within limits.
- Worktree overhead: Each worktree creates a full copy of the working directory (not the
.gitdirectory, which is shared). On repositories with large untracked files or build artifacts, this can consume significant disk space. - Merge complexity: The more agents that modify overlapping files, the more complex the merge step becomes. Structuring tasks so agents work on non-overlapping file sets dramatically simplifies integration.
- MCP server connections: Each agent that requires MCP servers maintains its own connections. Server-side connection limits may constrain the number of agents that can run simultaneously if they all need the same external tool.
The optimal number of parallel agents depends on your specific workflow. For most development tasks, 2–4 parallel agents hit the sweet spot between speedup and coordination overhead. Beyond 4 agents, the merge complexity and lead agent coordination burden often outweigh the wall-clock time savings.
Comparison: Claude Code Multi-Agent vs. Other Approaches
The multi-agent pattern in Claude Code is distinct from other AI coding tool approaches in 2026:
Cursor and GitHub Copilot operate as single-agent assistants embedded in an editor. They do not natively support spawning background agents, worktree isolation, or inter-agent communication. You can open multiple editor windows, but there is no coordination layer. For a detailed breakdown of these tools, read our Claude Code vs Cursor vs GitHub Copilot comparison.
Custom LangChain/CrewAI agent frameworks require you to build the orchestration, tool access, and state management yourself. Claude Code provides this infrastructure out of the box, with git worktree isolation and the AgentTool abstraction handling the mechanics. The tradeoff is flexibility: custom frameworks let you orchestrate any model from any provider, while Claude Code’s agents use Claude exclusively.
Google’s A2A protocol is an open standard for inter-agent communication across different platforms and providers. Claude Code’s agent teams are a closed system — all agents are Claude instances coordinated within the Claude Code runtime. A2A aims for cross-platform interoperability. These are complementary rather than competing approaches — you might use Claude Code agent teams for implementation work and A2A for broader system orchestration. See our A2A protocol developer guide for the full picture.
Common Mistakes and How to Avoid Them
Several patterns consistently cause problems in multi-agent Claude Code workflows:
Over-parallelizing tightly coupled tasks. If three subtasks all modify the same core file, running them in parallel guarantees merge conflicts. Identify shared files upfront and either assign them to a single agent or structure the work so agents add to different sections of the file.
Under-specifying agent instructions. Each agent only knows what you tell it. A vaguely instructed async agent will interpret the task differently than the lead agent intended, producing code that does not integrate well. Invest time in clear, specific instructions for each agent — include the interface contract, coding conventions, and expected output format.
Ignoring the merge step. The merge is where parallel agent work succeeds or fails. Build the merge step into your workflow explicitly. Do not assume that because agents worked in isolated worktrees, their outputs will combine cleanly. Test the merged result.
Using agent teams for simple tasks. If a task takes one agent 30 seconds, spawning a four-agent team to do it adds coordination overhead that makes it slower, not faster. Multi-agent coordination shines on tasks that take minutes, involve multiple independent files or modules, and benefit from parallel execution. For quick fixes and single-file changes, a single agent is faster.
Getting Started: Minimum Viable Multi-Agent Setup
If you want to start using multi-agent coordination today, here is the minimum setup:
- Install Claude Code if you have not already:
npm install -g @anthropic-ai/claude-code - Enable agent teams (optional, for named agents and SendMessage):
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 - Structure your task as a set of independent subtasks that can run in parallel
- Tell Claude Code to break the work into parallel agents: “Implement the API endpoint, tests, and documentation in parallel using separate agents”
Claude Code handles the worktree creation, agent spawning, and result merging. You can also configure agent behavior through your CLAUDE.md file — the project-level instructions file that every Claude Code agent reads before starting work. Adding multi-agent guidance to your CLAUDE.md (like “use parallel agents for changes spanning 3+ files” or “always spawn a verification agent after multi-file edits”) shapes how the lead agent decides to coordinate.
Conclusion
Claude Code’s multi-agent system in 2026 provides five distinct coordination patterns — sync subagents, async agents, fork subagents, named teammates, and remote agents — each designed for specific workflow requirements. Git worktree isolation solves the fundamental parallel editing problem. The experimental agent teams feature enables direct inter-agent communication that goes beyond simple parent-child delegation. And MCP server requirement declarations ensure agents have the tools they need before they start working.
The practical value is straightforward: tasks that involve multiple independent modules, files, or concerns run faster when agents work in parallel. The coordination overhead is real but manageable. Start with two parallel agents on a task you know well, verify the merge, and expand from there. Multi-agent coordination is not a silver bullet — it is a multiplier that works best on tasks that are naturally parallelizable. For the right tasks, it cuts wall-clock time in half or better while maintaining code quality through structured review and verification. Explore our developer tools for utilities that complement AI-assisted coding workflows, and read our AI coding tools comparison for the broader landscape of tools available to developers in 2026.