Claude Code shipped its own TypeScript in npm source maps

The original TypeScript of Claude Code leaked through npm source maps, and someone has now turned it into an 18-chapter book about how the agent works. Claude Code from Source went up on September 18. It covers the agent loop, tool execution, multi-agent orchestration, memory and performance, and every chapter ends with five patterns readers can reuse in their own agents.
The source itself has been public since March 31. On that date security researcher Chaofan Shou found that version 2.1.88 of the npm package shipped a 59.8MB cli.js.map. A source map is the file a bundler emits so minified production code can be traced back to the original, and this one’s sourcesContent field carried 1,906 TypeScript files as embedded strings. Bun, the runtime Anthropic acquired at the end of 2025, generates source maps by default, and *.map files were never added to .npmignore. Versions 0.2.8 and 0.2.28 had already shipped source maps in 2025. Anthropic pulled 2.1.88, released 2.1.89 and called the incident “a release packaging issue caused by human error, not a security breach.”
At the centre of the book is the agent loop: a single async generator drives the whole system. It yields messages as the model streams, runs tools, recovers from errors and ends with a typed terminal return. Because the generator only produces output when the consumer asks for it, backpressure and cancellation come for free. Context is compressed in four layers (snip, microcompact, collapse, autocompact), each lighter than the next.
Tool calls go through a 14-step pipeline between the model’s request and the result, including permission resolution. Two tricks keep it fast. Read-only tools start while the model is still streaming, before its response is complete. And tools are partitioned by safety: reads run in parallel, writes run one at a time.
The multi-agent chapters explain the roughly 95% saving on input tokens. Fork agents run in parallel with byte-identical prompt prefixes, so every child hits the prompt cache the parent already paid for. The source has three ways to run sub-agents. A fork copies the parent context and suits parallel reads. A teammate runs in its own terminal pane and talks through a file-based mailbox. A worktree agent gets its own git branch and a physically separate workspace. The book also covers coordinator mode and swarm teams.
Memory has no database behind it. Claude Code stores notes as files in four memory types and attaches staleness warnings to old entries. When it needs to recall something, a side-query to Sonnet picks the relevant memories instead of keyword or embedding matching, and the book says this beats embedding search.
The performance and security chapters are where most of the copyable detail sits:
- Startup takes 240ms because module-level I/O runs in parallel.
- Output is capped at 8K tokens by default and raised to 64K only when a response hits the cap. The book says this saves context in 99% of requests.
- Skills load in two phases: frontmatter at startup, full content only when invoked.
- Once a beta header has been sent, it stays set for the rest of the session so the prompt cache stays valid.
- The 27 lifecycle hooks read a config snapshot frozen at startup, so a hook can’t be injected while the session runs.
- Fuzzy search runs bitmap pre-filters before it scores matches.
The book was written by 36 AI agents in about 6 hours, working in four phases. Six agents read every file in the source tree. Twelve wrote 494KB of raw technical documentation, and fifteen rewrote all of it from scratch as narrative chapters. Three reviewers then produced 900 lines of feedback, and three more agents applied the fixes. The cover reads “NO’REILLY”, a parody with no affiliation to O’Reilly Media.
Anthropic responded to the leak with DMCA takedown notices, and GitHub disabled more than 8,100 repositories in the fork network. The most-forked mirror had passed 41,500 forks. The book’s last step was an audit that rewrote every code block as pseudocode with different variable names, so none of the original TypeScript appears in it.
Up next
Claude opened the door to an OpenAI employee’s ChatGPT
“We recognise there are a lot of questions and speculative details circulating,” an OpenAI spokesperson told the BBC, after independent researchers used Anthropic’s Claude to get into an OpenAI employee’s ChatGPT account, per the WSJ.
Related stories
- Typing “hi” into Claude Code crosses ten layers
- Claude desktop teardown: MCP servers run outside the VM
- A Claude Code mod that reverts its own failed ideas
- Show HN: Generate a Claude Code or Codex agent fleet from one HTML file
- pairmark races Claude Code against Codex in your repo
- Oh My Subagents keeps Claude Code teams running
Comments
No comments yet. Be the first.
Join the conversation
Sign in to leave a comment. It appears after moderation.

