Skip to content

学习路径

从 Agent 循环到多 Agent 协作,每次只加一个机制

这是什么

这是一份基于 Claude Code v2.1.88 真实源码的 Harness Engineering 架构解读教程。面向 Agent 开发者,帮助你理解当前第一梯队 AI Agent 的工程架构,并将这些设计思想用于自己的 agent 开发。

不是使用教程 —— 不教你怎么用 Claude Code,而是教你它是怎么建的,以及为什么这样建。

本教程 vs 其他资源

  • vs shareAI-lab/learn-claude-code:那个偏动手从零构建,本教程偏源码级架构解读
  • vs Anthropic Academy:官方视角 vs 社区驱动的源码深度分析
  • vs 逆向博客 (kirshatrov.com, sabrina.dev):散点分析 vs 16 课系统体系

教程特色

  • Harness 视角:以"模型之外的一切工程基础设施"为主线,揭示 Claude Code 的真正竞争力
  • Python 伪代码:每课附 Python 参考实现,无需 TypeScript 基础
  • 源码映射:每个概念标注真实源码路径,可自行深入
  • 设计决策:对比 OpenCode / Cursor 的不同工程选择,理解 trade-off
  • Context Engineering 框架:用 Write / Select / Compress / Isolate 四策略串联全部课程

六层架构

学习路线

根据你的背景和目标,选择合适的路线:

路线时间课程适合人群
速览路线2-3hs00 → s01 → s02 → s07 → s16想快速了解整体架构
完整路线2-3 天s00 → s01 → ... → s16想系统掌握 Harness 设计
安全专项半天s04 → s05 → s06关注权限和安全机制
上下文专项半天s03 → s07 → s09关注 Context Engineering
多 Agent 专项半天s11 → s12 → s13 → s14关注多 Agent 编排

课程总览

标题MottoContext 策略关键源码
s00Harness EngineeringThe harness is 99% of the code全部
s01Agent 循环One loop is all you needQueryEngine.ts, query.ts
s02工具系统Tools are the hands of the agentsrc/tools/, commands.ts
s03系统提示词Every token has a price tagSelectcontext.ts, claude.ts
s04权限系统Trust, but verifyutils/permissions/
s05HooksDon't just react, automateSelectutils/hooks/
s06设置层级Configuration is a contractWriteutils/settings/
s07上下文压缩Forget wisely, remember what mattersCompressservices/compact/
s08Memory 系统An agent without memory is a strangerWritememdir/
s09SkillsKnow what's available; load how on demandSelectskills/
s10Plan 模式Measure twice, cut onceEnterPlanModeTool/
s11任务系统Plan the work, work the planWritetasks/
s12子 AgentClean context per subtaskIsolatetools/AgentTool/
s13Agent 团队More than the sum of its agentsIsolateTeamCreateTool/
s14WorktreeTasks manage WHAT, worktrees manage WHEREIsolateutils/worktree.ts
s15MCP 集成Only as powerful as the tools it can reachservices/mcp/
s16全景架构See the forest, then the treescli.tsx, main.tsx

学习建议

  1. 先读 s00 导论:建立 Harness Engineering 和 Context Engineering 的整体框架
  2. 按层推进:每层解决一类问题,层内的课程有内在联系
  3. 先读伪代码:Python 伪代码能快速建立心智模型,再看源码映射深入
  4. 关注设计决策:这是本教程最有价值的部分 —— 不仅知道"怎么做",更知道"为什么"
  5. 动手试试:每课末尾有练习建议,建议用 Python 实现一遍

前置知识

  • Python 编程基础
  • 了解 LLM API 调用(如 OpenAI/Anthropic API 的 messages 格式)
  • 基本的 git 操作
  • 不需要 TypeScript 基础(但能读更好)