编写代理简报
编写代理简报
Section titled “编写代理简报”代理简报是在 issue 或 PR 移至 ready-for-agent 时发布在 GitHub issue 或 PR 上的结构化评论。它是 AFK 代理将据以开展工作的权威规格。原始正文和讨论属于上下文:代理简报才是契约。
简报说明代理应该做什么,这涵盖两种情形:对于 issue,是从零开始构建变更;对于 PR,是完成现有 diff 还需要做什么:完成它、补齐缺口、处理审查意见。两者遵循相同原则;下方 PR 示例展示了区别。
持久性优先于精确性
Section titled “持久性优先于精确性”issue 可能在 ready-for-agent 状态停留数天或数周。期间代码库会发生变化。编写简报时应确保即使文件被重命名、移动或重构,它仍然有用。
- 应该描述接口、类型和行为契约
- 应该指出代理应查找或修改的具体类型、函数签名或配置结构
- 不要引用文件路径:路径会过时
- 不要引用行号
- 不要假设当前实现结构会保持不变
描述行为,不描述步骤
Section titled “描述行为,不描述步骤”描述系统应该做什么,而不是如何实现。代理会重新探索代码库,并自行决定实现方式。
- 好的例子:「
SkillConfig类型应接受一个可选的schedule字段,其类型为CronExpression」 - 不好的例子:「打开 src/types/skill.ts,在第 42 行添加一个 schedule 字段」
- 好的例子:「用户不带参数运行
/triage时,应看到需要关注的 issue 摘要」 - 不好的例子:「在主处理函数中添加一个 switch 语句」
完整的验收标准
Section titled “完整的验收标准”代理需要知道何时算完成。每份代理简报都必须有具体、可测试的验收标准。每项标准都应能独立验证。
- 好的例子:「运行
gh issue list --label needs-triage会返回已完成初步分类的 issue」 - 不好的例子:「分流应正常工作」
明确的范围边界
Section titled “明确的范围边界”说明哪些内容不在范围内。这可以避免代理过度完善,或对相关功能作出假设。
## 代理简报
**类别:** bug / enhancement**摘要:** 用一句话描述需要完成的事
**当前行为:**描述目前发生的情况。对于 bug,这是出错的行为。对于 enhancement,这是该功能所基于的现状。
**期望行为:**描述代理完成工作后应该发生什么。明确说明边缘情况和错误条件。
**关键接口:**- `TypeName`:需要修改什么以及原因- `functionName()` 返回类型:当前返回什么,以及应该返回什么- 配置结构:需要新增的配置选项
**验收标准:**- [ ] 具体、可测试的标准 1- [ ] 具体、可测试的标准 2- [ ] 具体、可测试的标准 3
**范围之外:**- 此 issue 中不应修改或处理的内容- 可能看似相关但实际独立的相邻功能优秀的代理简报(bug)
Section titled “优秀的代理简报(bug)”## 代理简报
**类别:** bug**摘要:** skill 描述截断时会从单词中间截断,导致输出异常
**当前行为:**当 skill 描述超过 1024 个字符时,无论单词边界如何,都会在恰好1024 个字符处截断。这样会导致描述在单词中间结束(例如「Use when the user wants to confi」)。
**期望行为:**截断应在 1024 个字符之前的最后一个单词边界处进行,并添加「...」表示内容已截断。
**关键接口:**- `SkillMetadata` 类型的 `description` 字段:无需更改类型, 但填充该字段的校验或处理逻辑需要遵循单词边界- 任何读取 SKILL.md frontmatter 并提取描述的函数
**验收标准:**- [ ] 少于 1024 个字符的描述保持不变- [ ] 超过 1024 个字符的描述在 1024 个字符之前的最后一个单词边界处截断- [ ] 截断后的描述以「...」结尾- [ ] 包含「...」在内的总长度不超过 1024 个字符
**范围之外:**- 修改 1024 个字符的限制本身- 支持多行描述优秀的代理简报(enhancement)
Section titled “优秀的代理简报(enhancement)”## 代理简报
**类别:** enhancement**摘要:** 支持 `.out-of-scope/` 目录,用于跟踪已拒绝的功能请求
**当前行为:**拒绝功能请求时,会关闭 issue、添加 `wontfix` 标签并发表评论。没有持久记录决策或理由的地方。今后遇到类似请求时,维护者需要回忆或搜索之前的讨论。
**期望行为:**被拒绝的功能请求应记录在 `.out-of-scope/<concept>.md` 文件中,记录决策、理由以及所有请求该功能的 issue 链接。分流新 issue 时,应检查这些文件。
**关键接口:**- `.out-of-scope/` 中的 Markdown 文件格式:每个文件应包含一个 `# Concept Name` 标题、一行 `**Decision:**`、一行 `**Reason:**`,以及一个带有 issue 链接的 `**Prior requests:**` 列表- 分流工作流应尽早读取所有 `.out-of-scope/*.md` 文件,并根据概念相似度将新 issue 与它们进行匹配
**验收标准:**- [ ] 将功能请求以 wontfix 关闭时,会在 `.out-of-scope/` 中创建或更新文件- [ ] 文件包含决策、理由以及已关闭 issue 的链接- [ ] 如果已存在匹配的 `.out-of-scope/` 文件,应将新 issue 添加到其「Prior requests」列表,而不是创建重复文件- [ ] 分流期间应检查现有 `.out-of-scope/` 文件;如果新 issue 与之前拒绝的请求匹配,应显示相关结果
**范围之外:**- 自动匹配(由人工确认匹配结果)- 重新开放此前已拒绝的功能- bug 报告(只有 enhancement 的拒绝请求会记录到 `.out-of-scope/`)优秀的代理简报(PR)
Section titled “优秀的代理简报(PR)”对于 PR,「当前行为」描述 diff 的状态;简报要求代理完成或修复它,而不是从头构建。
## 代理简报
**类别:** enhancement**摘要:** 完成贡献者为 `triage list` 添加的 `--json` 输出标志
**当前行为:**该 PR 添加了一个 `--json` 标志,可将 issue 列表序列化为 JSON。正常流程可以运行,diff 也符合项目的命令结构。仍有两个缺口:错误仍以面向用户的文本输出(而不是 JSON),新标志也没有测试覆盖。
**期望行为:**使用 `--json` 时,所有输出(包括错误)都应在 stdout 上以格式正确的 JSON 输出,命令的退出代码保持不变。不带该标志时,现有的人类可读输出保持原样。
**关键接口:**- 使用 `--json` 时,命令的错误处理路径应输出 `{ "error": string }`,而不是纯文本错误- 重用 PR 已添加的现有序列化器;不要再引入一个
**验收标准:**- [ ] `triage list --json` 在成功和错误情况下都输出有效 JSON- [ ] 退出代码与非 JSON 命令一致- [ ] 测试覆盖 `--json` 的成功输出和一种错误情况- [ ] 默认(非 JSON)输出逐字节保持不变
**范围之外:**- 为其他任何命令添加 `--json`- 修改 PR 已定义的成功载荷 JSON 结构不好的代理简报
Section titled “不好的代理简报”## 代理简报
**摘要:** 修复分流 bug
**要做什么:**分流功能出问题了。看看主文件并修复。问题在第 150 行附近的函数中。
**要修改的文件:**- src/triage/handler.ts (第 150 行)- src/types.ts (第 42 行)这份简报不好,因为:
- 没有类别
- 描述含糊(「分流功能出问题了」)
- 引用了会过时的文件路径和行号
- 没有验收标准
- 没有范围边界
- 没有描述当前行为与期望行为
原文链接和 commit
Section titled “原文链接和 commit”英文 AGENT-BRIEF.md
# Writing Agent Briefs
An agent brief is a structured comment posted on a GitHub issue or PR when it moves to `ready-for-agent`. It is the authoritative specification that an AFK agent will work from. The original body and discussion are context: the agent brief is the contract.
The brief states **what the agent should do**, which stretches to both surfaces: for an issue, that's building the change from nothing; for a PR, it's what's left to do *to the existing diff*: finish it, close gaps, address review points. Same principles either way; the PR example below shows the difference.
## Principles
### Durability over precision
The issue may sit in `ready-for-agent` for days or weeks. The codebase will change in the meantime. Write the brief so it stays useful even as files are renamed, moved, or refactored.
- **Do** describe interfaces, types, and behavioral contracts- **Do** name specific types, function signatures, or config shapes that the agent should look for or modify- **Don't** reference file paths: they go stale- **Don't** reference line numbers- **Don't** assume the current implementation structure will remain the same
### Behavioral, not procedural
Describe **what** the system should do, not **how** to implement it. The agent will explore the codebase fresh and make its own implementation decisions.
- **Good:** "The `SkillConfig` type should accept an optional `schedule` field of type `CronExpression`"- **Bad:** "Open src/types/skill.ts and add a schedule field on line 42"- **Good:** "When a user runs `/triage` with no arguments, they should see a summary of issues needing attention"- **Bad:** "Add a switch statement in the main handler function"
### Complete acceptance criteria
The agent needs to know when it's done. Every agent brief must have concrete, testable acceptance criteria. Each criterion should be independently verifiable.
- **Good:** "Running `gh issue list --label needs-triage` returns issues that have been through initial classification"- **Bad:** "Triage should work correctly"
### Explicit scope boundaries
State what is out of scope. This prevents the agent from gold-plating or making assumptions about adjacent features.
## Template
```markdown## Agent Brief
**Category:** bug / enhancement**Summary:** one-line description of what needs to happen
**Current behavior:**Describe what happens now. For bugs, this is the broken behavior.For enhancements, this is the status quo the feature builds on.
**Desired behavior:**Describe what should happen after the agent's work is complete.Be specific about edge cases and error conditions.
**Key interfaces:**- `TypeName`: what needs to change and why- `functionName()` return type: what it currently returns vs what it should return- Config shape: any new configuration options needed
**Acceptance criteria:**- [ ] Specific, testable criterion 1- [ ] Specific, testable criterion 2- [ ] Specific, testable criterion 3
**Out of scope:**- Thing that should NOT be changed or addressed in this issue- Adjacent feature that might seem related but is separate```
## Examples
### Good agent brief (bug)
```markdown## Agent Brief
**Category:** bug**Summary:** Skill description truncation drops mid-word, producing broken output
**Current behavior:**When a skill description exceeds 1024 characters, it is truncated at exactly1024 characters regardless of word boundaries. This produces descriptionsthat end mid-word (e.g. "Use when the user wants to confi").
**Desired behavior:**Truncation should break at the last word boundary before 1024 charactersand append "..." to indicate truncation.
**Key interfaces:**- The `SkillMetadata` type's `description` field: no type change needed, but the validation/processing logic that populates it needs to respect word boundaries- Any function that reads SKILL.md frontmatter and extracts the description
**Acceptance criteria:**- [ ] Descriptions under 1024 chars are unchanged- [ ] Descriptions over 1024 chars are truncated at the last word boundary before 1024 chars- [ ] Truncated descriptions end with "..."- [ ] The total length including "..." does not exceed 1024 chars
**Out of scope:**- Changing the 1024 char limit itself- Multi-line description support```
### Good agent brief (enhancement)
```markdown## Agent Brief
**Category:** enhancement**Summary:** Add `.out-of-scope/` directory support for tracking rejected feature requests
**Current behavior:**When a feature request is rejected, the issue is closed with a `wontfix` labeland a comment. There is no persistent record of the decision or reasoning.Future similar requests require the maintainer to recall or search for theprior discussion.
**Desired behavior:**Rejected feature requests should be documented in `.out-of-scope/<concept>.md`files that capture the decision, reasoning, and links to all issues thatrequested the feature. When triaging new issues, these files should bechecked for matches.
**Key interfaces:**- Markdown file format in `.out-of-scope/`: each file should have a `# Concept Name` heading, a `**Decision:**` line, a `**Reason:**` line, and a `**Prior requests:**` list with issue links- The triage workflow should read all `.out-of-scope/*.md` files early and match incoming issues against them by concept similarity
**Acceptance criteria:**- [ ] Closing a feature as wontfix creates/updates a file in `.out-of-scope/`- [ ] The file includes the decision, reasoning, and link to the closed issue- [ ] If a matching `.out-of-scope/` file already exists, the new issue is appended to its "Prior requests" list rather than creating a duplicate- [ ] During triage, existing `.out-of-scope/` files are checked and surfaced when a new issue matches a prior rejection
**Out of scope:**- Automated matching (human confirms the match)- Reopening previously rejected features- Bug reports (only enhancement rejections go to `.out-of-scope/`)```
### Good agent brief (PR)
For a PR, "Current behavior" describes the state of the diff, and the brief asks the agent to finish or fix it rather than build from scratch.
```markdown## Agent Brief
**Category:** enhancement**Summary:** Finish the contributor's `--json` output flag for `triage list`
**Current behavior:**The PR adds a `--json` flag that serializes the issue list to JSON. The happypath works and the diff matches the project's command structure. Two gapsremain: errors are still printed as human text (not JSON), and the new flag hasno test coverage.
**Desired behavior:**With `--json`, all output (including errors) is well-formed JSON on stdout,and the command's exit codes are unchanged. The existing human-readable outputis untouched when the flag is absent.
**Key interfaces:**- The command's error path should emit `{ "error": string }` under `--json` instead of the plain-text error- Reuse the existing serializer the PR already added; don't introduce a second
**Acceptance criteria:**- [ ] `triage list --json` emits valid JSON for both success and error cases- [ ] Exit codes match the non-JSON command- [ ] A test covers the `--json` success output and one error case- [ ] Default (non-JSON) output is byte-for-byte unchanged
**Out of scope:**- Adding `--json` to any other command- Changing the JSON shape of the success payload the PR already defined```
### Bad agent brief
```markdown## Agent Brief
**Summary:** Fix the triage bug
**What to do:**The triage thing is broken. Look at the main file and fix it.The function around line 150 has the issue.
**Files to change:**- src/triage/handler.ts (line 150)- src/types.ts (line 42)```
This is bad because:- No category- Vague description ("the triage thing is broken")- References file paths and line numbers that will go stale- No acceptance criteria- No scope boundaries- No description of current vs desired behavior非官方学习站,与 Matt Pocock 和 AI Hero 没有隶属关系。本站不提供可安装的中文技能包。
技能原文采用 MIT 许可。Copyright (c) 2026 Matt Pocock