Skip to content

Claude Code Multi-Agent System Documentation

Complete guide and technical reference for multi-agent orchestration


Documentation Index

01-usage-guide.md — Usage Guide

A comprehensive user-facing manual covering:

  • Agent Tool: Parameter reference, spawn methods, background execution
  • Six Built-in Agents: general-purpose, Explore, Plan, verification, claude-code-guide, statusline-setup
  • Background Tasks: Asynchronous execution, progress tracking, completion notifications
  • Agent Teams: Team creation, member collaboration, message communication
  • Worktree Isolation: Independent environments, branch management, secure contexts
  • Custom Agents: Definition format, tool pool configuration, system prompts

Target Audience: All Claude Code users


02-implementation.md — Implementation Details

A deep technical reference for developers covering:

  • Architecture Overview: 5 agent categories, 4 spawn paths
  • Agent Spawn Flow: Detailed walkthrough of Sync / Async / Fork / Teammate paths
  • Tool Pool System: Three-layer filtering, constant definitions, permission mapping
  • Context Passing: CacheSafeParams, system prompt construction, fork cache optimization
  • Teams Internals: TeamFile structure, mailbox system, inbox polling, message routing
  • Background Task Engine: LocalAgentTask lifecycle, progress tracking, notification queue
  • Permission Synchronization: Team-level permissions, mode propagation, bubble mode
  • End-to-End Data Flow: From Agent Tool invocation to result delivery

Target Audience: Contributors, architects, and developers seeking deep implementation understanding


03-agent-framework.md — Agent Framework Deep Dive

Deconstructing the architecture behind Claude Code's agent framework from source code, covering:

  • Core Agent Loop: AsyncGenerator state machine, five-phase while(true) loop
  • System Prompt Engineering: Layered construction, cache boundary, CLAUDE.md loading
  • Tool System Design: Full lifecycle management, three-stage registration, 7-step execution pipeline
  • Context Management & Compression: Four-level progressive compression, system context injection
  • Skills & Plugin Ecosystem: Skill definition and discovery, plugins, hooks, MCP integration
  • Permission & Security Model: Layered permission model, rule pattern matching
  • Fault Recovery Mechanisms: 6 built-in recovery strategies, model fallback
  • Comparison with LangChain/ReAct: Architecture paradigm differences, why not ReAct
  • Why Claude Code Is So Good: 7 core design principles

Target Audience: Architects studying AI agent design, AI application developers, technical researchers


Illustration Notes

All diagrams use a dark background (#1a1a2e) with Anthropic brand copper-orange (#D97757), consistent with Claude Code's official documentation style.

ImageDescriptionDocument
01-agent-overview.pngMulti-Agent System Overview — Architecture panoramaUsage Guide
02-agent-types.pngSix Built-in Agents — Type comparison matrixUsage Guide
03-spawn-flow.pngAgent Spawn Flow — Four-path decision treeUsage Guide
04-agent-teams.pngAgent Teams Collaboration — Team communication topologyUsage Guide
05-architecture.pngImplementation Architecture — Core module relationshipsImplementation
06-context-passing.pngContext Passing — CacheSafeParams data flowImplementation
07-tool-pool.pngTool Pool System — Three-layer filtering pipelineImplementation
08-background-task.pngBackground Task Engine — Lifecycle state machineImplementation
09-teams-mailbox.pngTeams Mailbox System — Message routing topologyImplementation
10-fork-cache.pngFork Cache Optimization — Byte-level consistent sharingImplementation
11-agent-framework-overview.pngAgent Framework Overview — Core component relationshipsFramework Deep Dive
12-agent-core-loop.pngCore Agent Loop — Five-phase state machineFramework Deep Dive
13-system-prompt-pipeline.pngSystem Prompt Pipeline — Layered cache pipelineFramework Deep Dive
14-context-compression.pngContext Compression — Four-level progressive strategyFramework Deep Dive

Quick Start

For Users

  1. Read the Usage Guide
  2. Learn about the six built-in agents and their use cases
  3. Try spawning subagents using the Agent tool in a conversation
  4. Explore multi-agent collaboration with Agent Teams

For Developers

  1. Read the Implementation Details
  2. Browse the source code:
    • src/tools/AgentTool/ — Agent tool implementation
    • src/tools/TeamCreateTool/ — Team creation
    • src/tools/SendMessageTool/ — Inter-agent communication
    • src/utils/swarm/ — Swarm collaboration infrastructure
    • src/utils/forkedAgent.ts — Fork agent context
    • src/tasks/ — Task management system
  3. Understand the four spawn paths and context passing mechanisms

Core Concepts Quick Reference

ConceptDescription
Agent ToolPrimary entry point — accepts a prompt + subagent_type to spawn a subagent
SubagentAn independent child agent that executes tasks with its own tool pool and permissions
Fork AgentA forked agent that inherits the parent's full context and shares prompt cache
TeammateA collaborative member within an Agent Team, communicating via mailbox
WorktreeGit worktree isolation mode providing an independent file environment
LocalAgentTaskLocal agent task state, tracking running/completed/failed status
DreamTaskAutomatic memory consolidation task that runs periodically in the background
CacheSafeParamsCache-safe parameters ensuring byte-level consistency of API request prefixes
TeamFileTeam configuration file storing the member list and permissions
MailboxFile-based message queue supporting asynchronous communication between teammates

Released under the MIT License.