Technical breakdown of Claude Code's leaked source: anti-distillation via fake tool injection, native API attestation in Zig, frustration detection by regex, 250K wasted API calls/day from a 3-line bug, and KAIROS autonomous agent scaffolding.
| Mechanism | How It Works | Bypass |
|---|---|---|
| Fake tools injection (ANTI_DISTILLATION_CC flag) | Server silently injects decoy tool definitions into the system prompt when anti_distillation: ['fake_tools'] sent in API requests. Gated behind GrowthBook flag tengu_anti_distill_fake_tool_injection, only active for first-party CLI sessions. | MITM proxy strips anti_distillation field from request bodies; set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS env var; use third-party API provider or SDK entrypoint instead of CLI. |
| Connector-text summarization | API buffers assistant text between tool calls, summarizes it, returns summary with cryptographic signature. Original text restored from signature on subsequent turns. Recorded API traffic only captures summaries, not full reasoning chains. | Anthropic-internal only (USER_TYPE === 'ant'). External users never encounter it. |
/\b(wtf|wth|ffs|omfg|shit(ty|tiest)?|dumbass|horrible|awful|
piss(ed|ing)? off|piece of (shit|crap|junk)|what the (fuck|hell)|
fucking? (broken|useless|terrible|awful|horrible)|fuck you|
screw (this|you)|so frustrating|this sucks|damn it)\b/
userPromptKeywords.ts detects user frustration with regex. A regex is faster and cheaper than an LLM inference call just to check if someone is swearing at the tool.
| Component | Details |
|---|---|
| /dream skill | Nightly memory distillation |
| Daily logs | Append-only |
| GitHub webhooks | Webhook subscriptions |
| Background daemon | Worker processes |
| Cron refresh | Scheduled every 5 minutes |
| Status | Heavily feature-gated; scaffolding for always-on background agent exists but unclear how far along |
| Finding | Details |
|---|---|
| April Fools companion | buddy/companion.ts: Tamagotchi-style system. 18 species, rarity tiers (common to legendary), 1% shiny chance, RPG stats (DEBUGGING, SNARK). Deterministic from user ID via Mulberry32 PRNG. Species names encoded with String.fromCharCode() to dodge grep. |
| Terminal rendering | Int32Array-backed ASCII char pool, bitmask-encoded style metadata, patch optimizer merging cursor moves and canceling hide/show pairs, self-evicting line-width cache ('~50x reduction in stringWidth calls during token streaming'). |
| Bash security | 23 numbered checks in bashSecurity.ts: 18 blocked Zsh builtins, defense against Zsh equals expansion (=curl bypassing permission checks), unicode zero-width space injection, IFS null-byte injection, malformed token bypass found during HackerOne review. |
| Prompt cache economics | promptCacheBreakDetection.ts tracks 14 cache-break vectors. 'Sticky latches' prevent mode toggles from busting the cache. One function annotated DANGEROUS_uncachedSystemPromptSection(). |
| Multi-agent coordinator | coordinatorMode.ts: orchestration algorithm is a prompt, not code. Instructions include 'Do not rubber-stamp weak work' and 'You must understand findings before directing follow-up work.' |
| Code quality | print.ts: 5,594 lines, single 3,167-line function, 12 nesting levels. Uses Axios (recently compromised on npm with RAT-dropping malicious versions). |
| 250K wasted API calls/day | 1,279 sessions had 50+ consecutive autocompact failures (up to 3,272). Fix: MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3. Three lines of code. |
Google's Gemini CLI and OpenAI's Codex are open source, but those are agent SDKs (toolkits), not the full internal wiring of a flagship product
↓
The real damage is feature flags (KAIROS, anti-distillation): product roadmap details competitors can now see and react to
↓
Code can be refactored, but strategic surprise can't be un-leaked
↓
Anthropic acquired Bun late last year; a Bun bug (oven-sh/bun#28001, filed March 11) serves source maps in production despite docs saying disabled. If this caused the leak, Anthropic's own toolchain shipped a known bug that exposed their own source code.