Claude Code's architecture, mapped.
Calude Code is one of the most powerful agent harnessed out there, it's a lot more than "a CLI that calls claude." the actual system has six layers, and the model is just one node inside the loop.
the diagram breaks down every component:
๐๐ป๐ฝ๐๐ ๐๐ฎ๐๐ฒ๐ฟ handles session management, permission gating, and YAML-based trust tiers before anything reaches the model.
๐๐ป๐ผ๐๐น๐ฒ๐ฑ๐ด๐ฒ ๐๐ฎ๐๐ฒ๐ฟ holds the skill registry, context compressor (3-layer, 92% threshold), task graph, and cross-session memory store. this is where harness intelligence lives outside the weights.
๐๐ ๐ฒ๐ฐ๐๐๐ถ๐ผ๐ป ๐๐ฎ๐๐ฒ๐ฟ runs tool dispatch through a typed registry with one handler per tool. bash, read, write, grep, glob, revert. streaming runtime handles parallel execution. prompt cache reuses stable prefixes at 10% cost.
๐๐ป๐๐ฒ๐ด๐ฟ๐ฎ๐๐ถ๐ผ๐ป ๐๐ฎ๐๐ฒ๐ฟ connects the MCP runtime to external servers. filesystem, git, custom. tools register inward, memory writes outward to agent_memory. md.
๐ ๐๐น๐๐ถ-๐๐ด๐ฒ๐ป๐ ๐๐ฎ๐๐ฒ๐ฟ is the most underappreciated piece. subagent spawner, teammate mailboxes over redis pub/sub, FSM protocol (IDLEโREQUESTโWAITโRESPOND), autonomous board with atomic locks, and worktree isolation with per-task branches and conflict detection on merge.
๐ข๐ฏ๐๐ฒ๐ฟ๐๐ฎ๐ฏ๐ถ๐น๐ถ๐๐ ๐๐ฎ๐๐ฒ๐ฟ wraps everything. event bus with lifecycle hooks, background executor running daemon threads non-blocking.
the master agent loop sits at the center. perception โ action โ observation. it's deliberately simple. a "dumb loop" where the model reasons and the harness mediates.
this is the architecture behind what feels like magic when you use claude code. it's not magic. it's harness engineering.
the article below is a deep-dive covering how Anthropic, OpenAI, LangChain, and others build this pattern from the ground up.