claude-code-analysis README

The project's README from github.com/liuup/claude-code-analysis. As one markdown file: README.md.

Claude code 源码分析

事件背景

美国东部时间2026年3月31日凌晨4点23分,安全研究者 Chaofan Shou 在 X 发布推文, 发现 Anthropic 发布到 npm 的 Claude Code 包中,官方没有删除source map 文件, 这意味着 Claude Code 的完整 TypeScript 源码全部泄露, 包含 1902 个源文件以及 513,237 行代码.

目录结构

本仓库为对 Claude Code 泄露源码的静态分析文档集

claude-code-analysis/
├── README.md                        # 本说明文档(总索引)
├── analysis/                        # 分析文档主目录
├── src.zip                          # 源代码压缩包
└── src/                             # 源代码(仅供分析跳转引用)

总述

本目录中的分析文档基于 src/ 源码静态阅读整理,主要探讨以下系统设计问题:

  1. 软件架构设计与程序启动路径。
  2. 安全分析:用户信息的收集、利用情况,潜在的安全风险及防范措施。
  3. Agent Memory 机制(多层级存储与 Session 压缩逻辑)及实现细节。
  4. 能力扩充机制(Skills 扩展、Tool Call 机制、MCP 集成)的技术实现及运行方式。
  5. 隔离机制:通过 Sandbox 防范本地操作风险的设计与实现。
  6. 内部程序架构设计与模块特点。
  7. UI 拆解:src/components/ 内 TUI 控制台的组件构成。
  8. 竞品对比:与 Codex、Gemini CLI、Aider、Cursor 等工具的功能及体系差异分析。
  9. 源码证据与外部公开资料对照。

主要系统特征:

一图总览

+---------------------------+
| CLI / 多入口               |
| entrypoints/cli.tsx       |
| main.tsx                  |
+---------------------------+
            |
            v
+---------------------------+
| 初始化与运行环境             |
| init.ts / setup.ts        |
+---------------------------+
      |                |
      v                v
+----------------+   +---------------------------+
| 命令与控制面     |   | TUI / REPL 工作台          |
| commands.ts    |-->| App / REPL / Messages     |
| PromptInput... |   | / PromptInput             |
+----------------+   +---------------------------+
                             |
                             v
                  +---------------------------+
                  | Query / Agent 执行内核     |
                  | query.ts / QueryEngine.ts |
                  +---------------------------+
                    |           |           |
                    v           v           v
          +---------------+ +--------------------+ +----------------------+
          | Tool/Perm     | | Transcript/Memory  | | 平台扩展层             |
          | Tool.ts       | | sessionStorage     | | MCP/Plugin/Remote/   |
          | orchestration | | memdir/SessionMem  | | Swarm                |
          +---------------+ +--------------------+ +----------------------+
                    \______________   |   ______________/
                                   \  |  /
                                    \ v /
                              回流到执行内核

分章目录

第一部分:总体架构

第二部分:安全分析

第三部分:核心机制

第四部分:程序架构及亮点

第五部分:扩展分析

第六部分:组件体系详解

第七部分:同类产品对比

第八部分:证据与资料

第九部分:总结


声明

本项目仅供学术研究与技术学习使用。

本仓库所有内容均为对公开信息的二次整理与分析。Claude Code 的所有权利归 Anthropic 所有。

  1. 无侵权意图:本分析文档基于已在公共互联网上广泛流传的信息整理撰写,目的在于帮助开发者了解 AI Coding Agent 的安全边界、隐私设计与工程架构,属于正当的技术研究行为。
  2. 禁止商业使用:禁止将本仓库内容用于任何商业目的,或以此绕过、破坏 Claude Code 的安全机制与用户协议。
  3. 免责声明:本仓库作者不对因参考本文档而产生的任何直接或间接损失负责。如有任何合规疑虑,请以 Anthropic 官方文档与用户协议为准。
  4. 如需删除:若 Anthropic 认为本仓库内容侵犯其合法权益,请通过 Issue 联系,我们将在核实后第一时间进行删除处理。

Star History

Star History Chart

claude-code-analysis (liuup/claude-code-analysis)

source-code-analysis
Searching Database…

What is this?A Chinese-language static analysis document collection dissecting the source code of Claude Code, after its npm package accidentally shipped unminified source maps revealing the full TypeScript codebase.
Is this a tool I run, or something I read?It is a set of markdown chapters and appendices, not executable software — there is nothing to install or run, only documents to read on GitHub.
How do I go through the analysis?Open the README's chapter index and click into the markdown file for the topic you want, from architecture and security to Memory, Skills, MCP, Sandbox and UI components.
Do I need any tools or an API key to use this?No, it is a static documentation repository with no code dependencies, package manager, or API key requirement.
Is this officially sanctioned by Anthropic?No — the authors state it is for academic/technical research only, forbid commercial use, and will remove content if Anthropic objects; all rights to Claude Code remain with Anthropic.
Who would want to read this?Developers and security researchers curious about how a production AI coding agent is actually built internally — its memory system, sandboxing, tool-call/MCP plumbing, and TUI components.
How big was the leaked source code?According to the report, the leaked Claude Code package exposed its complete TypeScript source: 1,902 source files totaling 513,237 lines of code.
What topics does the analysis actually cover?Eighteen chapters plus appendices covering program architecture, user-data collection and security risks, Agent Memory, Skills, Tool Call mechanics, MCP integration, Sandbox isolation, context/prompt management, multi-agent logic, session persistence, and a full breakdown of the TUI component tree.
Does it compare Claude Code to other coding agents?Yes, chapter 16 and an appendix compare Claude Code's architecture and capabilities against Codex, Gemini CLI, Aider, and Cursor.
Are the claims backed by actual code, or just guesses?The authors say the analysis is based on static reading of the leaked src/ directory, with a dedicated chapter (17) and file-tree appendix cross-referencing claims to source evidence and public documentation.
Creator
liuup
Size
18.5 MB
Stars
4K
Updated
CommitApr 02
Age
6mo
Commits · 90 Days