Claude Code from Source: what the leaked source maps actually reveal
Architecture, patterns & internals of Anthropic's AI coding agent — reverse-engineered from source maps
At a glance
- What is it?
- A reverse-engineered architecture book about Anthropic's AI coding agent, written from npm source maps. It is a reading project, not a library you install, and the repository ships no Claude Code source at all.
- Who is it for?
- Adopt this as reading material if you are designing an agent loop, a tool permission model, or a prompt cache strategy and want a worked example of how one production agent is put together. Do not clone it expecting a dependency, an SDK, or a runnable harness: the repository contains no Claude Code source, no package manifest at the top level, and no install instructions.
- Can I use it commercially?
- Not without permission. GitHub finds no licence file in the repository, and without a licence all rights are reserved by default: you may read the code but not reuse it. Check the README, or ask the authors, before using it.
- Is it still maintained?
- Yes. The repository last received commits 173 days ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 20, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
What Claude Code from Source is, and what it is not
This repository is a book. The README states it plainly: "This repository is purely educational. It contains no source code from Claude Code, not a single line. Every code block is original pseudocode written to illustrate architectural patterns." The top-level layout backs that up. There is a book/ directory of Markdown chapters, a prompts/ directory, a web/ directory that appears to host the online edition, a CLAUDE.md, and a .github/ folder. There is no package manifest at the root, no build script, and no library to import.
The audience is narrow on purpose. The README names senior engineers building agentic systems, technical leaders evaluating architectures, and anyone curious how production AI tools work under the hood. If you are looking for an open source Claude Code, this is not one, and the repository does not claim to be. What it offers is a written analysis: 18 chapters across 7 parts, roughly 400 pages in print equivalent, each chapter layered so a technical lead can read the narrative and an implementer can drop into the deep-dive sections. Every chapter closes with an "Apply This" section that extracts patterns the author considers transferable.
The origin story matters for how you read it. According to the README, when Anthropic shipped Claude Code on npm, the .js.map source maps contained a sourcesContent field holding the full original TypeScript. The book is the result of studying that architecture. The README also describes the production process: 36 AI agents analyzed nearly two thousand TypeScript files across four phases (exploration, analysis, writing, review and revision), producing 494KB of raw technical documentation and a final revised book in roughly six hours. That is an unusual provenance for a technical book, and it is worth keeping in mind when you weigh how much of any given chapter is observation versus interpretation.
The architecture the book reconstructs: six abstractions and a stream
Chapter 1 promises the six key abstractions, the data flow, the permission system, and the build system. The rest of the table of contents reads like a tour of the internals of a streaming agent rather than a tour of a codebase's file tree.
The central mechanism the book describes is the agent loop, covered in chapter 5 as a deep dive into query.ts with four-layer compression, error recovery, and token budgets. The README's list of the ten patterns that make it work gives the shape of that loop: an AsyncGenerator that yields Messages with a typed Terminal return, chosen for natural backpressure and cancellation. Around that loop sit tools (chapter 6 describes a 14-step pipeline from definition to execution) and concurrency (chapter 7 describes a partition algorithm that separates tools by safety, runs reads in parallel, and serializes writes).
Two patterns in that list are the most interesting to argue with. The first is speculative tool execution: starting read-only tools during model streaming, before the response completes. That is a bet that the model's early tokens predict which tools it will call, and it trades wasted work on mispredicted calls for lower latency on correct ones. The second is fork agents for cache sharing, where parallel children share byte-identical prompt prefixes. The README puts the saving at roughly 95% of input tokens. Both are the kind of decision that only makes sense once you have measured your own cache hit rate and your own tool latency distribution; the book presents them as patterns, not as universal advice.
Multi-agent orchestration gets three chapters: sub-agent spawning with a 15-step runAgent lifecycle, fork agents and the prompt cache, and tasks, coordination, and swarms with a task state machine and a coordinator mode. Persistence gets memory (file-based, with a four-type taxonomy and LLM recall via a Sonnet side-query rather than keyword matching) and extensibility (two-phase skill loading, where frontmatter loads at startup and full content loads on invocation, plus lifecycle hooks and a hook config snapshot frozen at startup to prevent runtime injection).
Reading it: there is nothing to install
There is no install step. The README gives no package name, no CLI, no setup command, and no configuration file for the book itself. It points to the online edition at claude-code-from-source.com and the chapters live as Markdown under book/. The realistic first use is cloning the repository, opening the table of contents in README.md, and picking a chapter.
If you want the local copy, the clone is the only command the repository supports:
git clone https://github.com/alejandrobalderas/claude-code-from-source.git
cd claude-code-from-source
ls book/You should see the chapter files referenced from the table of contents, such as ch01-architecture.md and ch05-agent-loop.md. The README states that diagrams use Mermaid and render natively on GitHub, so the reading experience is better on GitHub or in a Markdown viewer that renders Mermaid than in a plain terminal pager.
If you would rather not clone anything, the README links the hosted version:
# the README points readers to the online edition
# https://claude-code-from-source.comThat link is the extent of the distribution story. There are no releases listed, no npm package, and no PDF linked from the README, even though people search for one. Treat the hosted site and the Markdown files as the two ways in.
Where the book is thin, and where it can mislead you
The first limitation is provenance. The book was assembled by AI agents from source maps, and the README describes the pipeline in detail: six parallel agents reading the source tree, twelve writing raw technical documentation, fifteen rewriting it as narrative, three reviewers producing feedback, three revision agents applying fixes. That is a lot of transformation between the artifact and the page. The README's own framing, that every code block is original pseudocode, means you cannot use a snippet from this book as a reference implementation. It illustrates a pattern; it does not reproduce the code.
The second limitation is legal and ethical, and the README addresses it head-on rather than dodging it. The source was extracted from npm source maps. Whether reading a published source map is fair game is a question the repository answers by refusing to redistribute anything: no source code from Claude Code, not a single line. If your organisation has a policy about consuming material derived from a vendor's published artifacts, that policy applies here, and the book's disclaimer is the author's position, not a legal opinion.
The third limitation is that the architecture is described at a point in time. The last push to the repository was on 2026-04-04, and there are no releases. Claude Code ships continuously; a chapter describing a 14-step tool pipeline or a 15-step agent lifecycle is a description of one version's internals, and the book does not appear to include a mechanism for tracking upstream changes. Read it as a study of a design, not as a current specification.
Finally, the book is a poor fit if you want to evaluate Claude Code as a product. It does not cover pricing, model quality, or which tasks the agent is good at. It covers how the machinery is assembled.
Alternatives: documentation, and reading the agent frameworks directly
The obvious alternative is Anthropic's own documentation for Claude Code and the Claude Agent SDK. The difference in approach is total. Vendor documentation tells you what the supported interface is, what configuration keys exist, and what behaviour is guaranteed. This book tells you how one implementation chose to sequence its work, and it is explicit that the code blocks are pseudocode. If you need to build on top of Claude Code, the documentation is the correct source. If you need to understand why an agent loop is shaped the way it is, the book answers a question the documentation does not attempt to answer.
The second alternative is reading an open source agent framework directly, such as one of the TypeScript or Python agent libraries that ship their full source. That gives you real code you can run and modify, which the book cannot offer. The trade-off is that you get one team's implementation without the comparative framing. The book's value is that it walks through a single production system end to end, chapter by chapter, and names the trade-offs at each step: speculative execution versus wasted calls, cache sharing versus coupling between parent and child, startup speed versus eager loading. A framework's source shows you the decision; it rarely shows you the alternatives that were rejected.
A third alternative, for the specific question of how a large CLI is structured, is to read any mature terminal application's source. That will teach you about rendering pipelines and input parsing, which chapters 13 and 14 cover, but it will not teach you about prompt caches, sub-agent lifecycles, or MCP transports, which is where most of this book's pages go.
Maintenance, licensing, and what a reader is actually committing to
The repository is not archived. The last push was on 2026-04-04, which is more than five months before today, so there is no basis for calling it actively maintained. There are no releases, which means there is no versioned artifact to pin and no changelog to follow. If the author stops writing, the Markdown files stay readable, which is the main advantage of a book over a library: nothing breaks when it stops being updated.
The licence is not stated in the repository metadata available here. The repository has no licence identifier listed, and the README's disclaimer covers the source-code question but not the terms under which the book text itself may be reused. If you intend to quote chapters, translate them, or use the diagrams in internal training material, that is the first thing to resolve, and it is a question for the author or the repository's licence file rather than something this article can answer. The disclaimer is also worth reading in full before you cite the book in a design document, because it draws a line between architectural patterns, which the author considers fair to discuss, and Claude Code's source, which the repository does not contain.
Upgrade cost is close to zero in the software sense and non-trivial in the editorial sense. There is no dependency to bump. But if you build a mental model from chapter 7's partition algorithm or chapter 9's fork-agent cache trick, you own the job of checking whether the pattern still holds in the version of Claude Code you are actually integrating with.
Editorial conclusion
Adopt this as reading material if you are designing an agent loop, a tool permission model, or a prompt cache strategy and want a worked example of how one production agent is put together. Do not clone it expecting a dependency, an SDK, or a runnable harness: the repository contains no Claude Code source, no package manifest at the top level, and no install instructions. Before you rely on any chapter, open the corresponding file under book/ and check whether the claim is attributed to the source maps or is the author's own synthesis, because the README's disclaimer applies to every code block in the book.
Frequently asked questions
Has Claude leaked its source code?
The book's premise is that Anthropic's published npm source maps contained a sourcesContent field with the original TypeScript, and that this is what the author studied. The repository itself contains no Claude Code source code, by its own explicit statement.
Is there an open source Claude Code?
No. Claude Code from Source is an educational book about the architecture, and the README states it contains no source code from Claude Code, not a single line. Every code block in it is original pseudocode written to illustrate patterns.
What is the Claude source code written in?
The README states that the source maps contained the full original TypeScript, and the repository's primary language is listed as TypeScript. The book's chapters are Markdown files under book/.
Is there a source code for Claude Code available on GitHub?
Not in this repository. The README is explicit that no Claude Code source is redistributed here; what exists on GitHub is the book text, a prompts/ directory, and a web/ directory for the online edition.
Community notes