cd /news/ai-agents/claude-code-from-source Β· home β€Ί topics β€Ί ai-agents β€Ί article
[ARTICLE Β· art-133220] src=claude-code-from-source.com β†— pub= topic=ai-agents verified=true sentiment=Β· neutral

Claude Code from Source

A new 18-chapter book, "Claude Code from Source," reverse-engineers Anthropic's Claude Code AI coding agent from the TypeScript source maps that shipped with the tool on npm, which included a sourcesContent field containing nearly two thousand original files. The book's authors say 36 AI agents analyzed and wrote the entire book in four phases in approximately 6 hours, covering the agent loop, a 14-step tool execution pipeline, multi-agent orchestration that shares prompt cache prefixes to cut costs by 95%, file-based memory, and 240ms startup via parallel I/O. The book is presented as purely educational, with all code blocks rewritten as pseudocode and a final audit pass to remove verbatim source code.

read3 min views3 publishedSep 18, 2026
Claude Code from Source
Image: source

#

How Anthropic built the most widely used

AI coding agent

When Claude Code shipped on npm, the source maps came with it. We read every file. This book distills the architecture, design decisions, and transferable patterns into 18 chapters you can learn from and apply to your own systems.

Start reading

What you'll learn #

The agent loop

How an async generator drives the entire system β€” streaming model output, executing tools, recovering from errors, and compressing context across 4 layers.

Tool execution at scale

A 14-step pipeline from model request to tool result. Permission resolution, speculative execution, concurrent batching by safety classification.

Multi-agent orchestration

How sub-agents share prompt cache prefixes to cut costs by 95%. Fork agents, coordinator mode, swarm teams with mailbox messaging.

Memory without a database

File-based memory with an LLM-powered recall system. Four memory types, staleness warnings, and a Sonnet side-query that beats embedding search.

Performance engineering

Startup in 240ms via parallel I/O. Slot reservation saving context in 99% of requests. Bitmap pre-filters for fuzzy search. Every millisecond accounted for.

Extensibility and security

Two-phase skill (metadata at startup, content on demand). 27 lifecycle hooks with config snapshots frozen at startup to prevent injection.

Explore the architecture #

Six core abstractions power Claude Code. Drag nodes to rearrange, hover for details, click to read the chapter.

Who this is for #

Engineers building agentic systems. Every chapter ends with "Apply This" β€” 5 transferable patterns with concrete adaptation advice. Steal the architecture, skip the mistakes.

Technical leaders evaluating architectures. Follow the narrative without reading every code block. Understand why decisions were made, not just what was built.

Anyone curious about how production AI tools work. Claude Code is used by hundreds of thousands of developers. This is how it works under the hood.

Table of contents #

Foundations

Before the agent can think, the process must exist.

1 The Architecture of an AI Agent
The 6 key abstractions, data flow, permission system, build system

2 Starting Fast β€” The Bootstrap Pipeline
5-phase init, module-level I/O parallelism, trust boundary

3 State β€” The Two-Tier Architecture
Bootstrap singleton, AppState store, sticky latches, cost tracking

4 Talking to Claude β€” The API Layer
Multi-provider client, prompt cache, streaming, error recovery

The Core Loop

The heartbeat of the agent: stream, act, observe, repeat.

Multi-Agent Orchestration

One agent is powerful. Many agents working together are transformative.

Persistence and Intelligence

An agent without memory makes the same mistakes forever.

The Interface

Everything the user sees passes through this layer.

Connectivity

The agent reaches beyond localhost.

Performance Engineering

Making it all fast enough that humans don't notice the machinery.

How this book was made #

The source was extracted from npm source maps β€” the .js.map files that shipped with Claude Code contained a sourcesContent field with the full original TypeScript. Nearly two thousand files comprising the complete architecture.

36 AI agents analyzed and wrote the entire book in four phases:

The entire process β€” from source extraction to final revised book β€” took approximately 6 hours. A final audit pass ensured no verbatim source code remained β€” every code block was rewritten as pseudocode with different variable names.

The 10 patterns that make it work #

If you read nothing else, these are the architectural bets that define Claude Code. Purely educational. This book contains no source code from Claude Code β€” every code block is original pseudocode written to illustrate architectural patterns. The goal is to help engineers understand how production AI agents are built, not to reproduce proprietary software. The "NO'REILLY" cover is a parody/meme for illustrative purposes only β€” no affiliation with O'Reilly Media.

── more in #ai-agents 4 stories Β· sorted by recency
── more on @anthropic 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/claude-code-from-sou…] indexed:0 read:3min 2026-09-18 Β· β€”