MCPcopy Index your code
hub / github.com/ComeOnOliver/claude-code-analysis

github.com/ComeOnOliver/claude-code-analysis @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
11,802 symbols 42,349 edges 1,902 files 1,595 documented · 14%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

English | 中文

Claude Code 源码分析

License: MIT Documentation English 中文

Claude Code 内部架构、模块和设计模式的全面逆向工程分析。


这是什么?

本项目是对 Claude Code(Anthropic 官方 AI 驱动的软件工程 CLI 工具)的深度技术分析。文档详细记录了其内部源码树结构、模块边界、工具/命令清单、状态管理和架构设计模式——全部通过源码逆向工程获得。

无论你是在 Claude Code 之上构建工具、参与类似项目的开发,还是对一个生产级 AI CLI 的架构设计感到好奇,本分析都能为你提供详尽的内部结构图。

为什么做这个?

Claude Code 是一个复杂的实际应用,它在单一 TypeScript 代码库中集成了 LLM 编排、终端 UI 渲染、插件系统、多智能体协调等功能。理解其架构可以帮助你深入了解:

  • 如何设计基于工具的 LLM Agent 系统
  • React 终端 UI(Ink)的实际应用模式
  • AI 代码助手的权限与安全模型
  • 上下文窗口管理与压缩策略
  • 多智能体任务编排

涵盖内容

完整分析 包含以下章节:

章节 描述
项目概览 高层能力与功能概述
技术栈 运行时、框架和依赖
目录结构 完整源码树布局(37 个子目录)
入口点 引导启动、CLI、SDK 和 MCP 入口
核心架构 查询引擎、上下文构建器、成本追踪
工具系统 全部 41 个工具,按类别分类说明
命令系统 全部 101 个斜杠命令,按功能组织
状态管理 Zustand 风格状态存储及关键状态字段
任务系统 任务类型、生命周期和状态管理
服务与集成 API 客户端、MCP、分析、压缩等
UI 层 React/Ink 组件架构(130+ 组件)
工具函数 300+ 工具模块,覆盖所有类别
特殊模式 Bridge、Kairos、协调器、语音、计划、Vim 模式
插件与技能 插件和技能扩展系统
钩子与可扩展性 钩子模式和 React Hooks
文件统计 代码库规模与模块数量
架构模式 关键设计模式与原则

快速开始

直接阅读文档即可:

# 克隆仓库
git clone https://github.com/YOUR_USERNAME/claude-code-analysis.git

# 打开分析文档
open DOCUMENTATION.md

免责声明

这是一份非官方的独立分析。 Claude Code 是 Anthropic 的产品。本项目与 Anthropic 无关,未获其认可或赞助。所有商标归其各自所有者所有。

许可证

本项目采用 MIT 许可证 开源。


📖 阅读完整分析(中文) →

📖 阅读完整分析(English) →

🇺🇸 English Version →

Extension points exported contracts — how you extend this code

IParsedCommand (Interface)
(no doc) [4 implementers]
src/utils/bash/ParsedCommand.ts
Props (Interface)
(no doc)
src/components/ContextVisualization.tsx
InstallProps (Interface)
(no doc)
src/commands/install.tsx
Diagnostic (Interface)
(no doc)
src/services/diagnosticTracking.ts
IDEPathConverter (Interface)
(no doc) [2 implementers]
src/utils/idePathConversion.ts
TeleportResumeWrapperProps (Interface)
(no doc)
src/components/TeleportResumeWrapper.tsx
CheckExistingSecretStepProps (Interface)
(no doc)
src/commands/install-github-app/CheckExistingSecretStep.tsx
DiagnosticFile (Interface)
(no doc)
src/services/diagnosticTracking.ts

Core symbols most depended-on inside this repo

logForDebugging
called by 2724
src/utils/debug.ts
logEvent
called by 1088
src/services/analytics/index.ts
has
called by 699
src/utils/fileStateCache.ts
logError
called by 623
src/utils/log.ts
set
called by 501
src/utils/fileStateCache.ts
max
called by 437
src/utils/fileStateCache.ts
lazySchema
called by 410
src/utils/lazySchema.ts
jsonStringify
called by 367
src/utils/slowOperations.ts

Shape

Function 10,431
Method 1,031
Class 256
Interface 83
Enum 1

Languages

TypeScript100%

Modules by API surface

src/bootstrap/state.ts212 symbols
src/utils/sessionStorage.ts156 symbols
src/native-ts/yoga-layout/index.ts144 symbols
src/utils/messages.ts122 symbols
src/utils/Cursor.ts105 symbols
src/utils/bash/bashParser.ts84 symbols
src/utils/attachments.ts74 symbols
src/utils/auth.ts69 symbols
src/utils/hooks.ts67 symbols
src/services/mcp/client.ts67 symbols
src/utils/sandbox/sandbox-adapter.ts59 symbols
src/ink/ink.tsx54 symbols

For agents

$ claude mcp add claude-code-analysis \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page