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.

8 min read · ChinaSiro/claude-code-sourcemap

A wooden shipping crate stamped with an 'npm' style barcode that has split open. Tumbling out of the crack is a highly detailed, intricate clockwork mechanism of interlocking gears, levers, and measuring calipers, spilling onto a pristine white table.
The accidental exposure of cli.js.map revealed the intricate, multi-agent architecture powering Anthropic's Claude Code.

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

Brian Roemmele, BrianRoemmele, 465,080 followers · @BrianRoemmele on X
Key Takeaways

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.

Portrait of Brian Roemmele

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.

The validation loop ensures that the LLM's output strictly adheres to predefined TypeScript schemas before executing any actions on the local machine.

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.

A close-up of a large, heavy iron main gear. Meshed into its teeth are three smaller, highly specialized gears (one shaped like a magnifying glass, one like a pen, one like a hammer). A thick, rigid metal frame encloses the entire assembly, keeping them perfectly aligned.
The coordinator agent (the main gear) delegates tasks to specialized sub-agents, all constrained by the rigid framework of the TypeScript schemas.

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.

FeatureClaude Code (Anthropic)Aider (Open Source)
Interface FrameworkInk (React for CLI)Python / Prompt Toolkit
Execution EnvironmentVendored Binaries (e.g., ripgrep)System Path Utilities
OrchestrationMulti-Agent CoordinatorSingle Loop + Git Integration
Tooling ContractStrict TypeScript SchemasFunction 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.