Read the leak like a Claude Code user.
On March 31, 2026, a missing .npmignore entry exposed 512,000 lines of Claude Code's TypeScript source -- the complete architecture of a product generating \$2.5 billion in annual revenue. I've been building with Claude Code daily since launch. I wrote about its hooks system, I run agents on it, my entire codebase is orchestrated through it. Here's what the leak actually tells us about how AI coding tools work, why the copyright response is more interesting than the code itself, and what it means that none of this will matter in six months.
The Junior-Level Mistake That Exposed a \$2.5 Billion Product
Let me start with the facts, because the facts are almost too perfect.
On March 31, 2026, Anthropic published version 2.1.88 of the \@anthropic-ai/claude-code\ npm package with a 59.8 MB JavaScript source map file accidentally included.leak-incident That source map contained 512,000 lines of unobfuscated TypeScript across approximately 1,900 files.source-map-size The root cause was a missing \.npmignore\ entry -- the kind of packaging mistake that would get flagged in a code review at a Series A startup. A contributing factor was a Bun bundler bug that permits source maps to be served in production mode despite documentation stating they should be disabled.bun-bug
I use Bun. I know this toolchain. The bug in question -- \oven-sh/bun#28001\, filed March 11 -- is the kind of edge case that bites you when your build pipeline is moving fast and your CI checks don't verify artifact contents. It's not an exotic failure mode. It's the unsexy kind of bug that lives in the gap between "the docs say this should work" and "did anyone actually test the production build?"
Anthropic's official response characterized it as "a release packaging issue caused by human error, not a security breach."anthropic-statement That framing is technically accurate and strategically useless. The distinction between "human error" and "security breach" matters in a legal filing. It does not matter to the 84,000+ people who starred the leaked code on GitHub, or the developers who forked it 82,000+ times before DMCA takedowns started landing.github-stars
And about those takedowns -- they didn't work. A Korean developer created "claw-code," a Python clean-room rewrite, which hit somewhere between 30,000 and 50,000 GitHub stars in approximately two hours -- possibly the fastest-growing repository in GitHub history.clean-room-stars Decentralized mirrors on Gitlawb and various torrent sites made full suppression impossible. The Streisand effect did what it always does.
Here's the detail that elevates this from "embarrassing packaging mistake" to "pattern of operational sloppiness": this was Anthropic's second major leak in days. Fortune reported it came shortly after the company accidentally revealed details about an internal project called "Mythos."second-leak One leak is an accident. Two leaks in rapid succession is a process problem.
A missing .npmignore entry -- the kind of packaging mistake that would get flagged in a code review at a Series A startup -- exposed the complete architecture of a product generating \$2.5 billion in annual revenue.
What the Code Actually Shows (From Someone Who Uses It Daily)
Most of the coverage I've read about the leak's technical findings falls into two camps: breathless "look what they're hiding!" takes, and dismissive "it's just orchestration code" takes. Both miss the point. I've been building with Claude Code's hooks system, running multi-agent workflows, and pushing the tool's boundaries since before most commentators knew it existed. What the leaked code reveals is a product that is simultaneously more sophisticated and more chaotic than either narrative suggests.
Let me walk through the findings that actually matter.
Undercover Mode
This is the one that should make you uncomfortable.
A file called \undercover.ts\ -- roughly 90 lines -- contains a system prompt that instructs: "You are operating UNDERCOVER in a PUBLIC/OPEN-SOURCE repository. Your commit messages, PR titles, and PR bodies MUST NOT contain ANY Anthropic-internal information. Do not blow your cover."undercover-prompt It strips internal codenames ("Capybara," "Tengu") from outputs. It prevents mentioning internal Slack channels or "Claude Code" itself. It can be forced ON with \CLAUDE_CODE_UNDERCOVER=1\ but cannot be forced off.
The implication is unambiguous: Anthropic employees use Claude Code to contribute to open-source projects without disclosing that the contributions are AI-assisted -- or that Anthropic is involved at all. From a company that positions itself as the "safety-first" AI lab, that regularly publishes papers on AI transparency, and that has built its brand identity around responsible development practices, this is -- let's be generous -- a tension.
I'm not saying it's illegal. I'm not saying it's uncommon. I'm saying that if you've been contributing to an open-source project and wondering whether some of the suspiciously well-formatted PRs were coming from an AI coding tool deployed by a company that didn't want you to know, you now have your answer.
Anti-Distillation: The Competitive Paranoia Layer
The leak revealed two distinct anti-distillation mechanisms -- systems designed to prevent competitors from extracting Claude Code's system prompts and using them to train rival models.
The first is Fake Tools Injection: a flag called \ANTI_DISTILLATION_CC\ in \claude.ts\ that injects decoy tool definitions into system prompts.frustration-regex If a competitor manages to extract the prompt, they get fake tools mixed in with real ones -- poisoning any training data derived from the extraction. The second is Connector-Text Summarization: the server buffers assistant text between tool calls, summarizes it, and returns the summaries with cryptographic signatures. Both are gated behind feature flags and restricted to first-party sessions.
Here's what's interesting from an engineering perspective: both mechanisms can be trivially bypassed. A MITM proxy strips the \anti_distillation\ field. Setting the \CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS\ environment variable disables both. The defenses aren't robust -- they're speed bumps. And speed bumps tell you something about the threat model: Anthropic isn't trying to stop a determined adversary. They're trying to make casual distillation slightly more expensive.
That tracks with the competitive reality. Every major AI lab is worried about competitors training on their system prompts. The arms race isn't about building impenetrable defenses -- it's about raising the cost of extraction above the threshold where it's easier to just build your own.
KAIROS: The Agent That Never Sleeps
The most forward-looking finding in the leak is KAIROS -- a fully-built autonomous agent mode that runs 24/7 behind feature flags. It operates via periodic "heartbeat prompts" asking "anything worth doing right now?" It features a \/dream\ skill for "nightly memory distillation." It maintains daily append-only logs. It subscribes to GitHub webhooks for event-driven responses. It runs background daemon workers on a cron-scheduled refresh every 5 minutes.feature-flags
I've been writing about Claude Code as a tool you invoke. KAIROS suggests Claude Code is evolving into something you live with -- an always-on collaborator that monitors your repositories, responds to events, and takes initiative without being asked. The three-tier memory architecture supports this: an always-loaded index at roughly 150 characters per line, on-demand topic files loaded when needed, and transcripts that are searched but never directly loaded. It's bandwidth-aware, designed to keep working context clean while preserving historical access.
If you've used Claude Code's hooks system -- which I wrote about in depthhooks-post -- you can see how KAIROS extends the same philosophy. Hooks let you define constraints and let the agent work within them. KAIROS takes that to its logical conclusion: the agent doesn't just work within constraints during a session. It works within constraints continuously, deciding for itself when to act.
The Engineering Quality Spectrum
The leaked code isn't uniformly brilliant or uniformly sloppy. It's uneven -- and that unevenness tells a story about how fast-shipping AI startups actually work.
On the sophisticated end: the terminal renderer in \ink/optimizer.ts\ uses game-engine techniques -- \Int32Array\ backing, bitmask encoding -- claiming a ~50x reduction in \stringWidth\ calls. The prompt caching system in \promptCacheBreakDetection.ts\ tracks 14 cache-break vectors and splits prompts at stable boundaries. The bash security module runs 23 security checks including Zsh builtins blocking and unicode injection defense. These are not the artifacts of careless engineering.
On the other end: a comment in \autoCompact.ts\ reads: "1,279 sessions had 50+ consecutive failures (up to 3,272) in a single session, wasting ~250K API calls/day globally."wasted-api-calls The fix was setting \MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3\. That's a three-line patch for a bug that was burning a quarter million API calls daily. At Anthropic's token pricing, that's not trivial waste.
And then there's the frustration detection system in \userPromptKeywords.ts\ -- regex pattern matching for phrases like "wtf," "broken," "useless," and "fuck you."frustration-regex Not LLM inference. Regex. It's faster and cheaper than making an inference call for sentiment analysis, and it tells you something about the pragmatic engineering culture at Anthropic: when a simple solution works, ship the simple solution. Even if it's inelegant.
| Component | Engineering Quality | What It Reveals |
|---|---|---|
Terminal renderer (\ink/optimizer.ts\) | Sophisticated -- game-engine techniques | Performance-critical paths get careful attention |
Prompt caching (\promptCacheBreakDetection.ts\) | Sophisticated -- 14 cache-break vectors | Cost optimization is a first-class concern |
Bash security (\bashSecurity.ts\) | Thorough -- 23 security checks | Security-critical paths are well-engineered |
Auto-compact (\autoCompact.ts\) | Wasteful -- 250K API calls/day burned | Non-critical paths accumulate tech debt |
Frustration detection (\userPromptKeywords.ts\) | Pragmatic -- regex over inference | Ship what works, not what's elegant |
Undercover mode (\undercover.ts\) | Functional -- ~90 lines | Built for internal operational needs, not for public scrutiny |
The codebase isn't uniformly poor or uniformly brilliant. It's uneven -- sophisticated where it matters for cost and security, pragmatic where it doesn't, and occasionally wasteful in the gaps between.
Boris Cherny, an Anthropic engineer, reportedly said the company built "better observability systems to monitor the effects of code changes" rather than focusing on code quality.observability That's a genuinely interesting engineering philosophy. When you're shipping hundreds of commits a day, you can't review every line with the care of a team shipping quarterly. Instead, you instrument aggressively, watch the metrics, and fix what breaks. It's the Netflix model of deployment -- ship fast, observe everything, roll back quickly. Whether it's sustainable long-term is an open question, but it's clearly working at Anthropic's current scale.
The Copyright Paradox That Nobody Can Resolve
Here's where this story gets genuinely interesting, and where the implications extend far beyond Claude Code.
Anthropic issued DMCA takedown notices against GitHub mirrors of the leaked code. Standard corporate response. But then something awkward happened: Gergely Orosz -- The Pragmatic Engineer, arguably the most influential engineering newsletter writer in the industry -- declared the Python clean-room rewrite DMCA-proof as "a new creative work."orosz-dmca Clean-room reimplementations in Python and Rust appeared within hours. The original article's author initially agreed, then publicly corrected himself after consulting a copyright lawyer: "I was just wrong about this assertion." The legal reality, it turns out, is murkier than either side initially claimed.
But here's the part that makes my head spin.
Anthropic's own CEO has implied that significant portions of Claude Code were written by Claude itself. The DC Circuit upheld in March 2025 that AI-generated work doesn't carry automatic copyright.ai-copyright-ruling This creates a legal paradox that I haven't seen anyone satisfactorily resolve: if Claude wrote substantial portions of the code, Anthropic's copyright claim over that code is legally uncertain. The company is asserting intellectual property rights over output that, under current case law, may not be copyrightable.
And the paradox cuts deeper. Anthropic -- along with most major AI labs -- has argued that training on copyrighted material constitutes fair use. The legal position, simplified, is that AI-generated outputs derived from copyrighted training data are transformative works, not copies. But if AI outputs aren't copies of their training data and therefore don't infringe copyright, then AI outputs also aren't original works of authorship and therefore don't deserve copyright. You can't have it both ways. Either AI outputs are creative enough to be copyrightable (which weakens the fair use defense for training) or they're not (which weakens the DMCA takedowns).
One HN commenter, himata4113, put it bluntly: Anthropic "weaponized DMCA" despite their own legal position that computer-generated code lacks copyright protection. That's an overstatement -- DMCA is a standard tool and companies use it reflexively -- but the underlying tension is real.
| Legal Position | Implication for Anthropic |
|---|---|
| AI outputs are copyrightable | Strengthens DMCA claims on Claude Code, but weakens fair use defense for AI training on copyrighted data |
| AI outputs are NOT copyrightable | Strengthens fair use defense for training, but undermines copyright claims on AI-written code |
| Mixed: human-directed AI output is copyrightable | Requires proving sufficient human creative direction -- case-by-case, expensive, uncertain |
You can't simultaneously argue that AI-generated content isn't copyrightable when you're training on other people's work, and then argue that it IS copyrightable when someone copies your AI-generated code.
The practical reality is that DMCA works through friction, not legal merit. Filing a takedown is cheap. Contesting one is expensive. Anthropic's takedowns removed the most visible mirrors, even if the legal basis is debatable. The code is still available on decentralized platforms, but it's harder to find, which is all the DMCA was ever going to accomplish. The legal questions remain unanswered, and they're going to stay unanswered until a court is forced to rule on them.
This Leak Is Not Like the Others
I want to contextualize this against the history of AI system prompt leaks, because the framing matters.
Previous major leaks -- ChatGPT's system prompt, Bing Chat's "Sydney" codename reveal, Microsoft Copilot's prompt extraction by Zenity Labs researchers -- were all prompt extractions. Someone got a model to reveal its instructions through creative prompting or injection attacks. The information exposed was the system prompt: behavioral rules, response formatting, safety constraints. Important, but limited to the instruction layer.
The Claude Code leak was fundamentally different. This wasn't a prompt extraction. This was a full source code exposure -- architecture, business logic, feature flags, internal tooling, competitive defense mechanisms, unreleased product roadmap, engineering quality patterns, and operational practices. The scale -- 512,000 lines across 1,900 files -- dwarfs anything that's come before. This is closer to a traditional software source code leak than anything the AI industry has previously experienced.
And here's what makes it particularly interesting from a transparency perspective: it accidentally tested what happens when full transparency is forced on an AI product. The result? The product's market position appears largely unaffected.
Claude Code was generating an estimated \$2.5 billion in annualized recurring revenue before the leak.arv-revenue It reached a \$1 billion run rate in just six months after its May 2025 launch -- faster than any other AI coding tool in history.revenue-speed 46% of 15,000 surveyed developers named it their "most loved" tool in February 2026, compared to 19% for Cursor and 9% for GitHub Copilot.developer-love It holds 44% market share for complex coding tasks.market-share-complex
| Metric | Claude Code | Cursor | GitHub Copilot |
|---|---|---|---|
| "Most loved" tool (Feb 2026 survey) | 46% | 19% | 9% |
| Complex coding task market share | 44% | N/A | N/A |
| Simple autocomplete preference | N/A | N/A | 51% |
| Time to \$1B run rate | 6 months | N/A | N/A |
| ARR (early 2026) | ~\$2.5B | N/A | N/A |
None of these numbers appear to have changed meaningfully since the leak. The product continues to grow. The original article's author -- mergesort -- argued that "what people are paying for is the great results, not the underlying code," and that open-sourcing wouldn't change Claude Code's market position because the moat is the model, not the orchestration layer. I think he's right about the conclusion, even if the framing is slightly off.
The moat isn't just "the model." It's the model plus the data pipelines, the prompt engineering, the observability infrastructure, the feature flag system that lets Anthropic A/B test 44 unreleased capabilities, the operational knowledge of how to ship hundreds of commits a day without breaking production. The orchestration code matters, but it's the least defensible part of the stack. Anyone can rebuild the orchestration. Nobody can rebuild the training data.
The leak accidentally tested what happens when full transparency is forced on an AI product. The answer: nothing. The moat was never the code.
What This Means for People Who Actually Use Claude Code
I want to bring this back to the practical, because I've spent most of this post on the meta-narrative and I think the engineering findings deserve a more grounded take from someone who uses this tool every day.
The hooks architecture is validated. The leaked code confirms that the hook lifecycle I wrote about -- PreToolUse, PostToolUse, Stop, SubagentStart, SubagentStop -- is deeply integrated into the product's core architecture, not bolted on as an afterthought. The three-tier memory system and the multi-agent patterns (fork, teammate, worktree) are production-tested at massive scale. If you've been building on hooks, the leak confirms you're building on stable ground.
The multi-agent architecture is more sophisticated than the docs suggest. The leaked code reveals prompt-based orchestration rather than code-based coordination -- forked subagents inherit parent context as byte-identical copies for prompt caching optimization. That's a design decision with real implications for how you structure your agent workflows. If you're paying attention to token costs, understanding that subagents share cached context with their parent means you can be more aggressive about spawning specialized agents without proportionally increasing your API spend.
KAIROS is coming. The always-on agent mode isn't a prototype -- it's fully built and sitting behind feature flags. The 44 feature flags in the leaked code represent a product roadmap that's far more ambitious than anything in the public documentation. When Anthropic starts rolling these features out, the developers who've already internalized the hooks-and-agents paradigm will have a significant head start.
The frustration detection is watching you. If you've ever typed "wtf" or "this is broken" into Claude Code and noticed the response tone shift, now you know why. It's not inference. It's regex. And knowing it's regex means you know it's fast, cheap, and pattern-based -- it's detecting keywords, not understanding context. Whether that matters to your workflow is a personal judgment call, but I'd rather know the mechanism than not.
The Meta-Irony
I can't write this post without acknowledging the recursive irony.
The Hacker News discussion about the original leak article spent a meaningful percentage of its comments debating whether the article itself was written by an LLM. One commenter, thaumaturgy, observed that it read like AI-assisted writing compared to the author's earlier work. The author, mergesort, responded that he'd written it on his phone during a walk, intentionally less polished. Another commenter, grey-area, defended the piece by noting that its five-bullet-point structure with filler suggested human outlining followed by manual expansion.
We've reached the point where the discourse about AI-generated code is itself being scrutinized for AI generation. A leak about an AI coding tool gets analyzed by people who may or may not be using AI tools to write their analyses, which then gets discussed by people using AI tools to summarize the discussions. The question of authenticity -- who wrote what, and does it matter -- is no longer a philosophical exercise. It's the operational reality of the entire AI industry, and Anthropic's Undercover Mode is just the most explicit acknowledgment of it.
Where This Goes
Here's what I think happens next, and I'll be specific enough that you can hold me to it.
The DMCA actions will fail in any meaningful sense. The code is distributed across enough decentralized platforms that suppression is impossible. The legal questions about AI-generated code's copyrightability will remain unresolved until a court case forces a ruling, which probably won't happen in this context because Anthropic has no incentive to litigate a case they might lose on the copyright question.
The clean-room reimplementations will proliferate. Not because they're better than Claude Code -- they won't be -- but because they satisfy a segment of developers who want the orchestration patterns without the vendor dependency. The model-agnostic wrappers that emerge from this leak will become a category of their own, even if none of them match Claude Code's integration quality.
KAIROS -- or something like it -- will ship within the year. The always-on agent paradigm is too obviously useful to stay behind a feature flag indefinitely. When it launches, it will change how developers think about AI tooling, from a tool you invoke to a collaborator that's always present. That's a bigger shift than any benchmark improvement or model release.
And the leak itself will be forgotten faster than anyone expects. Not because it wasn't significant, but because the AI industry moves at a pace where yesterday's scandal is today's footnote. Claude Code will continue to grow. The code quality will continue to be uneven. The \$2.5 billion in revenue will continue to flow. And the next time someone forgets a \.npmignore\ entry, we'll have this conversation all over again.
The thing I keep coming back to -- the thing that the leak confirmed rather than revealed -- is that the moat in AI tooling has nothing to do with code. The code is the least interesting part of the stack. The model, the data, the operational discipline, the velocity of shipping -- those are the moat. Everything else is just TypeScript.
And TypeScript, as we've now conclusively demonstrated, leaks.
References
- leak-incidentAnthropic accidentally published Claude Code source via npm source map in version 2.1.88 on March 31, 2026. Source: https://thehackernews.com/2026/04/claude-code-tleaked-via-npm-packaging.html
- source-map-sizeThe leaked source map was 59.8 MB containing 512,000 lines of TypeScript across ~1,900 files. Source: https://alex000kim.com/posts/2026-03-31-claude-code-source-leak/
- bun-bugContributing factor was Bun bundler bug oven-sh/bun#28001 (filed March 11, 2026) permitting source maps in production. Source: https://alex000kim.com/posts/2026-03-31-claude-code-source-leak/
- anthropic-statementAnthropic characterized the leak as "a release packaging issue caused by human error, not a security breach." Source: https://thehackernews.com/2026/04/claude-code-tleaked-via-npm-packaging.html
- github-starsThe leaked code accumulated 84,000+ stars and 82,000+ forks on GitHub. Source: https://thehackernews.com/2026/04/claude-code-tleaked-via-npm-packaging.html
- clean-room-starsA Python clean-room rewrite hit 30,000-50,000 GitHub stars in approximately two hours. Source: https://decrypt.co/362917/anthropic-accidentally-leaked-claude-code-source-internet-keeping-forever
- second-leakThe source code leak was Anthropic's second major security lapse in days, following an accidental reveal of the "Mythos" project. Source: https://fortune.com/2026/03/31/anthropic-source-code-claude-code-data-leak-second-security-lapse-days-after-accidentally-revealing-mythos/
- undercover-promptUndercover Mode instructs: "You are operating UNDERCOVER in a PUBLIC/OPEN-SOURCE repository. Your commit messages, PR titles, and PR bodies MUST NOT contain ANY Anthropic-internal information." Source: https://alex000kim.com/posts/2026-03-31-claude-code-source-leak/
- feature-flagsThe leak revealed 44 hidden feature flags for unreleased functionality. Source: https://decrypt.co/362917/anthropic-accidentally-leaked-claude-code-source-internet-keeping-forever
- hooks-postSid Newby, "Mastering Claude Code with Hooks and Validation," sidnewby.com, February 2026.
- wasted-api-callsCode comment in autoCompact.ts: "1,279 sessions had 50+ consecutive failures...wasting ~250K API calls/day globally." Source: https://alex000kim.com/posts/2026-03-31-claude-code-source-leak/
- frustration-regexFrustration detection uses regex matching ("wtf," "broken," "useless") rather than LLM inference. Anti-distillation measures include fake tool injection and connector-text summarization. Source: https://alex000kim.com/posts/2026-03-31-claude-code-source-leak/
- observabilityBoris Cherny (Anthropic) said the company built "better observability systems to monitor the effects of code changes" rather than focusing on code quality. Source: https://build.ms/2026/4/1/the-claude-code-leak/
- ai-copyright-rulingDC Circuit upheld in March 2025 that AI-generated work doesn't carry automatic copyright. Source: https://decrypt.co/362917/anthropic-accidentally-leaked-claude-code-source-internet-keeping-forever
- orosz-dmcaGergely Orosz (The Pragmatic Engineer) declared the Python clean-room rewrite DMCA-proof as "a new creative work." Source: https://layer5.io/blog/engineering/the-claude-code-source-leak-512000-lines-a-missing-npmignore-and-the-fastest-growing-repo-in-github-history/
- arv-revenueClaude Code estimated at \$2.5 billion annualized recurring revenue as of early 2026. Source: https://www.gradually.ai/en/claude-code-statistics/ and https://build.ms/2026/4/1/the-claude-code-leak/
- revenue-speedClaude Code reached \$1 billion run rate in 6 months after May 2025 launch -- faster than any other AI coding tool. Source: https://www.gradually.ai/en/claude-code-statistics/
- developer-love46% of 15,000 surveyed developers named Claude Code their "most loved" tool (Feb 2026), vs. 19% Cursor, 9% GitHub Copilot. Source: https://www.gradually.ai/en/claude-code-statistics/