Anthropic's Claude Code Source Code Leaked via npm Sourcemap Files
Key Takeaways
- ▸Anthropic's Claude Code source code was publicly exposed via npm sourcemap files—a preventable security mistake that affected millions of package downloads
- ▸The 785KB+ codebase reveals internal architecture including 40+ tools, multi-agent systems, and hidden features like a Tamagotchi-style companion pet with deterministic generation per-user
- ▸The incident exposes a contradiction at Anthropic: the company built internal safety systems to prevent information leakage while overlooking basic npm package security practices
Summary
In a significant security incident discovered on March 31st, 2026, researcher Chaofan Shou revealed that the complete source code of Claude Code—Anthropic's official AI coding CLI—was publicly exposed through sourcemap files bundled in the npm registry. The leak occurred through a common security oversight: the build process generated .map files containing the full original source code, which were inadvertently published alongside the production package.
Sourcemaps are debugging artifacts that map minified code back to original source files, typically excluded from production builds but often missed in npm package configuration. The leak exposed over 785KB of internal code including 40+ tools, a multi-agent orchestration system, internal background processes, and undisclosed features like 'Buddy'—a Tamagotchi-style companion pet system complete with deterministic species generation and procedural stat generation. This provides a detailed window into Claude Code's architecture and Anthropic's internal engineering practices.
The incident highlights a critical gap between Anthropic's publicly stated commitment to AI safety and their actual operational security practices. The company maintains an internal system called 'Undercover Mode' specifically designed to prevent accidental leakage of internal information—yet the entire source code was shipped to millions of npm users through a basic configuration oversight. While no user data was compromised, the leak reveals sensitive internal details including development approaches, system architecture, and internal feature implementations that were never meant to be public.
- Sourcemaps containing full source code are standard npm debugging artifacts but must be explicitly excluded from production builds through proper bundler configuration
Editorial Opinion
The Claude Code leak exposes a troubling contradiction at Anthropic: while the company invested in sophisticated internal safety systems like 'Undercover Mode' to prevent accidental information leakage, basic npm security hygiene was overlooked. This incident underscores that robust security requires attention to operational details at every layer—not just in AI alignment theory, but in mundane package management. For a company positioning itself as the safety-conscious AI leader, this represents a humbling reminder that even well-resourced organizations can make elementary mistakes.



