Inside Claude Code's Multi-Agent Orchestration System
Claude Code's AgentTool orchestrates sync, async, fork, teammate and remote agents via git worktree isolation for reliable parallel AI coding.
Claude Code now ships production-ready multi-agent orchestration built around a single abstraction called AgentTool, which spawns and routes communication across five agent types: sync subagents, async agents, fork subagents, teammates, and remote agents running on separate Claude Code Runner environments.
The choice of pattern determines whether agents help or hinder each other. Sync subagents block the parent until they return a result, making them suited for dependent steps like running tests before deciding on fixes, while async agents launch in the background and let independent tasks — implementing an endpoint, writing tests, updating docs — run concurrently and merge back once finished.
Underpinning parallel execution is git worktree isolation: every spawned agent works in its own directory sharing the same .git history but an independent set of files, preventing corrupted state when multiple agents touch overlapping code. The lead agent handles merge conflicts explicitly after child agents complete, and worktrees with no changes are cleaned up automatically.
Fork subagents add a caching optimization, inheriting the parent's system prompt so API request prefixes stay cache-identical, reducing latency and cost at the expense of carrying irrelevant context; a built-in recursion guard caps nesting depth to prevent runaway spawning. For teams building on Claude Code, these primitives turn agent orchestration from an ad hoc pattern into a documented, production-grade capability.