|
1 | 1 | --- |
2 | 2 | name: review-loop |
3 | | -description: Use this skill whenever the user asks for a review loop, self-review workflow, planner/reviewer/coder/code-reviewer collaboration, plan-before-code process, multi-round agent review, or a stable subagent workflow that must produce a plan, wait for user confirmation, implement code, review the diff, and preserve revision records. This skill requires real subagent support and must not fall back to single-agent roleplay. |
4 | | -protocolVersion: 2.0.0 |
| 3 | +description: 当用户要求评审循环、自评审工作流、planner/reviewer/coder/code-reviewer 协作、先方案后编码、多轮 Agent 评审,或要求稳定的子 Agent 工作流依次产出方案、等待用户确认、实现代码、评审差异并保留修订记录时,使用此 Skill。此 Skill 必须使用真实子 Agent,不得退化为单 Agent 角色扮演。 |
5 | 4 | --- |
6 | 5 |
|
7 | | -# Review Loop |
8 | | - |
9 | | -Use this skill to run a two-phase workflow: |
10 | | - |
11 | | -1. Plan loop: `planner` writes or revises `plan.md`; `plan-reviewer` reviews it. |
12 | | -2. Code loop: after user confirmation, `coder` implements the confirmed plan; `code-reviewer` reviews the resulting diff. |
13 | | - |
14 | | -The workflow requires real planner, reviewer, and coder subagents. If the |
15 | | -current environment cannot create fresh native subagents, stop and tell the |
16 | | -user that `review-loop` cannot run in this session. Codex and Claude Code use |
17 | | -host-native subagents for all four roles. |
18 | | - |
19 | | -## Required Setup |
20 | | - |
21 | | -Before doing task work: |
22 | | - |
23 | | -1. Read `references/protocol.md`, `references/state-machine.md`, and `references/role-contracts.md`. |
24 | | -2. Read `references/codex.md` or `references/claude-code.md` when that platform applies. |
25 | | -3. Create a task id. |
26 | | -4. Run `scripts/init-workspace.js` to create `.agent-workflows/review-loop/<task-id>/`. |
27 | | -5. Run `scripts/prepare-agent-roles.js` to prepare the platform's real subagent roles. |
28 | | -6. Run `scripts/validate-state.js` before advancing. |
29 | | - |
30 | | -Default `maxRounds` is `3`. If the user specifies a maximum loop count, pass it to `init-workspace.js`. |
31 | | - |
32 | | -## Hard Rules |
33 | | - |
34 | | -- Do not implement code until the plan loop has ended and the user explicitly confirms the plan. |
35 | | -- Do not let reviewer roles modify repository files. Reviewers return one strict |
36 | | - JSON object; the orchestrator persists and validates it through |
37 | | - `scripts/review-manager.js --finalize`. |
38 | | -- Start every reviewer in a fresh context that does not inherit planner/coder conversation history. |
39 | | -- On Codex or Claude Code, run `scripts/review-manager.js --prepare`, pass the |
40 | | - returned paths-only prompt to a fresh native reviewer subagent, save its one |
41 | | - JSON response to a temporary file outside the repository, then run |
42 | | - `scripts/review-manager.js --finalize --input <file> --agent-id <id>`. Prepare |
43 | | - binds every input and the Git tree; finalize rejects drift, writes the |
44 | | - immutable reviewer-run, and persists the canonical review. Do not invoke |
45 | | - `scripts/persist-review-json.js` directly. |
46 | | -- Use `scripts/validate-review-json.js` for later read-only revalidation. |
47 | | -- Use `scripts/snapshot-diff.js` after every code loop implementation round. |
48 | | -- `coder-complete` reconstructs the current Git tree, path partitions, and |
49 | | - patches; rerun `snapshot-diff.js` if any code changes after snapshotting. |
50 | | -- Once the current code reviewer-run artifact exists, do not replace its bound |
51 | | - snapshot even when canonical review persistence has not completed. |
52 | | -- Use `scripts/advance-state.js` for every state transition; never hand-edit `state.json`. |
53 | | -- Stop a loop when the reviewer returns `approved` or when the loop reaches `state.json.maxRounds`. |
54 | | -- When a loop stops because `maxRounds` is reached, summarize remaining findings and ask the user whether to continue, accept, or revise. |
55 | | -- If reviewed plan/code changes while waiting at a confirmation gate, prefer a |
56 | | - new review round. Override only after the user's current message explicitly |
57 | | - accepts the changed content; pass `--accept-changed-inputs true` with a |
58 | | - non-empty `--override-reason`. The transition records the accepted drift in |
59 | | - `state.json.confirmationOverrides`. |
60 | | -- Increase `maxRounds` only from that `max_rounds_reached` confirmation gate; |
61 | | - rejecting at that gate cannot resume drafting until the limit is increased, |
62 | | - after a current user message explicitly supplies a higher limit. Pass |
63 | | - `--user-confirmed true`; never reuse an earlier general instruction to bypass |
64 | | - the configured limit. |
65 | | -- Preserve every round's revision record in `plan.md`. |
66 | | - |
67 | | -## Workflow Roles |
68 | | - |
69 | | -The four required roles are: |
| 6 | +# 评审循环 |
| 7 | + |
| 8 | +使用此 Skill 执行两个阶段的工作流: |
| 9 | + |
| 10 | +1. 方案循环:`planner` 编写或修订 `plan.md`,`plan-reviewer` 对其进行评审。 |
| 11 | +2. 代码循环:用户确认方案后,`coder` 实施已确认方案,`code-reviewer` 评审产生的差异。 |
| 12 | + |
| 13 | +该工作流必须使用真实的 planner、reviewer 和 coder 子 Agent。如果当前环境无法创建新的原生子 Agent,停止并告知用户本次会话无法运行 `review-loop`。Codex 和 Claude Code 的四个角色都使用宿主原生子 Agent。 |
| 14 | + |
| 15 | +## 必需准备 |
| 16 | + |
| 17 | +开始任务前: |
| 18 | + |
| 19 | +1. 读取 `references/protocol.md`、`references/state-machine.md` 和 `references/role-contracts.md`。 |
| 20 | +2. 根据当前平台读取 `references/codex.md` 或 `references/claude-code.md`。 |
| 21 | +3. 创建任务 ID。 |
| 22 | +4. 运行 `scripts/init-workspace.js`,创建 `.agent-workflows/review-loop/<task-id>/`。 |
| 23 | +5. 运行 `scripts/prepare-agent-roles.js`,准备当前平台的真实子 Agent 角色。 |
| 24 | +6. 在推进流程前运行 `scripts/validate-state.js`。 |
| 25 | + |
| 26 | +`maxRounds` 默认为 `3`。如果用户指定最大循环轮数,将其传给 `init-workspace.js`。 |
| 27 | + |
| 28 | +## 强制规则 |
| 29 | + |
| 30 | +- 在方案循环结束且用户明确确认方案前,不得实现代码。 |
| 31 | +- 所有面向用户或需要用户确认的自然语言中间产物必须使用中文,包括技术方案、评审摘要与结论、问题说明与修改建议、方案修订记录、代码执行记录、角色日志、验证结果说明、剩余风险,以及确认节点的汇总和提问。命令、路径、代码符号、Markdown 固定字段名、协议枚举值和工具原始输出可保留原文。 |
| 32 | +- 不得让 reviewer 角色修改仓库文件。Reviewer 只返回一份符合固定格式的 Markdown 文档;编排者通过 `scripts/review-manager.js --finalize` 解析、持久化并校验该文档。 |
| 33 | +- `plan-reviewer` 和 `code-reviewer` 的每一轮评审都必须创建全新、独立的原生子 Agent 实例;即使角色和评审类型相同,也不得恢复或复用任何之前轮次创建的 reviewer,且不得继承父级会话、planner 或 coder 的任何上下文。`review-manager.js --finalize` 会拒绝与历史 reviewer-run 重复的 `--agent-id`。 |
| 34 | +- `planner` 和 `coder` 可以跨轮复用各自之前创建的子 Agent 实例,以保留方案修订或代码实现上下文;二者不得相互复用实例。 |
| 35 | +- 在 Codex 或 Claude Code 中,运行 `scripts/review-manager.js --prepare`,将返回的仅含路径的提示词交给新的原生 reviewer 子 Agent,把其唯一纯 Markdown 响应保存到仓库外的临时文件,再运行 `scripts/review-manager.js --finalize --input <file> --agent-id <id>`。Prepare 会绑定全部输入和 Git 树;finalize 会拒绝漂移、直接校验 Markdown、写入不可变的 reviewer-run 并将规范评审持久化为 `reviews/*-review-N.md`。不得直接调用 `scripts/persist-review-markdown.js`。 |
| 36 | +- 后续只读复验使用 `scripts/validate-review-markdown.js`,该命令直接解析和校验 `.md` 文档。 |
| 37 | +- 每轮代码实现和验证完成后直接执行 `coder-complete`。该转换只校验初始基线与当前工作树可以安全重建,不生成差异文件或轮次范围文件。 |
| 38 | +- Prepare 会把初始基线到绑定工作树的完整 diff 写入 `diffs/code-diff-N.patch`,作为代码 reviewer 与人工共同使用的评审交接产物,并将其内容摘要绑定到 reviewer 请求。 |
| 39 | +- 不得生成、传递或记录相邻代码轮次间的增量 patch;`code-diff-N.patch` 始终表示初始基线到当前评审版本的差异。 |
| 40 | +- Prepare 会在 reviewer-run 中绑定当前工作树摘要;评审期间代码发生变化时 finalize 会拒绝结果,必须重新开始当前评审轮次。 |
| 41 | +- 所有状态转换都使用 `scripts/advance-state.js`,不得手动编辑 `state.json`。 |
| 42 | +- reviewer 返回 `approved` 或循环达到 `state.json.maxRounds` 时停止当前循环。 |
| 43 | +- 因达到 `maxRounds` 而停止时,用中文汇总剩余问题,并询问用户要继续、接受还是修订。 |
| 44 | +- 在确认节点等待期间,如果已评审的方案或代码发生变化,优先开启新一轮评审。只有用户当前消息明确接受变化时才可覆盖,并传入 `--accept-changed-inputs true` 和非空的 `--override-reason`。转换会把接受的漂移记录到 `state.json.confirmationOverrides`。 |
| 45 | +- 只能在 `max_rounds_reached` 确认节点增加 `maxRounds`;在该节点拒绝结果后,必须由用户当前消息明确给出更高上限,才能恢复起草。传入 `--user-confirmed true`;不得复用更早的笼统指令绕过已配置上限。 |
| 46 | +- 在 `plan.md` 中保留每轮修订记录,并以中文书写记录内容。 |
| 47 | + |
| 48 | +## 工作流角色 |
| 49 | + |
| 50 | +四个必需角色是: |
70 | 51 |
|
71 | 52 | - `planner` |
72 | 53 | - `plan-reviewer` |
73 | 54 | - `coder` |
74 | 55 | - `code-reviewer` |
75 | 56 |
|
76 | | -Use the templates under `templates/roles/` as role definitions. On Codex and |
77 | | -Claude Code all four roles are native subagents, and reviewer roles must start |
78 | | -with no inherited planner/coder conversation. |
| 57 | +使用 `templates/roles/` 下的模板作为角色定义。在 Codex 和 Claude Code 中,四个角色都必须是原生子 Agent。Planner/coder 后续轮次可以继续使用各自已有实例;plan-reviewer/code-reviewer 每一轮必须新建实例,并禁用父级会话上下文继承。 |
79 | 58 |
|
80 | | -## User Confirmation Gates |
| 59 | +## 用户确认节点 |
81 | 60 |
|
82 | | -After the plan loop ends, show the user: |
| 61 | +方案循环结束后,用中文向用户展示: |
83 | 62 |
|
84 | | -- `plan.md` path |
85 | | -- plan loop termination reason |
86 | | -- review summary by round |
87 | | -- unaccepted findings and reasons |
| 63 | +- `plan.md` 路径 |
| 64 | +- 方案循环终止原因 |
| 65 | +- 按轮次整理的评审摘要 |
| 66 | +- 未接受的问题及理由 |
88 | 67 |
|
89 | | -Ask whether to enter the code loop. Only after explicit confirmation, run `advance-state.js --event confirm-plan`. |
| 68 | +用中文询问是否进入代码循环。只有用户明确确认后,才运行 `advance-state.js --event confirm-plan`。 |
90 | 69 |
|
91 | | -After the code loop ends, show the user: |
| 70 | +代码循环结束后,用中文向用户展示: |
92 | 71 |
|
93 | | -- `plan.md` path |
94 | | -- diff summary |
95 | | -- code loop termination reason |
96 | | -- validation commands and results |
97 | | -- remaining risks |
| 72 | +- `plan.md` 路径 |
| 73 | +- 差异摘要 |
| 74 | +- 代码循环终止原因 |
| 75 | +- 验证命令及结果 |
| 76 | +- 剩余风险 |
98 | 77 |
|
99 | | -Ask whether to accept the final result. Only after explicit confirmation, run `advance-state.js --event confirm-final`. |
| 78 | +用中文询问是否接受最终结果。只有用户明确确认后,才运行 `advance-state.js --event confirm-final`。 |
0 commit comments