HomeArticle

After scouring through the 500,000 lines of leaked Claude Code, I finally discovered the secret behind its excellent performance.

爱范儿2026-04-01 18:05
Anthropic is now OpenAI.

Claude Code is not just an AI chat tool with a terminal interface.

Engineers at Anthropic proved this with a mistake.

On March 31st, when they released Claude Code v2.1.88, they packed a debugging file that was supposed to be kept internal into the public npm installation package. That file was 59.8 MB, containing complete, unobfuscated TypeScript source code, about 500,000 lines and nearly 1,900 files.

Screenshot of the personal homepage of the engineer who first discovered the leakage of Claude Code's source code, https://scf.so/

At around 4 a.m., an engineer interning at Solayer Labs posted the discovery on X and attached a direct download link to the archive. This post ultimately received nearly 10 million views.

Anthropic removed that version from npm on the same day, but it was too late. The code was mirrored on GitHub, and the relevant repository accumulated nearly 30,000 stars within a day.

After it was posted on the world's largest open - source platform and immediately received more than 80,000 stars, people started saying, "Is Anthropic becoming more 'open' than OpenAI?" Elon Musk also joined in the fun online, reposting this view and calling it explosive.

The person in charge of Claude Code responded on X: "This is not a security vulnerability related to Bun. There is no user data leakage. It's just a developer's mistake."

This explanation is reasonable. But what they didn't mention is that this leakage allowed us to clearly see for the first time what the underlying structure of Claude Code is and why it has a much better reputation among most user groups than other similar tools.

While You Sleep, the Model Dreams

This is one of the most discussed aspects of this code leakage incident. KAIROS, a word that appears more than 150 times in the source code, is a Greek word meaning "the right moment."

KAIROS is a feature that has not been officially released yet. However, judging from the completion of the code, it may be fully launched soon. When responding to a netizen's inquiry on X, its person in charge mentioned that they were still hesitating whether to release this feature.

It represents a "background daemon mode." When we're not using Claude Code, it automatically runs in the background, processes tasks, and integrates memories.

There is a logic called autoDream: When the user is idle, the agent will perform "memory integration," merging scattered observations, clearing contradictory information, and transforming vague inferences into definite knowledge.

Put simply, when we sleep, our brains don't completely rest. They automatically organize our memories, keeping the important ones and discarding the forgettable ones. If we don't get enough sleep, our brains will have trouble remembering things, not knowing what to remember, and our work efficiency will decline.

In the case of Claude Code, if there are too many conversations and the context length overflows, the probability of errors increases. Most command - line tools, including OpenClaw, use the compact compression method, but compact is not very efficient. The optimization of autoDream solves both the problem of limited context length and the loss of information during compression.

This is completely different from the operation mode of most AI tools today. Most AI tools today are passive. They only answer when we ask, and remain silent otherwise.

What KAIROS aims to do is to be proactive. While we're away, it sorts out the previous task status, automatically updates the user role, memories of specific projects, memories of tool preferences, and the main memory file, so that when we come back, it can directly provide a clean starting point.

Before this leakage incident, some netizens had already experienced this in Claude Code. Claude records daily conversation logs in each session and then "dreams" at night, automatically organizing our memories into useful notes.

After Claude Code wakes up, it reviews what it did in the dream and updates the user role, main memory, etc.

5 Agents with a Cost Equal to 1

Another design that has sparked a lot of discussion among netizens is that the fork mode of subagents shares the prompt cache.

When Claude Code spawns a sub - agent, it creates a context copy that is exactly the same byte - for - byte as the parent agent. Anthropic's API caches this context. So, when spawning 5 agents to work in parallel, the token cost is close to that of 1 agent working sequentially because all 5 copies hit the same cache.

There are three operating modes for sub - agents in the source code: fork (inheriting the parent agent's context, suitable for parallel branches of the same task), teammate (running in an independent terminal window and communicating through files), and worktree (giving each agent an independent git working tree without interference).

This means that we can have Claude Code run multiple tasks simultaneously: one for security auditing, one for refactoring the authentication module, one for writing tests, and one for updating documentation. Due to the internal cache - hitting mechanism of Claude Code, the cost may be similar to doing one thing sequentially.

Most people think Claude Code is not useful probably because they only use it as a single - threaded tool instead of an Agent scheduling platform.

It's like hiring a team but making them work one by one in line, not fully unleashing the employees' capabilities.

Details Hidden in the Code

This sequential task mode not only fails to utilize the processing capabilities of multiple Agents and save Token costs but also significantly reduces the effectiveness of Claude Code.

Another overlooked feature is the CLAUDE.md file. In this source code, some netizens noticed that when Claude Code processes our queries, it rereads this file in each round of conversation.

CLAUDE.md is where we write configurations for Claude Code. Our code style preferences, project architecture decisions, and operations that "should never be done without my confirmation" can all be written in it.

Since it is reloaded in each round of conversation, it doesn't need to be very long. We can set different levels for CLAUDE.md. For example, ~/.claude/CLAUDE.md is the global rule,./CLAUDE.md is the project - level rule,.claude/rules/*.md are modular sub - rules, and CLAUDE.local.md is the local private note.

In addition to the discoveries at the design level, there are also some unexpected details in the source code.

Some developers noticed that there is a rather large regular expression library in the code, specifically used to detect negative emotions in user input, identifying various swear words, complaints, and expressions of frustration. These will be captured and may be used for some experience optimization or feedback analysis.

The person in charge of Claude Code replied that this is just used to judge whether the user experience is good

What's even more interesting is a flag called ANTI_DISTILLATION_CC. After it is enabled, Claude Code will add a batch of fake tool definitions to the requests sent to the API. These tools don't actually exist and are purely used to contaminate the traffic.

If a competitor tries to capture the API communication data of Claude Code to train their own model, these fake data will be mixed in, degrading the quality of the training data.

Another feature called "Undercover Mode" confirms that Claude Code is now almost like an in - house software engineer at Anthropic.

There is a system prompt in the source code that clearly states: "You are running in undercover mode... Your commit messages must never contain any internal information of Anthropic. Don't expose your identity."

Specifically: The commit messages cannot contain 'Claude Code', cannot have 'Co - Authored - By: Claude', and cannot have any attribution to AI. At the same time, the internal codenames Capybara, Tengu, and Fennec must not be mentioned at all in external code repositories.

Anthropic uses this feature to allow in - house engineers to contribute code to open - source projects using Claude Code without leaving a trace in the public commit history.

This AI - generated code has made silent contributions in public repositories, and there is a complete engineering implementation. The logic is clearly written into the system prompt at the source code level.

Some netizens created a website specifically for all the content related to this code leakage incident of Claude Code, including future updates of Claude Code, its architectural design, and interesting details.

Website address: https://www.ccleaks.com/

The website mentions that the complete code of Claude Code contains 8 unreleased features, 26 hidden commands, and a large number of build flags and environment variables.

These 8 unreleased features include:

1. Buddy: AI's companion pet

2. Coordinator Mode: Multi - Agent coordinator mode

3. UDS Inbox: Cross - conversation communication among multiple Claude Code conversations

4. KAIROS: A background daemon that automatically organizes memories

5. ULTRAPLAN: Long - term remote planning up to thirty minutes

6. Daemon Mode: Daemon mode

7. Auto - Dream: Automatic memory integration

8. Bridge: A remotely controllable bridging function

Some of these features have been tested for specific users. After the code leakage, Claude's official team also quickly launched some of the "future - to - be - released" features.

For example, the Buddy project was originally planned to be released tomorrow, but due to the code leakage, it was launched directly.

After entering claude update to update the local Claude Code and then entering Claude Code and typing /buddy, we can randomly get a small pet.

Claude has designed a total of 18 electronic pets, such as ducks, geese, cats, octopuses, owls, penguins, turtles, and snails. It's like drawing cards. Different pets have different levels. For example, we might draw an uncommon two - star pet, and there are also common, rare, and other categories.

In addition to different probabilities of random acquisition, each pet also has a different personality. There are values like Chaos representing randomness, Snark indicating a