Agent Harness Engineering
Use this skill when the goal is to make a repository easier for coding agents to understand, change, and maintain over time.
This skill turns the main ideas from OpenAI's harness-engineering article into a reusable project pattern:
- -
AGENTS.md stays short and acts as a router - durable knowledge moves into INLINECODE1
- context is disclosed progressively instead of dumped all at once
- quality rules become mechanical checks instead of tribal knowledge
- optional garbage collection keeps agent-generated entropy under control
When to use it
Use this skill when the user asks to:
- - create a reusable engineering skill for many repos
- bootstrap a repo for agent-first or AI-assisted development
- redesign
AGENTS.md so it routes to structured docs - add repo-readable architecture, spec, quality, reliability, or security docs
- add mechanical checks for doc freshness, structure, and agent guardrails
- add a low-friction cleanup loop for drift, stale docs, and code sprawl
Choose a rollout mode
Pick the least invasive mode that still improves the repo.
- -
overlay: Default for existing repos. Add docs/agent/ as an agent-readable overlay without rewriting existing docs. full: Use for greenfield repos or when the user explicitly wants a broader doc reorganization.
For most mature repos, start with overlay.
First-use workflow
When applying this pattern to a repo for the first time, do the following in order:
- 1. Inspect the repo's current
AGENTS.md, docs/, CI, and lint/test commands. - Run the bundled bootstrap script in
overlay or full mode. - Review the generated
AGENTS.md block and adapt command names to the repo. - Keep existing project-specific instructions, but move durable detail from
AGENTS.md into the generated docs. - Wire the generated validation script into the repo's native check flow.
- If the repo moves fast or uses many agents, optionally enable garbage collection.
Bootstrap command
Run the bundled script from this skill directory:
CODEBLOCK0
Optional flags:
- - INLINECODE13
- INLINECODE14 to scaffold the garbage-collection report
- INLINECODE15 to preview changes
- INLINECODE16 to overwrite generated files
- INLINECODE17 to skip the
CLAUDE.md -> AGENTS.md symlink
What the bootstrap adds
On first application, the scaffold normally creates or updates:
- -
AGENTS.md with a short agent-navigation block - INLINECODE20 symlink to
AGENTS.md unless disabled - INLINECODE22
- INLINECODE23
- INLINECODE24
- INLINECODE25
- INLINECODE26
- INLINECODE27
- INLINECODE28
- INLINECODE29
- optionally INLINECODE30
- optionally INLINECODE31
Operating rules
1. AGENTS.md is a router
Do not turn AGENTS.md into a giant handbook.
- - keep it short
- link outward to durable docs
- update links when docs move
- reserve
AGENTS.md for task-routing instructions and repo-specific operational constraints
2. Durable knowledge lives in docs
Put medium- and long-lived repo knowledge in docs/agent/ or the repo's main docs tree.
Examples:
- - architecture boundaries
- product or integration specs
- current plans
- quality gates and invariants
- reliability expectations
- security assumptions and trust boundaries
3. Progressive disclosure beats giant prompts
Only read the docs needed for the task.
- - start at INLINECODE36
- open the relevant leaf docs
- avoid loading unrelated docs into context
- add new docs to the index so future agents can discover them quickly
4. Mechanical checks beat soft reminders
Prefer checks that can fail fast in CI or local validation:
- - missing required docs
- missing frontmatter fields
- stale review dates
- docs not linked from the index
- INLINECODE37 missing navigation links
5. Garbage collection is optional but useful
Enable the GC loop when the repo has high change velocity, many generated edits, or recurring drift.
The default GC report looks for:
- - stale docs
- oversized files
- suspicious filenames like
final-final or INLINECODE39 - lingering
TODO or FIXME clusters - docs that are not linked from the index
References to read only when needed
- - Read
references/bootstrap-playbook.md when planning the first rollout for a repo. - Read
references/docs-blueprint.md when adapting the doc taxonomy or frontmatter. - Read
references/quality-gates.md when wiring checks into CI or repo-native tooling. - Read
references/garbage-collection.md when enabling scheduled cleanup or review loops.
Acceptance checklist
Before you finish a rollout, confirm:
- -
AGENTS.md routes to docs instead of duplicating them - INLINECODE47 points to every active leaf doc
- the generated docs have owners and
last_reviewed dates - INLINECODE49 passes
- the repo's native check command includes the validation script or an equivalent wrapper
- garbage collection is either enabled intentionally or documented as deferred
Do not do this
- - do not rewrite a mature doc system unless the user asks
- do not duplicate the same guidance in
AGENTS.md and INLINECODE51 - do not add stack-specific CI assumptions without checking the repo
- do not enable automatic destructive cleanup; GC should surface candidates, not delete code blindly
技能名称: agent-harness-engineering
详细描述:
智能体工具工程
当目标是让代码仓库更易于编码智能体理解、修改和长期维护时,请使用此技能。
该技能将OpenAI的工具工程文章中的核心思想转化为可复用的项目模式:
- - AGENTS.md保持简短,充当路由角色
- 持久性知识移至docs/目录
- 上下文逐步披露,而非一次性全部加载
- 质量规则变为机械检查,而非隐性知识
- 可选的垃圾回收机制控制智能体产生的熵增
使用时机
当用户要求以下内容时使用此技能:
- - 为多个仓库创建可复用的工程技能
- 为智能体优先或AI辅助开发引导仓库初始化
- 重新设计AGENTS.md,使其路由到结构化文档
- 添加仓库可读的架构、规范、质量、可靠性或安全文档
- 添加文档新鲜度、结构和智能体护栏的机械检查
- 为漂移、过时文档和代码蔓延添加低摩擦清理循环
选择部署模式
选择对仓库侵入性最小的模式。
- - overlay:现有仓库的默认模式。添加docs/agent/作为智能体可读的覆盖层,无需重写现有文档。
- full:用于全新仓库或用户明确要求更广泛文档重组的情况。
对于大多数成熟仓库,从overlay模式开始。
首次使用工作流
首次将本模式应用于仓库时,按顺序执行以下操作:
- 1. 检查仓库当前的AGENTS.md、docs/、CI和lint/test命令。
- 以overlay或full模式运行捆绑的引导脚本。
- 审查生成的AGENTS.md区块,并根据仓库调整命令名称。
- 保留现有的项目特定指令,但将AGENTS.md中的持久性细节移至生成的文档中。
- 将生成的验证脚本接入仓库的原生检查流程。
- 如果仓库迭代速度快或使用多个智能体,可选择启用垃圾回收。
引导命令
从本技能目录运行捆绑脚本:
bash
python3 scripts/bootstrap_project.py --repo /path/to/repo --mode overlay
可选标志:
- - --mode overlay|full
- --with-gc 搭建垃圾回收报告框架
- --dry-run 预览更改
- --force 覆盖已生成的文件
- --no-claude-link 跳过CLAUDE.md -> AGENTS.md符号链接
引导添加的内容
首次应用时,脚手架通常会创建或更新:
- - AGENTS.md,包含简短的智能体导航区块
- CLAUDE.md符号链接到AGENTS.md(除非禁用)
- docs/agent/index.md
- docs/agent/architecture.md
- docs/agent/specs.md
- docs/agent/plans.md
- docs/agent/quality.md
- docs/agent/reliability.md
- docs/agent/security.md
- scripts/agentrepocheck.py
- 可选:docs/agent/garbage-collection.md
- 可选:scripts/agentgcreport.py
操作规则
1. AGENTS.md是路由
不要将AGENTS.md变成一本巨大的手册。
- - 保持简短
- 链接到外部持久性文档
- 文档移动时更新链接
- 保留AGENTS.md用于任务路由指令和仓库特定的操作约束
2. 持久性知识存放在文档中
将中期和长期仓库知识放在docs/agent/或仓库的主文档树中。
示例:
- - 架构边界
- 产品或集成规范
- 当前计划
- 质量门禁和不变量
- 可靠性期望
- 安全假设和信任边界
3. 渐进式披露优于巨型提示
只读取任务所需的文档。
- - 从docs/agent/index.md开始
- 打开相关的叶子文档
- 避免将无关文档加载到上下文中
- 将新文档添加到索引中,以便未来的智能体能够快速发现它们
4. 机械检查优于软提醒
优先选择能在CI或本地验证中快速失败的检查:
- - 缺少必需的文档
- 缺少前置元数据字段
- 审查日期过期
- 文档未从索引链接
- AGENTS.md缺少导航链接
5. 垃圾回收可选但有用
当仓库变更速度快、生成编辑多或存在反复漂移时,启用GC循环。
默认GC报告查找:
- - 过时文档
- 超大文件
- 可疑文件名,如final-final或v2
- 残留的TODO或FIXME集群
- 未从索引链接的文档
仅在需要时阅读的参考资料
- - 规划仓库首次部署时,阅读references/bootstrap-playbook.md。
- 调整文档分类或前置元数据时,阅读references/docs-blueprint.md。
- 将检查接入CI或仓库原生工具时,阅读references/quality-gates.md。
- 启用定时清理或审查循环时,阅读references/garbage-collection.md。
验收清单
完成部署前,确认:
- - AGENTS.md路由到文档而非重复内容
- docs/agent/index.md指向每个活跃的叶子文档
- 生成的文档有所有者和lastreviewed日期
- scripts/agentrepo_check.py通过
- 仓库的原生检查命令包含验证脚本或等效包装器
- 垃圾回收要么已有意启用,要么已记录为推迟执行
禁止事项
- - 除非用户要求,否则不要重写成熟的文档系统
- 不要在AGENTS.md和docs/agent/*中重复相同的指导内容
- 未经检查仓库,不要添加特定技术栈的CI假设
- 不要启用自动破坏性清理;GC应展示候选对象,而非盲目删除代码