
According to a Twitter post, the Claude code source code has been leaked via a map file in their npm registry.
Claude code source code has been leaked via a map file in their npm registry!
Code: https://t.co/jBiMoOzt8G pic.twitter.com/rYo5hbvEj8
— Chaofan Shou (@Fried_rice) March 31, 2026
—
An interesting article about the Claude Code source code leak can be find on Alex Kim’s blog.
Comments:
Anthropic appears to have accidentally shipped a .map file with their Claude Code npm package, exposing the full readable source of the CLI tool. The package has since been pulled, but not before it was widely mirrored and dissected.
A few interesting findings from the leaked code:
- Anti-distillation mechanisms:
The client can request “fake tool” injection to poison training data for anyone scraping API traffic. There’s also a system that summarizes intermediate outputs with signed blobs, so recorded traffic doesn’t contain full reasoning chains. Both mechanisms are feature-flagged and relatively easy to bypass. - “Undercover mode”:
A built-in mode prevents the model from revealing internal codenames or even mentioning “Claude Code.” Notably, it cannot be force-disabled in external contexts, meaning AI-generated contributions may intentionally appear human-authored. - Frustration detection via regex:
Instead of using an LLM, user frustration is detected with a simple regex matching phrases like “wtf,” “this sucks,” etc. Cheap and fast, if a bit ironic. - Client attestation at the transport layer:
Requests include a placeholder that gets replaced with a hash by Bun’s native HTTP stack (in Zig), allowing the server to verify requests come from an official binary. This acts like lightweight DRM for API access, though it’s gated behind flags and not airtight. - Operational inefficiency:
A comment notes ~250K API calls/day were being wasted due to repeated failures in a compaction routine. Fixed by adding a simple failure cap. - KAIROS (unreleased):
The code references a heavily gated autonomous agent mode with background workers, scheduled tasks, memory distillation, and GitHub integration—suggesting an always-on agent system in development. - Other quirks:
- A Tamagotchi-style “companion” system (likely an April Fools feature)
- Game-engine-like terminal rendering optimizations
- Extensive bash security filtering (23 checks, including Zsh-specific exploits)
- Prompt caching treated as a first-class economic concern
- A multi-agent orchestration system implemented via prompts rather than code
The broader takeaway: the leak is less about code quality and more about product strategy exposure. Feature flags and hidden capabilities (like KAIROS and anti-distillation efforts) reveal roadmap direction that competitors wouldn’t normally see.
There’s also an ironic angle: the leak may have been caused by a known Bun issue where source maps are served in production. If so, Anthropic’s own stack may have exposed its flagship product.
Overall, not catastrophic technically—but strategically awkward timing given recent enforcement actions against third-party clients using Claude APIs.

—
A GitHub user, Sigrid Jin was able to create a new project starting from the leaked Claude Code project:
At 4 AM on March 31, 2026, I woke up to my phone blowing up with notifications. The Claude Code source had been exposed, and the entire dev community was in a frenzy. My girlfriend in Korea was genuinely worried I might face legal action from Anthropic just for having the code on my machine — so I did what any engineer would do under pressure: I sat down, ported the core features to Python from scratch, and pushed it before the sun came up.
The whole thing was orchestrated end-to-end using oh-my-codex (OmX) by @bellman_ych — a workflow layer built on top of OpenAI’s Codex (@OpenAIDevs). I used
$teammode for parallel code review and$ralphmode for persistent execution loops with architect-level verification. The entire porting session — from reading the original harness structure to producing a working Python tree with tests — was driven through OmX orchestration.The result is a clean-room Python rewrite that captures the architectural patterns of Claude Code’s agent harness without copying any proprietary source. I’m now actively collaborating with @bellman_ych — the creator of OmX himself — to push this further. The basic Python foundation is already in place and functional, but we’re just getting started. Stay tuned — a much more capable version is on the way.

—
You can read more info and find about what exactly was leaked following this Discussion.
