The Blueprint in the Sourcemap: Deconstructing ChinaSiro/claude-code-sourcemap
How an npm packaging error gave the developer community an unprecedented look inside Anthropic's multi-agent terminal IDE.

The Claude Code Leak Dropped the Real Blueprint (and the stuff fee are talking about yet): Anthropic’s “packaging error” yesterday exposed 512,000 lines of their full Claude Code CLI source via a forgotten npm sourcemap. Not model weights. The entire agent harness. I dug https
- The claude-code-sourcemap repository reveals that production-grade AI agents rely on strict TypeScript schemas, not just prompt engineering, to safely interface with local systems.
- Anthropic chose to build Claude Code's terminal UI with Ink (React for CLI), demonstrating the necessity of complex state management even in text-only environments.
- The architecture features a multi-agent 'coordinator' pattern, delegating specialized tasks to sub-agents to preserve the main context window.
- By vendoring compiled Rust binaries like ripgrep directly into the package, Anthropic prioritized a zero-dependency installation over a smaller footprint.
The Multi-Million Dollar Sourcemap
On March 31, 2026, the AI development community experienced a rare event: a top-tier research lab accidentally open-sourced its flagship developer tool. Anthropic published version 2.1.88 of its @anthropic-ai/claude-code package to npm. Bundled inside was a forgotten file: cli.js.map. This source map allowed anyone armed with a reverse-engineering script to reconstruct nearly 5,000 files of pristine TypeScript.
The resulting repository, mirrored by users like ChinaSiro, provides an unredacted look at how Anthropic solves the "agentic loop" problem. It proves that building a reliable AI coding assistant requires far more than a clever system prompt; it demands rigorous, classical systems engineering.
React in the Terminal
The first surprise in the reconstructed source tree is the entry point: main.tsx. Claude Code is a command-line interface, yet it is built with React. Anthropic utilized Ink, a React renderer for the terminal, to manage the complex, asynchronous state of an AI agent.
When an LLM generates a massive file diff, streams a response, or triggers a local search, the UI must update smoothly without breaking the terminal buffer. Ink provides the declarative framework necessary to handle these concurrent visual updates—spinners, progress bars, and syntax-highlighted diffs—treating the terminal as a dynamic canvas rather than a static log.
// Simulated Ink component structure based on leaked architecture
import React, { useState, useEffect } from 'react';
import { render, Text, Box } from 'ink';
import Spinner from 'ink-spinner';
const AgentInterface = () => {
const [status, setStatus] = useState('Thinking...');
return (
<Box flexDirection="column">
<Box>
<Text color="green"><Spinner type="dots" /> {status}</Text>
</Box>
{/* Complex diff views and interactive prompts render here */}
</Box>
);
};
render(<AgentInterface />);
The Strict Contract of the Agentic Loop
The most critical architectural revelation is found in sdk-tools.d.ts. This file defines the rigid boundaries between the chaotic output of a Large Language Model and the deterministic environment of a local file system. It is the safety harness.
Claude Code does not simply execute whatever bash commands the model hallucinates. The model is constrained by strict TypeScript union types (AgentInput, BashInput, FileEditInput). The CLI validates the LLM's JSON payload against these schemas before executing any side effects. If the payload fails validation, the error is fed back to the model, creating a self-correcting loop.
Orchestrating the Swarm
Analyzing the coordinator/ directory reveals that Claude Code is not a monolithic prompt loop. It employs a multi-agent hierarchy. A central "Main" agent manages the overall state and user intention, but it delegates granular, token-heavy tasks to specialized sub-agents.
This subagent_type architecture solves a fundamental limitation of current LLMs: context window degradation. By spawning a specialized editor agent with only the relevant files in its context, the main agent avoids distraction and reduces token costs during massive refactors.
The Bare Metal Strategy
Within the reconstructed package/vendor/ folder lies Anthropic's strategy for reliability: zero-dependency deployment. Instead of relying on the user's operating system to provide essential utilities, Claude Code bundles compiled binaries directly into the npm package.
The inclusion of tools like ripgrep (for high-speed code searching) across multiple architectures (arm64/x64 for Darwin, Linux, Win32) ensures that the agent's internal Grep tool functions identically on every machine. This vendoring strategy bloats the package size but eliminates the environmental friction that often derails automated coding assistants.
vs. The Open Source Ecosystem
The sourcemap leak provides a rare opportunity to compare an enterprise-grade, closed-source architecture against the open-source tools that dominate the space, such as Aider.
| Feature | Claude Code (Anthropic) | Aider (Open Source) |
|---|---|---|
| Interface Framework | Ink (React for CLI) | Python / Prompt Toolkit |
| Execution Environment | Vendored Binaries (e.g., ripgrep) | System Path Utilities |
| Orchestration | Multi-Agent Coordinator | Single Loop + Git Integration |
| Tooling Contract | Strict TypeScript Schemas | Function Calling / Regex Parsing |
While Aider relies heavily on the user's existing environment and git workflow, Claude Code attempts to encapsulate the entire execution context. It is a heavier, more controlled approach to the same problem: turning an LLM into a reliable software engineer.