← The Vault

Claude Code CLI Full TypeScript Source Leaked via npm .map Misconfiguration

A misconfigured source map just gave every agent builder a free architectural tour of Anthropic's production CLI.


A misconfigured source map just gave every agent builder a free architectural tour of Anthropic’s production CLI.

Anthropic accidentally exposed the full unobfuscated TypeScript source of Claude Code CLI via a .map file in their npm package. The .map file contained a direct URL pointing to Anthropic’s own Cloudflare R2 bucket, where the complete codebase sat publicly accessible. Chaofan Shou discovered and disclosed it.

This is not a breach in the traditional sense. No user data exposed, no credentials leaked. But for anyone building agentic systems, this is primary-source documentation of how Anthropic actually structured a production-grade AI coding agent.

What Got Exposed and Why It Matters

Source maps are debug artifacts that map minified/compiled output back to original source. When you ship a .map file with an npm package and that file points to a live, unauthenticated URL, you’ve handed anyone with a browser the full source tree.

The Claude Code CLI is not a toy wrapper around the API. It handles tool use, file system operations, multi-turn context management, and subprocess execution. Seeing the actual TypeScript tells you how Anthropic structured the agent loop, which primitives they reached for, and where they put error handling. That’s worth more than any blog post they’ll write about it.

What You Should Do Right Now

Pull the source before Anthropic patches the bucket ACL or rotates the URL. Run npm pack @anthropic-ai/claude-code locally, inspect the .map references, and fetch the linked files. Store a local copy.

Once you have it, focus on three things. First, look at the tool dispatch layer. How they route between file ops, shell commands, and API calls will tell you a lot about robust agentic loop design. Second, find the context management code. Seeing how they handle token budgets in a real shipped product beats reading papers. Third, check error recovery. Production agents fail constantly. Their retry and fallback logic is where the real engineering lives.

If you’re building on top of Claude or designing any CLI-adjacent agent tooling, treat this as an architectural reference. You won’t get access like this again once the bucket is locked down. Anthropic will fix this fast.

One practical note: don’t copy paste their code into your own projects. Beyond the obvious IP issues, the patterns matter more than the implementation. Extract the design decisions, not the code.

Source: @T3chFalcon