Claude Code 500K Lines Code Leak Fully Organized, What's the True Core of the AI Agent?
51.2k lines of code, 1906 files, 59.8 MB source map. In the early hours of March 31, Chaofan Shou from Solayer Labs discovered that Anthropic's flagship product, Claude Code, had exposed the full source code in a public npm repository. Within hours, the code was mirrored on GitHub, with forks surpassing 41k.
This isn't Anthropic's first time making this mistake. When Claude Code was first released in February 2025, a similar source map leak occurred. The version number at that time was v2.1.88, and the leak was due to the same reason: the Bun build tool automatically generated the source map, which was not excluded in the .npmignore file.
Most reports focused on the easter eggs found in the leak, such as a virtual pet system and a "undercover mode" that allowed Claude to anonymously contribute code to open-source projects. But the real question to unpack is why the same Claude model exhibited such different behavior between the web version and Claude Code. What is the 51.2k lines of code really doing?
Model is Just the Tip of the Iceberg
The answer lies in the code structure. According to a GitHub community's reverse analysis of the leaked source code, out of the 51.2k lines of TypeScript, the interface code directly responsible for invoking the AI model accounts for only about 8000 lines, or 1.6% of the total.

What is the remaining 98.4% doing? The two largest modules are the query engine (46k lines) and the tooling system (29k lines). The query engine handles LLM API calls, streaming output, cache orchestration, and multi-turn dialogue management. The tooling system defines around 40 built-in tools and 50 slash commands, forming a plugin-like architecture where each tool has independent permissions control.
Additionally, there are 25k lines of terminal UI rendering code (with a file named print.ts stretching 5594 lines, with a single function spanning 3167 lines), 20k lines of security and permission control (including 23 numbered Bash security checks and 18 Zsh built-in commands that are disabled), and 18k lines of multi-proxy orchestration system.
Machine learning researcher Sebastian Raschka, after analyzing the leaked code, pointed out that the strength of Claude Code compared to the web version of the same model lies not in the model itself but in the software scaffolding built around the model, including repository context loading, dedicated tool dispatch, cache policies, and sub-agent collaboration. He even suggested that if the same engineering architecture were applied to other models like DeepSeek or Kimi, similar programming performance gains could be achieved.
An intuitive comparison can help understand this gap. When you input a question in the ChatGPT or Claude web version, the model processes it and returns an answer, leaving nothing behind at the end of the conversation. However, Claude Code's approach is entirely different. Upon startup, it first reads your project files, understands your codebase structure, remembers preferences like when you last said "do not mock the database in tests," and more. It can directly execute commands in your terminal, edit files, run tests, and when faced with complex tasks, it can break them down into multiple subtasks assigned to different subprocesses for parallel processing. In other words, the web version AI is a question-and-answer window, while Claude Code is a collaborator living on your computer.
Some liken this architecture to an operating system: the 42 built-in tools are akin to system calls, the permission system is similar to user management, the MCP protocol is like device drivers, and the subprocess orchestration is akin to process scheduling. Each tool is initially marked as "unsafe, writable" by default, unless a developer explicitly declares it safe. Tools for editing files will enforce a check to see if you've read the file before allowing modifications. This is not a chatbot with a few add-ons; it's an operating environment with LLM at its core and a complete security mechanism.
This implies one thing: the competitive barrier of AI products may not lie in the model layer but in the engineering layer.
Every Cache Miss Increases Costs Tenfold
Within the leaked code is a file named promptCacheBreakDetection.ts, which tracks 14 potential vectors that could cause a prompt cache invalidation. Why would Anthropic's engineers put in so much effort to prevent cache misses?
A look at Anthropic's official pricing reveals the reason. For example, with Claude Opus 4.6, the standard input price is $5 per million tokens, but if a cache hit occurs, the read price is only $0.5, a 90% discount. In other words, for every cache miss, the inference cost increases tenfold.

This explains the seemingly "overdesigned" architectural decisions in the leaked code. When Claude Code starts, it loads the current git branch, recent commit history, and CLAUDE.md file as context—these static contents are globally cached, with dynamic content separated by boundary markers to ensure conversations do not redundantly process existing contexts. There's also a mechanism called sticky latches in the code to prevent mode switches from disrupting established caches. Subagents are designed to reuse their parent process's cache rather than rebuild their context window.
Here is a detail worth expanding on. Anyone who has used AI programming tools knows that the longer the conversation, the slower the AI's response, because each round of dialogue has to resend the entire history to the model. The common practice is to delete old messages to free up space, but the problem is that deleting any message breaks the continuity of the cache, causing the entire conversation history to be reprocessed, leading to increased latency and cost.
The leaked code contains a mechanism called cache_edits, where instead of actually deleting messages, old messages are marked as "skipped" at the API layer. The model no longer sees these messages, but the cache continuity remains unbroken. This means that in a long conversation lasting hours, after clearing hundreds of old messages, the response speed in the next round is almost as fast as the first round. For the average user, this is the underlying answer to "why Claude Code can support an unlimited long dialogue without slowing down".

According to leaked internal monitoring data (from code comments in autoCompact.ts, dated March 10, 2026), before introducing the automatic compact failure limit, Claude Code wasted about 250,000 API calls per day. There were 1,279 user sessions that experienced 50 or more consecutive compact failures, with the most severe session failing consecutively 3,272 times. The fix was simply adding one line of restriction: MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3.
So, for AI products, model inference cost may not be the most expensive layer; cache management failures are.
44 Switches, Pointing in the Same Direction
The leaked code contains 44 feature flags—precompiled feature switches that have not been publicly released. According to community analysis, these flags are categorized into five groups based on functionality, with the densest being the "Autonomous Agent" class (12 flags), pointing to a system called KAIROS.
KAIROS is referenced in the source code over 150 times; it is a persistent background daemon mode. Claude Code is no longer just a tool that responds when you actively call it but an agent that runs in the background, continuously observing, recording, and proactively acting at the right moment. The condition is not to interrupt the user, and any operation that could block the user for more than 15 seconds will be delayed.

KAIROS also has built-in terminal focus awareness. There is a `terminalFocus` field in the code that detects in real time whether the user is looking at the terminal window. When you switch to the browser or another app, the agent determines that you are "away" and switches to autonomous mode, actively performing tasks, submitting code directly without waiting for your confirmation. When you switch back to the terminal, the agent immediately returns to collaborative mode: first reporting what it has done and then asking for your opinion. The level of autonomy is not fixed but fluctuates in real time with your attention. This solves an embarrassing problem that AI tools have faced for a long time: fully autonomous AI makes people uneasy, while completely passive AI is inefficient. KAIROS's approach is to dynamically adjust the AI's initiative based on the user's attention, behaving obediently when you are focused on it and taking initiative when you are away.
Another subsystem of KAIROS is called autoDream. Every 5 sessions or every 24 hours, the agent initiates a "reflection" process in the background, consisting of four steps. It first scans existing memories to understand what it currently knows. Then it extracts new knowledge from conversation logs. Next, it merges the new and old knowledge, corrects contradictions, and removes duplicates. Finally, it streamlines the index by deleting outdated entries. This design is inspired by the memory consolidation theory in cognitive science. Just as humans organize their memories during sleep, KAIROS organizes project context when the user is away. For ordinary users, this means that the longer you use Claude Code, the more accurately it understands your project, not just "remembering what you said."
The second major category is "Anti-distillation and Security" (8 flags). The most notable among them is the `fake_tools` mechanism. When four conditions are met simultaneously (compile-time flag enabled, CLI entry activated, first-party API used, and GrowthBook remote switch set to true), Claude Code injects fake tool definitions into API requests, aiming to contaminate datasets potentially used in recording API traffic or training competitive models. This represents a new form of defense in the AI arms race. Its goal is not to prevent you from copying but to make you copy incorrect information.
Additionally, the code references the Capybara model alias (divided into standard, fast, and million-context window versions), widely speculated by the community to be the internal alias for the Claude 5 series.
-- Price
Easter Egg: Within 512,000 lines of code lies an electronic pet
Among all the serious engineering architecture and security mechanisms, Anthropic's engineers have also quietly built a complete virtual pet system, internally codenamed BUDDY.
According to leaked code and community analysis, BUDDY is a gamified terminal pet that will appear as an ASCII art bubble next to the user's input box. It features 18 species (including Otter, Salamander, Mushroom, Ghost, Dragon, and a range of original creatures like Pebblecrab, Dustbunny, Mossfrog), divided into five rarity levels: Common (60%), Rare (25%), Epic (10%), Legendary (4%), and Mythic (1%). Each species also has a "Shiny variant," with the rarest being the Shiny Legendary Nebulynx with a one in ten thousand chance of appearing.
Each BUDDY has five attributes: DEBUGGING, PATIENCE, CHAOS, WISDOM, and SNARK. They can also wear hats, including a Crown, Top Hat, Propeller Cap, Halo, Wizard Hat, and even a Mini Duck. The pet you hatch is determined by the hash of your user ID, and Claude will generate its name and personality.
As per the leaked launch schedule, BUDDY was originally set to start closed beta from April 1st to 7th, with a full launch in May, starting with Anthropic's internal employees.
With 512,000 lines of code, 98.4% hardcore engineering, but someone took the time in the end to create an electronic salamander that wears a propeller cap. Perhaps, this is the most human touch in the leaked code.
This content is provided for general informational purposes only and doesn't constitute financial, investment, legal, or tax advice. Any events, rewards, online promotions, or related information mentioned herein should not be considered a recommendation, solicitation, or invitation to purchase, sell, trade, or otherwise deal in any crypto assets. Crypto assets are highly volatile and may result in loss. The availability of WEEX services, products, and related events may vary by region. You are responsible for ensuring that your participation is in accordance with applicable local laws and regulations.
You may also like

Goldman Sachs, OKX Cut Off From Claude AI in Hong Kong

B.AI infrastructure upgrade, powerful Skills are ready to launch

WORLD3 releases AI strategic white paper: has processed over 100 billion LLM tokens

The number of users for B.AI LLM services has exceeded 1 million

B.AI LLM Platform Surpasses 800,000 Users Milestone
Key Takeaways: B.AI LLM platform’s user base exceeds 801,057 as of April 14. The platform emphasizes “permissionless access”…

The number of users of the B.AI LLM service platform has exceeded 750,000

Security Company: AI agent's encrypted payment infrastructure has significant security vulnerabilities, LLM router has led to the theft of a $500,000 wallet

Research finds that third-party AI routers have security vulnerabilities, which may lead to cryptocurrency theft

Ramp Labs Introduces Multi-Agent Memory Sharing Solution, Token Consumption Reduced by Up to 65%

Base announces the selected list for Base Batch 003 Accelerator, with 12 projects from AI and DeFi fields making the cut

Vitalik shares a local private LLM solution, emphasizing privacy and security first

Tether's QVAC Launches Synthetic AI Dataset and Consumer Application

litellm encountered a PyPI supply chain attack, allowing the theft of all sensitive credentials such as SSH keys with a simple installation

a16z Co-founder: The combination of OpenClaw and Pi Coding Agent is one of the top 10 software breakthroughs of all time

Tether releases a cross-platform BitNet LoRA framework, supporting consumer-grade GPUs and large model training and inference on smartphones

"Uncle was injured by a lobster" tricked out of 440,000 dollars, is AI agent really that good at breaking through?
80% Win Rate to 40% Drawdown: An AI Trader's Brutal Recalibration at WEEX AI Wars
Dive into the technical blueprint of an AI trading system built on LLaMA reasoning and multi-agent execution. See how Quantum Quaser uses confidence thresholds & volatility filters at WEEX AI Wars, and learn the key to unlocking 95% win rate trades.

Wallets, fintechs, and platforms target the freelancer market: why Argentina is a key market

Greece ends years of crypto tax uncertainty with new 10% levy on Bitcoin profits

Ethereum software bug triggers emergency fixes across major layer-2 networks

Kraken Owner Invests in Altcoin, Considers Further Purchases. You Should Recognize Him

Stablecoins offer sub-cent payments, Armstrong says, as critics flag risks

Analysis: Stablecoins, Payments, and Prediction Markets Have Become New Growth Points for Crypto Companies, but Profitability Remains Challenged

Nubank Suspends Crypto Withdrawals: What We Know So Far

Buffett's Successor Faces Setback, Google Holdings Show $3 Billion Unrealized Loss

Banking Outage in Japan: 128 Banks 'Frozen' at Once

Beyond APY: Saying Goodbye to Black Box Trust and Reassessing the Security Logic of ETH Staking

Argentine Bitcoiners Debut “The Genesis Of Satoshi Nakamoto” Artwork In Downtown Buenos Aires

Broadcom (AVGO) : AI Growth, Fund Positioning, and Guarantee Risk
Broadcom (AVGO) recently fell with the semiconductor sector, closing down 10.43% at $291.53 on November 5. The shares rebounded more than 4% in premarket trading on November 6. Concerns that election results could lead to tighter AI rules and slower data center approvals contributed to a broad sell-off, with a semiconductor index falling about 12%. The move appears tied mainly to sector sentiment and policy concerns, with no clear company-specific negative catalyst identified.
Institutional trading and AI growth expectations are also in focus. ARK funds sold about $134 million of Broadcom shares over two sessions while adding to SpaceX. Citi maintained its Buy rating and projected that Broadcom’s AI semiconductor revenue could reach $115 billion in fiscal 2027, roughly doubling year over year. Broadcom had approximately $179.2 billion in signed contracts as of the prior quarter, while analysts estimated fourth-quarter AI chip revenue at about $21.7 billion. These forecasts will need to be tested against future results.
Contingent guarantees are another point for investors to monitor. Broadcom is providing guarantees tied to Anthropic’s AI rack-leasing arrangement, involving about $29 billion in the first phase and a second-phase plan of up to $43 billion. Banks plan to issue $21 billion in bonds to support related chip financing. The guarantee amounts are not the same as debt already incurred, but they add a potential risk to assess. Broadcom is scheduled to report its next quarterly results on December 9, when management’s outlook for fiscal 2027 AI demand will be closely watched. This article is for informational purposes only and is not investment advice.

Netflix (NFLX) Stock Rebounds: Insider Sales, Advertising, and Growth Plans
Several Netflix executives sold company shares in early November 2026. Co-CEO Theodore Sarandos sold 27,312 shares from November 3 to 4, valued at about $1.81 million. CFO Spencer Neumann sold shares worth approximately $612,000. Co-CEO Gregory Peters realized about $1.69 million, including transactions related to tax withholding. Chief Legal Officer David Hyman and director Bradford Smith also reduced their holdings. Executive sales can have different reasons and should not be viewed on their own as a measure of the company’s outlook.
After recent pressure, Netflix shares rebounded more than 4% around November 4. Bill Ackman’s Pershing Square Capital Management allocated about 5% of its portfolio to Netflix, while new AI features and positive views on the company’s technology prospects helped sentiment. Netflix reported third-quarter 2026 revenue of $13.44 billion and earnings per share of $0.87, both above expectations, though its forward outlook remains a key focus.
Advertising is one of Netflix’s main challenges. Delays to key ad product features led the company to reduce its annual advertising revenue outlook from $3 billion to $2.7 billion. Viewer engagement has also faced pressure from changes in content appeal and competition from platforms such as YouTube. Netflix is pursuing growth through live events, gaming, and advertising, with plans to expand its ad-supported offering to 15 markets while adjusting its workforce by about 6% to improve margins. Investors may want to monitor advertising growth, engagement, and profitability. This article is for informational purposes only and is not investment advice.
Goldman Sachs, OKX Cut Off From Claude AI in Hong Kong
B.AI infrastructure upgrade, powerful Skills are ready to launch
WORLD3 releases AI strategic white paper: has processed over 100 billion LLM tokens
The number of users for B.AI LLM services has exceeded 1 million
B.AI LLM Platform Surpasses 800,000 Users Milestone
Key Takeaways: B.AI LLM platform’s user base exceeds 801,057 as of April 14. The platform emphasizes “permissionless access”…





