Claude Code Design

Reverse-engineer Claude Code — the reference agent harness — to extract design principles for building your own.

Overview
All readers — reverse-engineer Claude Code as a reference agent harness; extract design principles that transfer to your own agent.
System Prompt Assembly
Agent system authors — Claude Code's system prompt is a 20-section registry with an explicit static/dynamic boundary. Unpack the real code that does the layering.
Compaction
Agent system authors — Claude Code's compaction isn't one function; it's a five-tier pipeline (microcompact, session memory, auto-compact, reactive, context collapse), each solving a different problem.
Memory System
Agent system authors — Claude Code's memory in source is 6 file types × 4 content types × 3 agent-persistence scopes; unpacking each layer's responsibility and implementation.
Agent Execution Loop
Agent system authors — what actually happens when a Claude Code conversation runs: the query async generator, the 14-step per-turn pipeline, StreamingToolExecutor, retry / recovery / circuit-break paths, all source-grounded.
Permissions
Agent system authors — Claude Code's permission system is 7 modes × 8 rule sources × 11 decision reasons × 10 hook events; unpacking each layer in the source.
Execution Environment
Agent system authors — where does the agent actually run? Which machine, which directory, which sandbox container? Claude Code's 3 isolation modes (none / worktree / remote) + cross-platform process sandbox + CCR cloud architecture.
Design Lessons
Agent system authors — ten cross-cutting principles distilled from the source-grounded chapters, each tied to specific source files; a checklist for evaluating your own agent's design.
Applying to Your Agent (AI SDK)
Agent system authors (AI SDK users) — when building an agent with AI SDK, where each prior-chapter principle lands in the 8 embedding points. Uses Zapvol as the evaluated case with current-state assessment and evolution roadmap.
Lifecycle State Flow
Agent system authors — the 8 embedding points aren't 8 isolated hooks; they share a state that flows across steps, calls, and sessions. This chapter traces one full conversation's state evolution end-to-end.