How Claude Code Works
Description
Deep dive into Claude Code internals — architecture, agent loop, context engineering, and more. / 深入解析 Claude Code 源码:架构、Agent 循环、上下文工程、工具系统等
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
How Claude Code Works
**深入解读当前最成功的 AI 编程 Agent 的源码架构**
[](https://github.com/Windy3f3f3f3f/how-claude-code-works) [](https://github.com/Windy3f3f3f3f/how-claude-code-works/fork) [](./LICENSE) [](https://github.com/anthropics/claude-code) [](#专题深入)
[**📘 在线阅读文档**](https://windy3f3f3f3f.github.io/how-claude-code-works/#/) | [English](./README_EN.md)
🛠️ **想动手造一个?** 配套项目 **[Claude Code From Scratch](https://github.com/Windy3f3f3f3f/claude-code-from-scratch)** — ~4000 行 TypeScript 或 Python两个版本,11 章分步教程,从零构建你自己的 Claude Code
Claude Code 是目前使用最广泛的 AI 编程 Agent,也是我们认为最好用的 AI 编程工具。它能理解整个代码仓库、自主执行多步编程任务、安全地运行命令——而这一切背后是 **50 万行 TypeScript 源码**中沉淀的工程智慧。
Anthropic 开源(x)了这份源码。**但 50 万行代码,从哪里开始读?**
这也是我们创建这个项目的初衷——我们都遇到了没有办法阅读这么庞大代码项目的问题,解决方案是和 Claude Code 一起读,让它写文档配合我们理解源代码。在此同时,我们想把这个过程文档化,就形成了这个项目。
我们和 Claude Code 加班从源码中提炼出 **15 篇专题文档**,覆盖了从核心循环到安全防护的每一个关键设计决策。不管你是想造自己的 AI Agent,还是想更深入地理解和使用 Claude Code,这里都是最短路径(应该?就算不是最短的,我们也会不断更新这个项目)。
🏗️ 系统架构
graph TB
User[用户输入] --> QE[QueryEngine 会话管理]
QE --> Query[query 主循环]
Query --> API[Claude API 调用]
API --> Parse{解析响应}
Parse -->|文本| Output[流式输出]
Parse -->|工具调用| Tools[工具执行引擎]
Tools --> ReadTool[读文件]
Tools --> EditTool[编辑文件]
Tools --> ShellTool[Shell 执行]
Tools --> SearchTool[搜索工具]
Tools --
Related Skills
Auto Update
Pull the latest ECC repo changes and reinstall the current managed targets.
Development Ecc Guide
Navigate ECC's current agents, skills, commands, hooks, install profiles, and docs from the live repository su
Development Epic Claim
Claim an epic issue, stamp coordination state, and sync local ownership.
Development Epic Publish
Publish a validated epic update back to the issue and local cache.
Development Epic Review
Mark epic review requested, approved, or changes requested.
Development Epic Unblock
Sweep blocked epic issues and reopen anything whose dependencies are closed.
Development Related Agents
Django Build Resolver
Django/Python build, migration, and dependency error resolution specialist. Fixes pip/Poetry errors, migration
Openai Codex CLI
(55.8k ⭐) - Lightweight coding agent that runs in your terminal.
src/agents/ — 11 Agent Definitions
**Generated:** 2026-04-11