@GitHub_Daily: 想搞懂 Claude Code 底层怎么设计的,若直接看源码无从入手,而博客又讲得太零散。 最近在 GitHub 上发现 harness-books 用两本书把架构拆解讲清楚了,结构比我预想的清晰。 第一本聚焦运行时结构,权限怎么管、上下…
摘要
本文介绍了在GitHub上发现的两本书,详细解析了Claude Code的底层架构和设计哲学,对比了Claude Code与Codex,帮助开发者理解AI编码代理的设计逻辑。
查看缓存全文
缓存时间: 2026/08/21 15:21
想搞懂 Claude Code 底层怎么设计的,若直接看源码无从入手,而博客又讲得太零散。
最近在 GitHub 上发现 harness-books 用两本书把架构拆解讲清楚了,结构比我预想的清晰。
第一本聚焦运行时结构,权限怎么管、上下文怎么治理、出错了怎么恢复,逐章拆开讲。
重点不是研究代码怎么写,而是让我们了解清楚为什么要这样设计。
GitHub:http://github.com/wquguru/harness-books…
第二本把 Claude Code 和 Codex 放一起进行对比,同一任务两个工具怎么做,设计取舍在哪。
想理解 AI 编码 Agent 的设计逻辑,或者打算自己造一个,这两本读完能省掉不少翻代码的时间。
wquguru/harness-books
Source: https://github.com/wquguru/harness-books
Harness Books
Two books on harness engineering. They pursue the same engineering question: once a code-writing model is placed inside terminals, repositories, permission systems, and team workflows, what keeps the overall system bounded, continuous, and accountable for consequences?
|
Harness Engineering: A Design Guide to Claude Code Read online · Download PDF |
The Harness Design Philosophies of Claude Code and Codex Read online · Download PDF |
These books are not meant to walk line by line through the source code. They focus on how a harness organizes constraints and execution, and how an inherently unstable model can be folded into a sustainable engineering order. Prompt layering, query loops, permission decisions, context governance, failure recovery, multi-agent verification, local rules, and team institutions together form the organ system of a harness. The real danger is not that a model occasionally says something wrong, but that the system has no structure for handling consequences.
Core Claims
- Harness engineering is about how constraint structures organize execution.
- Once a code-writing model enters a real engineering environment, the main problem is no longer answer quality but behavioral consequences.
- Prompts, tools, permissions, state, recovery, verification, and institutions are not accessories around the system. They are organs in the same control structure.
- When comparing agent systems, the key question is not the feature checklist but where order is actually placed.
- If a team cannot turn individual experience into reusable rules, it will struggle to turn an agent into a stable system.
What The Two Books Focus On
Book 1: A Design Guide to Claude Code
The first book uses Claude Code as the observation target and concentrates on runtime structure. Its concern is why a system eventually has to grow components such as a control plane, query loop, tool permissions, context governance, recovery paths, multi-agent verification, and team rules.
Start with Book 1 if these are the questions you care about:
- Why harness engineering is not just prompt engineering at a larger scale
- Why prompts are fundamentally part of the control plane rather than a chat box
- Why model mistakes should be treated as a runtime norm rather than an exceptional event
- Why multi-agent work and verification should not be blended into one vague mechanism
- How a team can solidify personal experience into reusable engineering institutions
Book 2: Comparing Claude Code and Codex
The second book places Claude Code and Codex side by side and asks where each harness places order. One path starts from runtime discipline; the other starts from a more structured control layer. Both systems can work, but they distribute authority differently.
Start with Book 2 if you care more about system choice, architectural judgment, or what to learn when building your own harness:
- What the biggest control-plane divergence is between Claude Code and Codex
- How to align the roles of query loops, threads, rollouts, and state
- What governance roles are played by permissions, sandboxes, and policy languages
- How skills, hooks, and local rules encode organizational habits into the system
- If you want to build your own harness, who to learn from first and which layer to study first
Suggested Reading Paths
- Want the full frame first: read Book 1, then Book 2.
- Already familiar with coding-agent tools and want the architectural split directly: start with Book 2.
- Only want the conclusions: read Book 1 Chapter 9 plus Book 2 Chapter 7.
Full Table of Contents
Book 1 — Harness Engineering: A Design Guide to Claude Code
- Introduction
- Preface: Harness, Terminals, and Engineering Constraints
- Chapter 1 Why Harness Engineering Matters
- Chapter 2 Prompt Is Not Personality, Prompt Is the Control Plane
- Chapter 3 Query Loop: The Heartbeat of an Agent System
- Chapter 4 Tools, Permissions, and Interrupts: Why Agents Cannot Touch the World Directly
- Chapter 5 Context Governance: Memory, CLAUDE.md, and Compact as a Budgeting Regime
- Chapter 6 Errors and Recovery: An Agent System That Keeps Working After Failure
- Chapter 7 Multi-Agent Work and Verification: Managing Instability Through Division of Labor
- Chapter 8 Team Adoption: Turning a Smart Tool into a Reusable Institution
- Chapter 9 Ten Principles of Harness Engineering
- Appendix A Checklists: Turning Principles into Executable Constraints
- Appendix B Diagrams: Drawing the Runtime Skeleton
- Appendix C Source Map: Which Files Ground Each Chapter
Book 2 — The Harness Design Philosophies of Claude Code and Codex
- Introduction
- Reading Map: How to Understand Book 1 and This Comparative Book Together
- Preface: Two Harnesses, Not Accessories on the Same Horse
- Chapter 1: Why We Compare Claude Code and Codex
- Chapter 2: Two Control Planes: Prompt Assembly and Instruction Fragments
- Chapter 3: Where the Heartbeat Lives: Query Loop Compared with Thread, Rollout, and State
- Chapter 4: Tools, Sandboxes, and Policy Languages: Who Stops the Model from Moving Too Fast
- Chapter 5: Skills, Hooks, and Local Rules: How a System Learns Local Discipline
- Chapter 6: Delegation, Verification, and Persistent State: Who Prevents a System from Grading Itself
- Chapter 7: Convergence Through Different Roads, or Separate Branches
- Chapter 8: If You Are Building Your Own Harness, What to Study First
- Appendix A: Source Map That Underpins the Comparison
- Appendix B: Checklist to Determine Where Your Harness Sits
Want To Keep Practicing? Try AgentWay
|
|
AgentWay is a related but separate practice platform. Harness Books explains control structures, engineering judgments, and architectural divergences. AgentWay is where these ideas continue into training paths, drills, project exercises, and agent PoCs. |
Local Build
Build the two locale-aware Honkit sites and then assemble the unified Pages site:
python3 tools/book-kit/build_honkit.py book1-claude-code
python3 tools/book-kit/build_honkit.py book1-claude-code --locale en
python3 tools/book-kit/build_honkit.py book2-comparing
python3 tools/book-kit/build_honkit.py book2-comparing --locale en
python3 tools/book-kit/build_pages_site.py
Final output is written to dist/.
Keywords: Harness Engineering, Claude Code guide, Claude Code vs Codex, AI coding agent, control plane, query loop, agent recovery, agent verification, local governance, approval policy
相似文章
@mylifcc: 想真正理解 Claude Code 是怎么跑起来的,而不是只停留在 prompt 层面? 这个 repo 太硬核了: shareAI-lab/learn-claude-code 「Bash is all you need」—— 从 0 到…
介绍一个从零实现类似 Claude Code 的 agent harness 的开源学习项目,包含 20 节课逐步增加核心机制,并提供可运行代码和文档。
@GitHub_Daily: 用 Claude Code 开发项目,代码库一大,每次探索代码结构都要扫一堆文件,工具调用多、速度慢,token 也跟着烧。 于是找到 CodeGraph 这个开源工具,给代码库预建一张语义知识图谱,让 Claude Code 直接查图而…
CodeGraph 是一个开源工具,为代码库预建语义知识图谱,让 Claude Code 直接查图而不是逐文件扫描,从而大幅减少工具调用次数(减少 92%)并提升探索速度(提升 71%),支持 19 种编程语言和 13 个框架。
@cevenif: 用Claude Code或Codex做开发,但总觉得AI在乱跑?这门课可能正是你缺的那块拼图。 GitHub上有个开源课程叫 Learn Harness Engineering,专门教你给AI编程助手建立一套可控的工作框架,围绕五个核心机…
GitHub 上开源课程 Learn Harness Engineering,教你为 AI 编程助手(如 Claude Code、Codex)建立可控工作框架,包含12节理论课和6个实战项目,核心机制涵盖指令、状态、验证、范围、会话。
@GitHub_Daily: 刚接手一个新项目,面对几十万行代码,光是理清文件之间的调用关系和整体架构,就得花上好几天,效率很低。 于是找到 Understand Anything 这个开源项目,把整个代码库生成一张可交互的知识图谱,直观地看清每个模块之间的关系。 通…
Understand Anything 是一个开源项目,通过多智能体流水线自动分析代码库,生成可交互的知识图谱,帮助开发者快速理清代码结构和模块关系,支持与 Claude Code、Cursor 等主流 AI 编程工具集成。
@GitHub_Daily: 用 Claude Code 写项目,不少人上来就让它开干,写到一半发现架构跑偏了,推倒重来更费时间。 The Architect 这个 Claude Code 插件,专门在写代码之前先做一轮架构设计,产出一份完整的项目蓝图。 它会先问清楚…
介绍 The Architect,一个 Claude Code 插件,能在写代码前通过访谈生成完整项目蓝图,支持 14 种项目类型,帮助避免架构跑偏和推倒重来。