On 31 March 2026, developers reported that the published npm package for Anthropic’s Claude Code CLI shipped a large bundled cli.js together with a source map (.map). Because the map pointed back to original paths and content, the TypeScript/React implementation could be reconstructed from the registry artifact. This repository holds that kind of recovered src/ tree — useful for understanding architecture and integration, not an official release or supported SDK.
Chaofan Shou (@Fried_rice) discovered the leak and posted it publicly:
Claude code source code has been leaked via a map file in their npm registry!
— @Fried_rice, 31 March 2026
The source map file in the published npm package contained a reference to the full, unobfuscated TypeScript source, which was downloadable as a zip archive from Anthropic’s R2 storage bucket.
Claude Code is Anthropic’s official CLI tool that lets you interact with Claude directly from the terminal to perform software engineering tasks — editing files, running commands, searching codebases, managing git workflows, and more.
This repository contains the leaked src/ directory.
| Property | Value |
|---|---|
| Leaked on | 2026-03-31 |
| Language | TypeScript |
| Runtime | Bun |
| Terminal UI | React + Ink (React for CLI) |
| Scale | ~1,900 files, 512,000+ lines of code |
Discussion and context: Hacker News thread on the npm source-map leak.
Legal / ethical note: The underlying software is Anthropic’s proprietary product. This README describes structure for analysis only; redistribution or use beyond fair use / your local law is your responsibility.
The CLI is a Bun-bundled application whose spine is src/main.tsx: a Commander-based program named claude that registers global options, subcommands, and a preAction hook where trust, settings, telemetry gates, and prefetch work run before the interactive or print-mode loop.
The tree below matches this repo’s src/ layout. For root-level filenames, per-folder notes, and selected subtrees (services/, tools/, utils/), see docs/directory-structure.md.
src/
├── main.tsx
├── QueryEngine.ts
├── Task.ts
├── Tool.ts
├── commands.ts
├── context.ts
├── cost-tracker.ts
├── costHook.ts
├── dialogLaunchers.tsx
├── history.ts
├── ink.ts
├── interactiveHelpers.tsx
├── projectOnboardingState.ts
├── query.ts
├── replLauncher.tsx
├── setup.ts
├── tasks.ts
├── tools.ts
│
├── assistant/
├── bootstrap/
├── bridge/
├── buddy/
├── cli/
├── commands/
├── components/
├── constants/
├── context/
├── coordinator/
├── entrypoints/
├── hooks/
├── ink/
├── keybindings/
├── memdir/
├── migrations/
├── moreright/
├── native-ts/
├── outputStyles/
├── plugins/
├── query/
├── remote/
├── schemas/
├── screens/
├── server/
├── services/
├── skills/
├── state/
├── tasks/
├── tools/
├── types/
├── upstreamproxy/
├── utils/
├── vim/
└── voice/
| Area | Role |
|---|---|
main.tsx + cli/ |
Argument parsing, early startup (MDM/keychain prefetch side effects), routing to REPL, -p/--print, doctor, install, MCP helpers, etc. |
replLauncher.js / components/ / ink/ |
Terminal UI built with React + Ink; dialogs, status, and input handling. |
services/api/ |
HTTP client to Anthropic APIs, bootstrap, files, session ingress, usage, retries. |
services/mcp/ |
Model Context Protocol: config parsing, stdio/SDK transports, connection manager, OAuth, enterprise/XAA paths. |
services/compact/ |
Session compaction (memory/context management hooks the model loop). |
services/lsp/ |
Optional LSP integration for editor-like features in the terminal workflow. |
tools/ |
Tool implementations the agent invokes (bash, read/write, grep/glob, web, todos, tasks, teammates, MCP tools, etc.). |
utils/swarm/ |
Multi-agent teammate flows: backends for tmux, iTerm, in-process runners, permission sync, reconnection. |
coordinator/ |
Gated behind bundle feature COORDINATOR_MODE (multi-agent coordination). |
assistant/ |
Gated behind bundle feature KAIROS (assistant / Agent SDK–oriented mode). |
plugins/, skills/ |
Bundled and user plugins; skill loading and telemetry. |
utils/settings/, services/policyLimits/, services/remoteManagedSettings/ |
Layered configuration, enterprise policy, and remote-managed settings. |
buddy/, upstreamproxy/, voice/, vim/ |
Product features (buddy flows, upstream proxy, voice, vim-style editing). |
utils/deepLink/, utils/claudeInChrome/ |
OS integration: URL schemes, Chrome native messaging, optional MCP entrypoints. |
Execution paths converge on shared state (state/, bootstrap/), permissions (utils/permissions/), and session storage (utils/sessionStorage.js, hooks in utils/sessionStart.js). Non-interactive and SDK-style use share much of the same stack as the full-screen REPL, with different front-ends for I/O.
Full internals documentation is built with MkDocs Material from docs-site/. The site includes system design (layers, state flow, security/trust), architecture overview and workflows, a developer hub (editing docs, navigating src/, Bun feature flags), guides for greenfield agentic CLI and docs/CI patterns, reference pages per subsystem, official docs map, and appendices (directory layout, tools, env vars, glossary).
- Live site: https://mehmoodosman.github.io/claude-code-source-code/
- Local preview:
cd docs-site && python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt && mkdocs serve - Publish: pushing to
mainruns.github/workflows/pages.ymland deploys togh-pages.
Canonical site_url and repo_url are set in docs-site/mkdocs.yml for this deployment. Forks should change those values to match their own GitHub user/org and Pages URL.
Contributing to docs: edit Markdown under docs-site/docs/; keep the official docs map in sync with Anthropic’s docs index when adding major features.
- Commit and push so
mainincludesdocs-site/and.github/workflows/pages.yml. - Run the Pages workflow (or wait for it on push).
- Settings → Pages → deploy from branch
gh-pages// (root)(unless you switch to the GitHub Actions Pages source). - Set
site_urlinmkdocs.ymlto your live URL and alignrepo_url/extra.socialwith your fork, then push to refresh the site.
src/— Application source (thousands of modules) as recovered from the bundle map.docs-site/— MkDocs source for the GitHub Pages documentation site.docs/— Short pointer plusdirectory-structure.md(src/layout reference).scripts/— Optional helpers (e.g.gen-appendices.sh).- There is no
package.jsonin this clone; building would require the original toolchain (Bun, internalbun:bundlefeatures, and private deps). Treat this tree as a read-only architectural reference.