The AI community has gone crazy! Just now, an X account named Chaofan Shou posted that "Claude Code's source code has been leaked through a mapping file in its npm registry!" In a short time, the post has garnered millions of views. A large number of netizens have quickly followed up, frantically forking the project and analyzing its source code. Link: https://github.com/sanbuphy/claude-code-source-code Some netizens commented, "This seems to be an accident by the Claude Code team who accidentally uploaded the source code of v2.1.88 directly to the npm package. The overall code structure is very mature, and the entire repo..." The process is very detailed, with the main workflow including REPL startup, QueryEngine, tool registration, Slash commands, permission system, task system, and multi-layered state management—a very typical production-grade AI agent harness design. All tools are available for viewing. [Link: https://x.com/sanbuphy/status/2038912992457408838] According to more Twitter users, this leak "wasn't caused by a hack, but rather Anthropic itself packaged the source map into the production version when releasing it on npm." This leak originated from a cli.js.map file of approximately 57MB, containing the complete contents of 4756 source files: 1906 of which are Claude Code's own TypeScript/TSX source code, and the remaining 2850 are from node_modules dependencies. More importantly, the extraction method is virtually effortless. `cli.js.map` is essentially a JSON file, containing two core arrays: `sources`: a list of file paths; `sourcesContent`: the corresponding complete source code. These two arrays are matched one-to-one by index. In other words, no decompilation or deobfuscation is needed; `sourcesContent` directly stores the verbatim content of the original source code. Batch restoration can be achieved with a simple script. From the recovered code, the overall architecture of Claude Code can be clearly seen: The CLI interface is built on React + Ink. The core is a REPL loop that supports natural language input and slash commands. The underlying layer interacts with the large model API through a tool system. Key implementation details, including architecture design, system prompt, and tool call logic, are all completely exposed.


KAIROS Background Daemon Mechanism—Currently, Claude Code is still a command-line tool that only responds to a small request, but the leaked code reveals Anthropic's next ambition: to keep the Agent always online. The code includes a feature module hidden by the Feature Flag (build flag), codenamed KAIROS. This is an automated background daemon. Once activated, the Agent has background session capabilities and can directly subscribe to GitHub webhooks (for example, it will automatically fix new errors in the background). More interestingly, it includes a memory compaction mechanism called "dream," used to compress and consolidate long-term memory during idle periods. The Mysterious "Capybara" Model—A Capybara model really exists. The leaked code comments repeatedly mention an unreleased model codename, "Capybara" (recently, internal documents have also leaked that its official name is Claude Mythos, a powerful new generation model positioned above Opus). The leaked code includes information about the capybara-fast version, as well as internal debugging logs from the developers regarding "making false claims" about the model. **Emotion Monitoring** The underlying telemetry system revealed that Anthropic was highly sensitive to developers' frustration. The system specifically tracked whether users swore at Claude in the terminal and the frequency of repeatedly typing "continue" (a frustrated behavior usually caused by interrupted model output). Anthropic subsequently recognized the problem and removed the source map; the repository on GitHub used to extract the source code was also removed by the DMCA. However, because early npm packages had already been cached and mirrored, this source code had already spread widely in the community, making complete repossession difficult. Some netizens also pointed out that this is the second time Anthropic has made such a basic mistake. Back in February 2025, it was leaked again, at which time Anthropic urgently removed and fixed it, but now it's stumbled in the same place again. Currently, several complete mirror repositories have appeared on GitHub (such as leeyeel, dnakov, ghuntley, etc.), with the source code neatly organized, allowing anyone to directly study or even fork it. In just one hour, one of the Claude Code clone projects has surpassed 12k stars on GitHub and over 18k forks. Project address: https://github.com/instructkr/claude-code Regarding the Claude Code leak, some people joked, "This is the best birthday present ever." This time, Claude Code has indeed been open-sourced, and the important products of this star AI company have been thoroughly exposed. For the industry, this provides some reference for many things. Now, the "best practices" from the industry's top AI companies are directly available to everyone. How to perform context compression? How to manage the long-term memory of intelligent agents? How to securely schedule the MCP protocol? These things, which were previously somewhat confidential, now have publicly available reference books. It wouldn't be surprising if various companies' agents received major version updates in a few days.