Skip to content

Repository files navigation

Claude Code 源码剖析

Deploy VitePress site to Pages

Deep reverse-engineering and architectural analysis of Claude Code, rewritten as a structured interactive documentation site.

概述

本项目是对 Claude Code 源码的深度逆向工程分析,以结构化、交互式的文档站点形式呈现。涵盖从 CLI 入口到安全机制的完整架构剖析。

  • 源码仓库: 777genius/claude-code-source-code-full
  • 技术栈: TypeScript + React/Ink (终端UI) + Bun runtime
  • 源码规模: 1894 个 .ts/.tsx 文件,约 51.5 万行代码

章节结构

章节主题核心文件深度
01整体架构四层架构、数据流、模块依赖★★★★★
02CLI 入口与启动流程cli.tsx → main.tsx → init()★★★★
03QueryEngine 核心Agentic Loop、AsyncGenerator★★★★★
04Agent 系统子 Agent、Fork、工具过滤★★★★★
05Tool 系统Tool 接口、权限检查、BashTool★★★★
06Prompt 系统系统提示词构建、缓存优化★★★
07Context 系统上下文管理、四级压缩★★★★
08Session 与状态管理AppState、持久化、Task 生命周期★★★★
09Streaming 与 API 通信流式响应、错误恢复、重试机制★★★★
10多 Agent 协作Coordinator、Worker、通信机制★★★★
11命令系统斜杠命令、参数解析、Help 系统★★★★
12UI 组件系统Ink 渲染、REPL、终端 UI★★★★★
13插件与扩展MCP、Skills、插件系统★★★
14安全与权限权限模型、安全检查链★★★★

本地运行

# 安装依赖
npm install
# 启动开发服务器
npm run dev
# 构建生产版本
npm run build
# 预览生产版本
npm run preview

技术栈

项目结构

claude-code-analysis/
├── docs/
│ ├── .vitepress/
│ │ ├── config.ts # VitePress 配置
│ │ └── theme/
│ │ ├── index.ts # 主题入口
│ │ └── custom.css # 自定义样式
│ ├── chapters/ # 15 章内容
│ ├── public/ # 静态资源
│ ├── index.md # 首页
│ ├── reading-roadmap.md # 阅读路线图
│ └── planning.md # 写作规划
├── scripts/
│ └── rewrite.cjs # CSS 重写工具
├── .github/
│ └── workflows/
│ └── deploy.yml # GitHub Pages 部署
├── build_ebook.py # 构建独立 HTML 电子书
├── package.json
└── README.md

许可

本项目内容基于 Claude Code 源码的逆向工程分析,仅供学习和研究使用。

相关链接

About

A comprehensive reverse-engineering and architectural analysis documentation of Claude Code, presented as an interactive VitePress documentation site with support for independent HTML ebook generation.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages