Skip to content

Claude Codev2.1.88 深度技术剖析

逐目录、逐文件、逐函数 — Anthropic Claude Code 全方位架构解析

技术栈

技术用途
TypeScript主要开发语言
Bun运行时 + 构建工具 + 包管理
React + Ink终端 UI 渲染框架
Zod v4Schema 验证(工具输入/输出)
MCPModel Context Protocol 工具扩展协议
Zustand-like Store轻量级状态管理
React Compiler Runtime自动记忆化优化
Yoga LayoutFlexbox 终端布局引擎

核心模块关系

┌─────────────────────────────────────────────────────────────┐
│                     CLI Entrypoint (cli.tsx)                  │
│  init() → config → shutdown → remote settings → proxy → LSP │
└──────────────────────────┬──────────────────────────────────┘

              ┌────────────▼────────────────┐
              │     REPL Screen (REPL.tsx)   │
              │  App → Provider → StatusLine │
              └────────────┬────────────────┘

         ┌─────────────────▼─────────────────┐
         │       QueryEngine (核心循环)       │
         │  submitMessage() → query() → SDK  │
         └──┬──────────┬──────────┬─────────┘
            │          │          │
     ┌──────▼──┐  ┌────▼────┐  ┌─▼──────────┐
     │ Tools   │  │Commands │  │ Services   │
     │ 40 内置 │  │  70+命令│  │ API/MCP/   │
     │ +MCP扩展│  │ +技能   │  │ Token/Cost │
     └─────────┘  └─────────┘  └────────────┘
            │          │          │
     ┌──────▼──────────▼──────────▼──────────┐
     │          State Management              │
     │  AppState(80+字段) + ToolPermission   │
     └──────────────────┬────────────────────┘

         ┌──────────────▼──────────────┐
         │     Bridge (远程通信)        │
         │  轮询 → 消息 → 心跳 → 会话  │
         └─────────────────────────────┘

项目规模

类别数量
源码文件500+
内置工具40
命令70+(含内部构建可达 120+)
UI 组件200+
Hooks100+
工具函数150+