Dive into Claude Code
A source-level architectural analysis of Claude Code's roughly 512,000 lines of TypeScript, arguing that only a small fraction is AI decision logic while the rest is deterministic infrastructure, packaged with a design guide for agent builders.
Dive into Claude Code is a research repository built around a detailed architectural analysis of Claude Code's source code, spanning about 1,900 TypeScript files and 512,000 lines. Its central finding is that only 1.6% of the codebase implements AI decision logic; the agent loop itself is a simple while-loop, and the remaining 98.4% is deterministic infrastructure such as permission gates, context management, tool routing and recovery logic that does the real engineering work.
It traces every design choice back to five underlying values and thirteen implementation principles, covering the agentic query loop, safety and permission handling, extensibility, context and memory management, subagent delegation and session persistence, and separately documents two CVEs where extensions could execute before a trust dialog appeared. Beyond the paper's own content, the repository adds a design-space guide for anyone building their own AI agent system, a cross-system comparison against OpenClaw and Hermes-Agent, and a curated collection of community analyses and related projects.
It accompanies a published arXiv paper and is organized as a reading guide tailored to different audiences, from agent builders to security researchers.