Skip to main content
Claude Code v2.1.88 is a production-grade AI coding agent built on a layered architecture. The core agent loop is simple — send messages to the Claude API, execute tools, loop back — but a multi-layer harness wraps it with permissions, streaming, concurrency, compaction, sub-agents, persistence, and MCP.

Layer Diagram

The Four Main Layers

Entry Layer

cli.tsx parses CLI flags and version info, then delegates to main.tsx. From there, the app forks: interactive sessions render with React/Ink via REPL.tsx, while SDK/headless consumers go through QueryEngine.ts.

Query Engine

The SDK-facing lifecycle engine. submitMessage() returns an AsyncGenerator<SDKMessage> that drives the full agent loop — assembling prompts, handling slash commands, streaming tool execution, and compacting context.

Three Pillars

Tool System — 40+ tools behind a uniform Tool<Input, Output, Progress> interface. Service Layer — API client, compact engine, MCP manager, analytics. State LayerAppStateStore providing React context for permissions, file history, and model settings.

Task & Bridge Layer

Tasks represent long-running work: local_bash, local_agent, remote_agent, in_process, dream, and workflow. The Bridge Layer (bridgeMain.ts) connects to Claude Desktop or remote containers via HTTP with JWT auth and backoff.

Key Design Patterns

Directory Reference

The 12 Progressive Harness Mechanisms

Claude Code layers 12 production mechanisms on top of the basic agent loop. Each builds on the previous: