Claude Code Analysis banner
liuup liuup

Claude Code Analysis

Development community

Description

🤖 The analysis of Claude Code

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Claude code 源码分析

事件背景

美国东部时间2026年3月31日凌晨4点23分,安全研究者 [Chaofan Shou](https://x.com/Fried_rice) 在 X 发布[推文](https://x.com/Fried_rice/status/2038894956459290963?s=20), 发现 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. 竞品对比:与 CodexGemini CLIAiderCursor 等工具的功能及体系差异分析。
  9. 源码证据与外部公开资料对照。

主要系统特征:

  • 该项目属于本地代码 Agent 平台,具备独立的执行逻辑与环境闭环设计。
  • 核心功能包含统一的执行内核、分层 Memory 系统,以及基于 MCP 和 Skills 的外接扩展支持。
  • 架构防御层面,系统采用了本地 Sandbox 隔离与工具调用权限(Tool Permission)控制措施。
  • 隐私层面,涉及数据流出的环节主要包括模型上下文交互、本地持久化存储和外部组件远程通信功能。

一图总览

+---------------------------+
| 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 |
                  +------------