Thorsten Meyer | ThorstenMeyerAI.com | April 2026


Executive Summary

On March 31, 2026, a misconfigured source map file in Anthropic’s npm package inadvertently exposed the complete TypeScript source code for Claude Code — 1,900 files, 512,000+ lines, the DNA of the industry’s most advanced CLI agent. Within hours, security researcher Chaofan Shou had identified the path. The repository was forked over 41,500 times before Anthropic could respond. Anthropic confirmed it was a release packaging error caused by human error, not a security breach.

This was the moment the black box of agentic AI was opened.

What the source reveals is not just a CLI tool. It is a distributed operating system for intelligence — with a dynamic system prompt assembly line, a sophisticated permission engine (the “YOLO classifier”), auto-compaction memory management, a teleportation protocol for moving agent state between local and cloud environments, a mobile bridge for phone-to-desktop task dispatch, and an unreleased autonomous daemon called “Kairos” that watches, logs, and proactively acts without waiting for human input.

Claude Code is not winning because it has the smartest model. It is winning because Anthropic has engineered the harness — the code around the model — at a level of sophistication that no competitor has publicly demonstrated. The 6x performance gap that Stanford’s IRIS Lab documented between harness implementations is visible in every directory of this codebase.

Claude Code Leak – Inside the Agentic OS
ThorstenmeyerAI.com · Analysis Report March 31, 2026
Breaking Leak

INSIDE
Claude Code
THE LEAK

A forensic audit of the 512,000-line TypeScript codebase accidentally exposed on March 31, 2026 — revealing Anthropic’s complete agentic operating system architecture.

512K
Lines of Source
33+
Bridge Files
6
Core Systems
444
Line: getSystemPrompt()
01
Agentic Development: The Complete Guide to AI-Assisted Coding with Claude, Cursor, and Beyond

Agentic Development: The Complete Guide to AI-Assisted Coding with Claude, Cursor, and Beyond

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Dynamic Prompt Assembly

constants/prompts.ts · Line 444
The Assembly Line
Claude’s “personality” is not a static file. getSystemPrompt() assembles the prompt dynamically on every session — injecting live Git history, current working directory, active tool list, and session date into a cached pipeline.
getSystemPrompt(tools, model,
additionalWorkingDirectories?,
mcpClients?): Promise<string[]>
01
Environment Injection
What Gets Injected
Three parallel async calls populate the prompt before Claude sees a single token:
getSkillToolCommands(cwd)
getOutputStyleConfig()
computeSimpleEnvInfo(model, dirs)
The result: Claude knows your repo before you say a word.
02
TypeScript Programming Language, Software Developing, Coding T-Shirt

TypeScript Programming Language, Software Developing, Coding T-Shirt

TypeScript adds additional syntax to JavaScript to support a tighter integration with your editor and uses type inference…

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

The Kairos Daemon & Dream System

Autonomous Core
“Kairos” — The Background Agent
A persistent autonomous daemon that continues working while the human is absent. It monitors repository state, queues deferred tasks, and can open PRs before the engineer returns from sleep — embodying the “fix your PRs before you wake up” promise.
Memory Architecture
The Dream System — CACHED_MAY_BE_STALE
Long-term state is preserved across sessions via a structured cache layer. The internal flag CACHED_MAY_BE_STALE signals a deliberate latency-over-correctness trade-off: speed at session startup trumps guaranteed freshness of context data.
Personality Layer
“Buddy” — Virtual Pet State
Hidden within the codebase: a “Buddy” virtual pet subsystem whose state evolves across sessions. Anthropic uses it to maintain a persistent personality fingerprint — an agent that “feels” like it knows you over time.
“Anthropic isn’t winning because they have the smartest model. They are winning because they have built a Distributed Operating System for Intelligence.
— Source article, March 31, 2026
03
Customer-based IP Service Monitoring with Mobile Software Agents (Whitestein Series in Software Agent Technologies and Autonomic Computing)

Customer-based IP Service Monitoring with Mobile Software Agents (Whitestein Series in Software Agent Technologies and Autonomic Computing)

Used Book in Good Condition

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

The Mobile Bridge

bridge/ · 33+ files
Long-Running Bridge Server
Your local machine becomes a remotely commanded node. The bridgeMain.ts daemon long-polls Anthropic’s cloud for instructions dispatched from the iOS/Android app — then executes locally and returns results up the chain.
📱
Input
Mobile App
☁️
Dispatch
CCR Cloud
🔁
Poll
Bridge Server
💻
Execute
Local Machine
⬆️
Return
Result to Cloud
04
Cloud Security Fundamentals: Building the Foundations for Secure Cloud Platforms

Cloud Security Fundamentals: Building the Foundations for Secure Cloud Platforms

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Transport Protocol Transition

Version Protocol Mechanism Key Trade-off
V1 Hybrid Legacy WebSocket + HTTP POST Real-time read via WebSocket; writes batched at 500 messages per POST to reduce overhead Lower bandwidth cost; slight write latency
V2 SSE Current Server-Sent Events SSETransport.ts with sequence numbers; reconnects replay missed output without data loss Full continuity on flaky networks; slightly higher complexity
05

Trust Systems

Autonomous Trust
YOLO Classifier
A classifier that scores each pending action against risk thresholds. Low-risk operations execute automatically. High-risk operations — like rm -rf — escalate via the SDKControlRequest flow to a human approval gate.
Remote Permissions
SDKControl Request/Response
When the remote agent needs approval, a request packet is sent down the bridge to surface a UI dialog or push notification on the user’s device. Only after an explicit SDKControlResponse does cloud execution resume.
06

Remote Sessions

CCR Infrastructure
Cloud Compute Runtime — The Hidden Layer
The leak confirms a fully operational Remote Agent infrastructure. Sessions are automatically named by a lightweight model (likely Haiku) based on the current task context. The CCR acts as the coordination plane between mobile dispatches, bridge polling, and the Kairos daemon — all running in parallel without user involvement.
07

The 6 Core Systems

Prompt
Dynamic Assembly
Context-aware system prompt built fresh each session
Daemon
Kairos Agent
Background autonomous task execution while you sleep
Memory
Dream System
Cross-session state with speed-first cache semantics
Bridge
Mobile Control
Long-poll server makes local machine remotely commandable
Trust
YOLO Classifier
Risk-scored auto-approval with human escalation gate
Transport
V2 SSE Layer
Sequence-numbered streams survive network interruptions

For enterprise leaders, the leak reveals the architecture that will define the next generation of AI agents: dynamic prompt assembly, autonomous permission engines, long-running daemon modes, distributed execution across local and cloud environments, and memory systems that persist across sessions. Every organization deploying AI agents should study this blueprint.

MetricValue
Source files exposed1,900 TypeScript files
Lines of code512,000+
GitHub forks (within hours)41,500+
Built-in tools~40 (permission-gated)
Base tool definition29,000 lines TypeScript
Leak causenpm source map → R2 bucket
DiscoveryChaofan Shou (@fried_rice)
DateMarch 31, 2026
Auto-compact threshold13,000-token buffer
Max consecutive compact failures3 (circuit breaker)
YOLO fast-reject stage64 tokens
YOLO deep-thinking stage4,096 tokens
Consecutive denial limit3 (fallback to manual)
Session denial limit20 (force human control)
Bridge pollingPOST /v1/environments/{id}/work/poll
Transport V1WebSockets + batched HTTP (500 msgs)
Transport V2SSE with sequence numbers
Internal codenamesCapybara (Claude 4.6), Fennec (Opus 4.6), Numbat (unreleased)
Claude Code ARR$2.5 billion (Feb 2026)
Enterprise share>50% of CC revenue
OECD unemployment5.0% (stable)
OECD broadband (advanced)98.9%

1. The Architecture: Not a Chatbot — A Distributed Operating System

The leaked source code reveals that Claude Code is not an AI chatbot with a terminal interface. It is a multi-layered operating system for software intelligence, with distinct subsystems for cognition (prompts), perception (tools), memory (compaction), security (permissions), and distribution (teleport/bridge).

The Five Layers

LayerDirectoryFunctionEnterprise Relevance
Cognitionconstants/prompts.tsDynamic system prompt assemblyHow agents understand context
Perceptiontools/ (~40 tools)Tool orchestration with concurrent/serial schedulingHow agents interact with systems
Memoryservices/compact/Auto-compaction + session memoryHow agents maintain state over hours
Securityutils/permissions/YOLO classifier + circuit breakersHow agents govern themselves autonomously
Distributionutils/teleport.tsx, bridge/Local↔cloud state transfer; mobile dispatchHow agents operate across environments

The Dynamic Prompt Assembly Line

The system prompt is not a static text file. It is a dynamic, cached assembly line (getSystemPrompt() at line 444 of constants/prompts.ts). The prompt is built piece-by-piece based on environment: directory, Git history, date, active tools, MCP connections, CLAUDE.md memory files, output style configuration, and language settings.

Prompt SectionSourceCaching
Core rulesStatic sectionsCached (reused across turns)
Environment infocomputeSimpleEnvInfo()Dynamic (changes per context)
MemoryloadMemoryPrompt()Dynamic (CLAUDE.md files)
MCP instructionsgetMcpInstructionsSection()Uncached (servers connect/disconnect)
Skill commandsgetSkillToolCommands()Dynamic
Output stylegetOutputStyleConfig()Dynamic
ScratchpadgetScratchpadInstructions()Cached

The caching architecture (systemPromptSections.ts) is the speed secret. By splitting the prompt into cached and dynamic blocks, Anthropic swaps context-specific information without reprocessing static rules — saving massive latency and cost on every turn.

CLAUDE.md as Permanent Memory

The code confirms that CLAUDE.md files are treated as manual overrides for agent behavior on a per-repository basis. These files are injected directly into the user context, providing long-term project instructions that persist across sessions. This is the organic context capture mechanism that makes Claude Code’s bottom-up enterprise strategy work.

“Claude Code is not a chatbot with a terminal. It is a distributed operating system for intelligence: cognition, perception, memory, security, and distribution — five layers, 512,000 lines, and a level of engineering that explains the $2.5 billion ARR.”


2. The YOLO Classifier: Autonomous Permission Engineering

The most architecturally significant discovery is the autonomous permission engine — a two-stage AI governance system designed to let the agent run without human approval for safe operations while catching dangerous ones.

The Two-Stage Architecture

StageLocationToken BudgetFunction
Fast-rejectyoloClassifier.ts64 tokensCatch obvious violations instantly
Deep-thinkingyoloClassifier.ts4,096 tokensAnalyze conversation transcript for intent alignment

The classifier uses Sonnet 4.6 as the evaluation model. Critically, it only sees tool calls — not the assistant’s conversational text. This prevents prompt injection where the agent might try to convince the classifier that a dangerous action is safe.

The Safe List (Fast Path)

Certain tools skip the AI classifier entirely to save latency:

Tool CategoryExamplesRationale
Read-only operationsls, grep, glob, LSP lookupsCannot modify state
Task managementTodoWrite, TaskCreate, TaskListLow-risk metadata
CoordinationSleep toolNo external effects

The Circuit Breakers

BreakerThresholdAction
Consecutive denials3 in a rowFallback to manual approval mode
Session denials20 totalForce human control; assume “gone rogue”
Compact failures3 consecutiveDisable auto-compaction for session

Dangerous Rule Stripping

When entering Auto Mode, the system proactively strips dangerous permissions from the environment: it searches for and disables commands like iex, invoke-expression, and nested shells (wsl, pwsh) to prevent the agent from escaping its sandbox while the human is not watching.

What This Means for Enterprise

The YOLO classifier is the most mature autonomous permission system publicly documented. It demonstrates that AI agent governance is not just policy — it is engineering: two-stage classification, transcript sanitization, safe-list fast paths, circuit breakers, and proactive sandbox hardening. Every enterprise deploying autonomous agents should study this architecture.

“The YOLO classifier is two-stage: 64-token fast-reject, then 4,096-token deep analysis. It sees tool calls but not conversational text — preventing prompt injection. Three consecutive denials force manual mode. Twenty session denials assume the agent has gone rogue.”


3. The Memory System: How Agents Maintain State Over Hours

The auto-compaction system (services/compact/autoCompact.ts) is how Claude Code maintains working memory over extended sessions without losing context.

How Auto-Compaction Works

StepTriggerAction
1Conversation hits 13,000-token buffershouldAutoCompact() returns true
2Session memory compaction attemptedtrySessionMemoryCompaction() extracts key information
3If session memory failsFull compactConversation() triggered
4Summary generatedOld messages cleared; summary preserved as working memory
5Post-compact cleanupCache baselines reset; prompt cache break detection updated
6Circuit breaker3 consecutive failures → disable for session

The Three-Tier Token Estimation

The system uses a three-tier estimation approach to predict costs before they happen — ensuring the agent does not exceed API budgets on recursive operations.

Session Memory vs. Legacy Compaction

ApproachMechanismTrade-off
Session memory compactionExtract key information; prune messagesPreserves signal; loses raw detail
Legacy compactionFull summarization; replace all messagesMore aggressive; higher information loss
Circuit breakerDisable after 3 failuresPrevents infinite retry loops

The Recompaction Chain

The code tracks whether the current compaction is a “recompaction” — a second compaction within the same chain. This prevents runaway summarization loops where the agent keeps trying to compress already-compressed content.

“Auto-compaction is not ‘forgetting.’ It is structured memory management: compress, preserve the summary, track recompaction chains, and circuit-break after 3 failures. This is how an agent maintains working memory over hours of coding.”


4. The Teleport Protocol and Mobile Bridge: Distributed Agent Execution

The most architecturally advanced components are the teleport protocol (utils/teleport.tsx) and the bridge system (bridge/ directory, 33+ files) — infrastructure for moving agent state across environments.

The Teleport Protocol

FunctionMechanismPurpose
Pre-flight validationvalidateGitState()Ensure repo clean; sync with remote
Session namingHaiku model auto-names based on taskHuman-readable remote sessions
State transferGit bundles (standard) or direct push (autofix)Move context to cloud
skipBundle modeDirect Git push access on CCRFor autofix-pr: clone → fix → push

The Bridge: Phone-to-Desktop Dispatch

ComponentFileFunction
Long-polling serverbridgeMain.tsLocal machine polls Anthropic API for work
Dispatch endpointPOST /v1/environments/{id}/work/pollCloud → local instruction passing
Mobile appiOS/AndroidUser sends commands from phone
Result returnHTTP responseExecution results sent back up chain

The Two Transport Generations

VersionProtocolTrade-off
V1 (Hybrid)WebSockets (read) + batched HTTP POST (500 msgs, write)Lower overhead; batch efficiency
V2 (SSE)Server-Sent Events with sequence numbersInternet flicker resilience; no lost output

Remote Permission Handling

When the agent runs in the cloud and needs approval for a dangerous action, it sends a SDKControlRequest down the bridge. The local UI (or a push notification on your phone) displays an approval dialog. SDKControlResponse fires back to the cloud to resume execution.

The Autofix-PR Architecture

The leaked RemoteAgentTask reveals that autofix-pr is not a local tool — it is a Remote Agent Task that teleports to Anthropic’s CCR (Claude Code Remote) infrastructure:

StepAction
TriggerDeveloper points Claude at a PR URL
TeleportAgent moves to CCR session
AnalyzeRead PR diff, scan CI failure logs, parse reviewer comments
FixRun in high-permission Auto Mode
VerifyPoll CI/CD pipeline; if tests fail, loop restarts
CompletePR is green; agent reports results

“The teleport protocol moves agent state from your terminal to the cloud. The bridge lets you dispatch tasks from your phone. The autofix-PR daemon watches your PR until it is green. This is not a CLI tool. It is a distributed execution platform.”


5. Kairos: The Autonomous Daemon

The leak reveals an entire unreleased mode called Kairos — a persistent, always-running Claude assistant that does not wait for human input.

What Kairos Is

FeatureDescriptionStatus
ModeAutonomous proactive agentFeature-flagged (not yet public)
TriggerKAIROS feature flag in getSystemPrompt()Internal testing
BehaviorWatches, logs, proactively acts on observationsDaemon mode
Prompt“You are an autonomous agent. Use available tools to do useful work.”Different from standard prompt
MemoryIncludes scratchpad instructionsPersistent working state
IntegrationUses all standard tools + proactive moduleFull capability access

The Proactive Module

When Kairos is active, the system prompt shifts from “assist the user” to “do useful work autonomously.” The proactive module (proactiveModule.isProactiveActive()) determines whether Kairos should activate. When it does, the entire prompt structure changes — dropping interactive guidance sections and adding autonomous execution instructions.

Kairos + Brief

The source also reveals KAIROS_BRIEF — a variant that provides condensed status updates. This suggests Anthropic is building a mode where the agent runs continuously and provides periodic briefings to the human, rather than waiting for turn-by-turn interaction.


6. OECD Context and Practical Actions

OECD broadband data (98.9% in advanced economies) confirms the infrastructure for distributed agent architectures is universally available. The constraint is not connectivity — it is organizational readiness for the architectural patterns this leak reveals.

Actions for Leaders

1. Study the five-layer architecture as a blueprint. Cognition (dynamic prompts), perception (tool orchestration), memory (auto-compaction), security (permission classifiers), distribution (teleport/bridge). Every enterprise agent platform will converge on this pattern. Build yours accordingly.

2. Implement two-stage permission classification. The YOLO classifier — fast-reject plus deep-analysis, with transcript sanitization and circuit breakers — is the most mature autonomous permission architecture publicly documented. Adapt it.

3. Build execution trace infrastructure for auto-compaction. Claude Code’s memory system works because it logs everything. Your agents need the same: full execution traces that support structured summarization when context limits are reached.

4. Prepare for distributed agent execution. The teleport protocol and bridge infrastructure signal that agents will operate across local, cloud, and mobile environments simultaneously. Architect your agent infrastructure for multi-environment execution from day one.

5. Watch Kairos as the preview of autonomous daemon agents. The shift from “respond when prompted” to “watch, log, and proactively act” is the next architectural phase. Kairos is Anthropic’s answer. Prepare your governance frameworks for agents that do not wait for permission to observe.

ActionOwnerTimeline
Five-layer architecture reviewCTO + AI EngineeringQ2 2026
Permission classification designCISO + AI EngineeringQ2 2026
Execution trace infrastructureCTO + PlatformQ2 2026
Multi-environment agent architectureCTO + ArchitectureQ2–Q3 2026
Daemon agent governance frameworkCISO + LegalQ3 2026

The Bottom Line

512,000 lines. 1,900 files. 41,500 forks. ~40 tools. $2.5B ARR. Five architectural layers. Two-stage permission classifier. Auto-compaction with circuit breakers. Teleport protocol for local-to-cloud state transfer. Mobile bridge for phone dispatch. Kairos autonomous daemon. Internal codenames: Capybara, Fennec, Numbat.

Anthropic is not winning because it has the smartest model. It is winning because it has built a distributed operating system for intelligence — with dynamic prompt assembly, autonomous permission engineering, structured memory management, cross-environment execution, and an unreleased autonomous daemon that watches and acts without human prompting.

The deck of cards has been dropped. The trick is revealed. The architecture that powers the industry’s most advanced AI agent is now public knowledge. The question for every enterprise AI team: how fast can you learn from this blueprint?

The Claude Code leak reveals what the industry should have known: the model is not the product. The harness — the operating system for intelligence wrapped around the model — is the product. And that operating system is more sophisticated than anything the industry assumed.


Thorsten Meyer is an AI strategy advisor who notes that “512,000 lines of harness code” explains both the $2.5 billion ARR and the 6x performance gap from harness choice — and that “accidental open source” is what happens when you ship source maps to npm, which is, ironically, exactly the kind of packaging error that a well-configured Claude Code instance would catch. More at ThorstenMeyerAI.com.


Sources

  1. Chaofan Shou (@fried_rice) — Discovery of Claude Code Source Map Exposure (Mar 31, 2026)
  2. Anthropic — Confirmed npm Packaging Error; “Human Error, Not Security Breach”
  3. The Register — “Anthropic Accidentally Exposes Claude Code Source Code” (Mar 31, 2026)
  4. VentureBeat — “Claude Code Source Code Leaked: Here’s What We Know” (Mar 31, 2026)
  5. Fortune — “Anthropic Leaks Own AI Tool Source Code in Second Major Breach” (Mar 31, 2026)
  6. DEV Community — “Claude Code Leaked via npm Source Maps: What’s Inside” (Mar 31, 2026)
  7. Alex Kim — “Claude Code Source Leak: Fake Tools, Frustration Regexes, Undercover Mode”
  8. The Neuron / eWeek — “Anthropic Leaks Claude Code: A Blueprint for AI Coding Agents”
  9. Apiyi.com — “512,000 Lines Accidentally Open-Sourced: AI Agent Industry Impact”
  10. SiliconANGLE — “Claude Code Source Code Exposed via npm Packaging Error”
  11. ccleaks.com — Claude Code Hidden Features Documentation
  12. Source Analysis — getSystemPrompt(), yoloClassifier.ts, autoCompact.ts, teleport.tsx, bridge/
  13. Internal Codenames — Capybara (Claude 4.6), Fennec (Opus 4.6), Numbat (Unreleased)
  14. Stanford IRIS Lab — Meta-Harness: 6x Performance Gap from Harness Choice
  15. Anthropic — Claude Code: $2.5B ARR, Enterprise >50% (Feb 2026)
  16. OECD — 5.0% Unemployment, 11.2% Youth, 98.9% Broadband

© 2026 Thorsten Meyer. All rights reserved. ThorstenMeyerAI.com

You May Also Like

The Genesis Mission: America’s New AI Moonshot for Scientific Discovery

On November 24, 2025, the United States formally launched what may become…

Market Impact Report: OpenAI–UK MoJ Data-Residency Rollout and Hitachi–OpenAI AI-Infrastructure MoU

Executive take Two moves, one signal: generative AI is crossing from pilots…

Implementing Agentic Commerce (ACP) on Salesforce/Stripe: A Technical Playbook for Merchants

Executive summary Agentic Commerce moves the shopping flow into AI assistants (e.g.,…

Market Impact of the FTC’s Updated Endorsement Guides & Rule Banning Fake Reviews (2023–2025)

Introduction The U.S. Federal Trade Commission (FTC) revised its Guides Concerning the…