Tous les signals
AI AgentsClaude Code

Inside Claude Code: What 512K Lines Revealed

Publié le April 2, 2026
Inside Claude Code: architecture, context and memory layers, and unreleased features found in the leaked 512K-line codebase

Three weeks ago, I published a breakdown of Claude Code's architecture based on Anthropic's docs and community reverse-engineering.

Then on March 31 (2 days ago), a source map accidentally leaked the entire codebase. 512,000 lines of TypeScript.

The visible architecture was about 60% accurate. But what was hidden underneath turned out to be far more interesting.

The engine.

The core is a QueryEngine that runs as a state machine with retry logic, streaming, and token budget management. The while loop I described in my previous post was correct in principle, but the real implementation goes much further.

60+ registered tools. Not 5 like I wrote. BashTool, FileEditTool, AgentTool, GrepTool, LSPTool, WebSearchTool, NotebookTools, MultiEditTool...

Context.

4 layers of compaction. AutoCompact triggers near the context ceiling with a 13,000-token buffer. MicroCompact compresses tool results without API calls. Snip Compaction and Context Collapse for deeper resets, with a lightweight MEMORY.md index always loaded, topic files fetched on-demand, raw transcripts grep-searched only when needed.

Features found in the code, but not shipped yet.

None of these are available to users. They sit behind disabled feature flags. But they show where Anthropic is heading.

KAIROS. An always-on background process that keeps running even when you close Claude Code. It watches your GitHub repos for new events (PRs, issues, CI failures) and decides every 15 seconds if it should act on something. Think of it as Claude Code that never sleeps.

ULTRAPLAN. Think background sub-agents, but on steroids. Instead of the usual back-and-forth in your terminal, Claude Code sends the problem to run autonomously on Anthropic's servers for up to 30 minutes. You close your laptop, come back later, and review the plan from a browser page before applying it.

BUDDY. A small animated character that lives in your terminal. Each user gets a different species (18 total) based on their user ID. It reacts to what you do, has speech bubbles, and was planned for an April 1-7 rollout. Basically Anthropic built a tamagotchi into a coding tool.

And the build toolchain is Bun. Which is exactly what caused the leak. Bun generates source maps by default. The CLI itself is React.js + Ink. React, but for your terminal. With a custom reconciler, Yoga layout engine, and double buffering.