乐于分享
好东西不私藏

2026 年火遍 AI 圈的驾驭工程(Harness Engineering)是什么?

2026 年火遍 AI 圈的驾驭工程(Harness Engineering)是什么?

一、从 1300 年前说起

harness 这个词,最早出现约 1300 年前,指的是马具 —— 把马、缰绳、车厢绑在一起,让马的力气能被引导到正确的方向上。

后来这个词被工程界借走:

  1. 1. Wire Harness(线束):汽车里那一捆把发动机、电池、传感器连在一起的电线。
  2. 2. Test Harness(测试支架):软件工程里跑测试用的脚手架 —— mock、fixture、runner、断言库。
  3. 3. Harness Engineering(AI Agent 的执行环境):2025 年之后开始流行的新词,指围绕 AI Coding Agent 搭建的「约束 + 反馈 + 验证」系统。

这几个场景的共同点是:本体(马、电流、代码、模型)很强大但很野,harness 的作用是把这股力量约束、引导、可验证地输出。

二、AI Coding 里的 Harness —— 新的主角

Martin Fowler 给的定义非常简洁:harness 是模型之外、帮助 agent 工作的所有外层机制。可以记一个公式:

Coding Agent = Model + Context + Tools + Constraints + Feedback + Human Control
                              └──────────── Harness ────────────┘

可以这么理解:

  • Prompt Engineering:你对模型说什么(写实习生的任务书)
  • Context Engineering:模型能看到什么(给实习生准备资料)
  • Harness Engineering:实习生在什么环境里干活、有哪些权限、什么时候 review、谁能拍板上线

三、一个好 harness 的九个维度

借鉴 Anthropic、Augment、Milvus 等公开资料,加上 vmark/claudepot-app 这类开源项目的真实做法,可以拆成:

  1. 1. 任务边界:能改 bug、能写测试;不能改支付逻辑、不能直接 deploy。
  2. 2. 上下文系统CLAUDE.md /AGENTS.md 不是堆文档,而是「指向结构化资料的地图」。
  3. 3. 工具集:grep、LSP、typecheck、test runner —— 工具产生的确定性反馈,比 prompt 里写「请小心」可靠一万倍
  4. 4. 硬约束:把规则从 prompt 搬进 linter/CI。「请遵守架构规范」是软约束;CI 阻止跨层 import 是硬约束。
  5. 5. 反馈闭环:差的反馈是Lint failed;好的反馈是File: x.ts:42, use logger.info instead of console.log
  6. 6. 独立验证:agent 自己说「done」不算数,必须由外部测试/fixture 判定。claudepot-app 的parity-harness 就是典型 —— 把输入/期望输出存成文件,每次跑xtask verify-cc-parity 自动 diff。
  7. 7. 权限与破坏半径:禁止rm -rf、禁止直 push main、敏感目录只读。
  8. 8. 可观测性:记录 agent 读了哪些文件、调了哪些工具、哪些测试反复挂 —— 这是改进 harness 的唯一依据。
  9. 9. 人机协作 gate:formatter 自动过;API change/DB migration 必须人工 review。

四、最小可用版本

不需要一上来就上各种 Harness 配置全家桶,起步阶段:

repo/
├── AGENTS.md                 # 100-200 行,agent 工作入口
├── docs/{architecture,style,testing,domain}.md
├── scripts/check-agent-work.sh   # lint + typecheck + test + build
└── .github/workflows/ci.yml

AGENTS.md 里写上关键的一句:

Before claiming the task is complete, run./scripts/check-agent-work.sh. Do not mark complete until all checks pass.

这就是一个能跑的 coding harness。

五、为什么这件事现在才火

2023-2024 年大家在卷 prompt;2025 年卷 context(RAG、长上下文);2026 年发现:模型已经足够聪明,瓶颈在「能不能在真实代码库里被信任地运行多轮」

Anthropic 自己的 C 编译器项目(3982 commits、几乎全部由 Claude 写)证明了一个朴素结论:harness 的质量,决定了 agent 自主性的上限。测试足够严、fixture 足够全、回退路径足够明确,Claude 就能跑几千个 commit 不翻车;反之,再强的模型也只是个会幻觉的实习生。

一句话总结

Harness Engineering 把 AI Coding 从「会聊天的代码助手」变成「受约束、可验证、可纠错、可审计的软件工程执行系统」。

核心不是写更聪明的 prompt,而是设计一个更可靠的工作环境 —— 就像当年给马套上缰绳,不是为了限制它,而是为了让它真正能拉动车。


参考链接

概念与方法论

  • • Birgitta Böckeler (Thoughtworks), Harness engineering for coding agent users — https://martinfowler.com/articles/harness-engineering.html
  • • Augment Code, Harness Engineering for AI Coding Agents: Constraints That Ship Reliable Code — https://www.augmentcode.com/guides/harness-engineering-ai-coding-agents
  • • Milvus Blog, What Is Harness Engineering for AI Agents? — https://milvus.io/blog/harness-engineering-ai-agents.md

Anthropic 官方资料

  • • Claude Code 官方文档(含 hooks、memory、subagents、programmatic usage) — https://code.claude.com/docs/en/overview
  • • Nicholas Carlini, Building a C compiler with a team of parallel Claudes(16 个 agent / 100k 行 / $20k) — https://www.anthropic.com/engineering/building-c-compiler
  • How a non-technical project manager built and shipped Respiro with Claude Code in six weeks — https://claude.com/blog/how-a-non-technical-project-manager-built-and-shipped-a-stress-management-app-with-claude-code-in-six-weeks
  • How Anthropic's cybersecurity team built a threat detection platform (CLUE) with Claude Code — https://claude.com/blog/how-anthropic-uses-claude-cybersecurity

社区实战记录

  • The 3-Day MVP: How I Built and Launched SubflowAI in 19 Days using Claude Code — https://genaiunplugged.substack.com/p/subflow-ai-chrome-extension-schedule-notes-substack
  • • Aviad Rozenhek, Building gemini-imagen with Claude Code: How AI Became My Pair Programming Partner — https://dev.to/aviad_rozenhek_cba37e0660/building-gemini-imagen-with-claude-code-how-ai-became-my-pair-programming-partner-ca9
  • • Claude Code Toolkit(explore → plan → next → ship 开源 harness 框架) — https://github.com/applied-artificial-intelligence/claude-code-toolkit