后记 庖丁解牛,游刃有余
完稿之际,我再次审视本书的目录,竟发觉了一个有趣的巧合:本书的架构本身,便是一个关于Harness工程的隐喻(见图1)。

图1 Harness工程的隐喻
第1章和第2章是上下文注入——为读者加载“项目背景”,恰如CLAUDE.md在会话开始时为模型加载项目记忆。
第3章到第6章是工具注册——Skills、子智能体、Hooks、MCP四大组件,宛如四类工具,逐一交到读者手中。
第7章到第9章是执行环境——Headless模式、Agent SDK、Plugins,让能力从终端延伸至CI/CD、编程接口与生态分发。
第10章是治理层——成本、安全、指令、协作,确保整个系统在真实工程环境中可靠运转。
上下文、工具、执行环境、治理,这不正是Harness工程的四大组件?
这一结构并非刻意雕琢,而是自然而成。毕竟,理解一个系统的最佳方式,便是按照系统本身的结构来组织知识。
在本书的撰写过程中(2025年末至2026年初),我亲历了AI辅助开发领域一场不可逆转的范式转移:竞争的重心已从模型本身,彻底转向Harness工程。
2025年,业界关注的焦点尚在“哪个模型最强”;而步入2026年,顶尖工程师们开始追问一个全新的命题——“如何让同一模型表现得更卓越”。答案不再是指向更大的参数量或更大的上下文窗口,而是回归更精巧的Harness设计,即更精准的上下文管理、更合理的工具编排、更严苛的权限约束,以及更智能的自动压缩策略。
**开源社区的爆发式增长有力地印证了这一趋势。**Superpowers(4.2万星)仅凭14个Skills便定义了从头脑风暴到代码审查的完整开发方法论;Compound Engineering赋予了Agent从错误中汲取经验、自我进化的能力;grill-me仅用几行指令便重塑了AI的行为模式;Trellis则让一份规范跨在11个AI平台间实现了无缝通用。它们并未发明新的模型——它们都在致力于同一件事:设计更卓越的Harness。
而这些Harness的设计,无一不是建立在本书所阐述的基础机制之上——CLAUDE.md承载记忆,Skills注入知识,子智能体实现任务分治,Hooks充当约束守卫,MCP负责外部连接。Superpowers的七阶段工作流,正是这5种机制的精妙编排;Compound Engineering的知识沉淀闭环,则是CLAUDE.md与Skills的高级应用。
零件是恒定的,组合是无穷的。
本书赋予你的是零件,至于如何组合,则取决于你所面对的具体问题,以及你的工程判断力。
写作期间,一个概念反复在我的脑海中浮现——Agentic Loop,它宛如一个优雅的莫比乌斯环(见图2)。

图2 一个优雅的莫比乌斯环
图解说明:莫比乌斯环上的四个意象依次对应 Agentic Loop 的闭环循环:『眼睛(观察/感知)→ 大脑(推理决策)→ 机械手(工具调用)→ 镜子(结果回注与自我修正)』。
“推理→工具调用→结果回注→继续推理”这一循环看似简单得微不足道,实则是Claude Code一切复杂行为涌现的基石。当你提交一个bug时,它绝非简单地“看一眼便猜测答案”,而是经历了一个反复观察、假设与验证的过程:先查阅报错日志,继而搜索相关代码,深入理解上下文,最后才动手修复。这种复杂的行为模式并非被硬编码在程序中,而是由循环结构涌现出来的智能表现。
我始终认为,这一循环蕴含着一种哲学层面的美感。它揭示的其实是:智能并非一次性的灵光乍现,而是持续的试探与修正。模型在每一轮循环中都能回溯上一轮的结果,因此它自然会做出“再看看”“再试试”的决策。这与人类解决问题的方式一模一样——只不过人类的循环节奏更为迟缓,且极易在中途被外力打断。
作为工程师,你能做的,是为这个循环设计约束:它能感知什么(工具白名单)、它能记住什么(CLAUDE.md+上下文管理)、它能做什么(权限系统)、它何时应当停止(max-turns+Hooks)。你不需要干预循环内部的决策,那是模型的职责所在。你掌控的,是循环的边界条件。
这正是Harness工程的本质:并非编程行为,而是约束行为。
如果你在读完本书后仍感意犹未尽,渴望更深入地探索“规范驱动”的方法论,推荐你关注我即将出版的《SDD实战:规范驱动开发》。该书系统阐述了SDD的完整方法论体系:从需求分析到架构设计,从任务拆解到验证迭代,从Agent设计模式到团队协作。如果说这本书旨在教你如何调教Harness,那么《SDD实战:规范驱动开发》则专注于教你如何定义规范——两者相辅相成,共同勾勒出AI时代软件工程的完整图景。
倘若你对Agent设计模式的理论框架感兴趣,希望从更高的抽象维度理解感知、记忆、推理、行动、治理等认知模块,那么《Agent设计模式 图解可复用智能体架构》将是你的不二之选。该书以框架形式系统梳理了21个Agent设计模式,是目前该领域较为完备的架构参考。
这3本书分别锚定了3个维度:Harness工程、规范方法论、设计模式理论。自下而上,是构建的视角,教你如何落地;自上而下,是设计的视角,教你如何抽象。
庖丁解牛,游刃有余。
但庖丁并非只会用刀——他洞悉牛的骨骼,他知道刀该从何处切入、何处抽离,他能感知筋膜之间那一丝微不可察的空隙。
Claude Code是刀,你的项目是牛,而本书要教你的,是骨骼的走向、空隙的位置。
现在,该你动手了。
黄佳
2026年初夏
配套资源验证码260928
文中代码字体版权说明
text
Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components
as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting — in part or in whole — any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole, must
be distributed entirely under this license, and must not be distributed
under any other license. The requirement for fonts to remain under this
license does not apply to any document created using the fonts or their
derivatives.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS
IN THE FONT SOFTWARE.
*文中代码字体版权说明
← 上一章:第10章 炉火纯青:工程化实战——从个人到团队 | 返回目录