ClaudeCode Source Analysis banner
bcefghj bcefghj

ClaudeCode Source Analysis

Development community

Description

Claude Code 源码解析报告 - 基于2026年3月31日npm source map泄漏事件的完整技术分析

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日 npm source map 泄漏事件的完整技术分析**


目录


第一章:事件背景

1.1 泄漏事件时间线

2026年3月31日凌晨,安全研究者 **Chaofan Shou** 在 X(原 Twitter)上发布了一条震惊整个 AI 开发社区的消息:

*"Claude code source code has been leaked via a map file in their npm registry!"*

Anthropic 发布到 npm 的 Claude Code 包(`@anthropic-ai/claude-code` v2.1.88)中,意外打包了一个 59.8 MB 的 source map 调试文件(`cli.js.map`),其中包含了完整的、未混淆的 TypeScript 原始源码。

timeline
    title Claude Code 泄漏事件时间线
    2025-02 : 首次泄漏
             : Claude Code 首次上架 npm 时
             : 同样打包了 source map
             : 持续暴露 13 个月无人注意
    2026-03-26 : CMS 配置泄漏
               : Anthropic CMS 配置错误
               : 暴露 Claude Mythos 模型细节
               : 3000 份未发布资产泄出
    2026-03-31 : npm Source Map 泄漏
               : v2.1.88 包体积从 17MB 暴涨到 31MB
               : 完整 512000 行 TypeScript 源码曝光
               : 数小时内被多个 GitHub 仓库镜像
    2026-03-31 : Anthropic 紧急响应
               : 推送 npm 更新移除 source map
               : 删除旧版本包
               : 发起 DMCA 删除通知
               : 但代码已被广泛传播

1.2 泄漏技术原理

Source map(`.map` 文件)是 JavaScript/TypeScript 构建工具链的标准产物,用于将编译/打包后的代码映射回原始源文件,方便调试时定位到真实代码行。

flowchart LR
    A["TypeScript 源码
1,906 个 .ts/.tsx 文件"] -->|"Bun bundler 编译"| B["cli.js
打包后的单文件"] A -->|"默认生成"| C["cli.js