Skip to content

Commit 629c46c

Browse files
committed
update review-loop skill
1 parent 14548ee commit 629c46c

30 files changed

Lines changed: 4565 additions & 256 deletions

.agents/skills/review-loop/SKILL.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: review-loop
33
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: 1.0.0
4+
protocolVersion: 2.0.0
55
---
66

77
# Review Loop
@@ -11,7 +11,10 @@ Use this skill to run a two-phase workflow:
1111
1. Plan loop: `planner` writes or revises `plan.md`; `plan-reviewer` reviews it.
1212
2. Code loop: after user confirmation, `coder` implements the confirmed plan; `code-reviewer` reviews the resulting diff.
1313

14-
The workflow requires real subagents. If the current environment cannot create real subagents, stop and tell the user that `review-loop` cannot run in this session.
14+
The workflow requires real planner and coder subagents. If the current
15+
environment cannot create them, stop and tell the user that `review-loop`
16+
cannot run in this session. Codex and Claude Code reviewers run as standalone
17+
CLI processes instead of custom subagents.
1518

1619
## Required Setup
1720

@@ -21,23 +24,50 @@ Before doing task work:
2124
2. Read `references/codex.md` or `references/claude-code.md` when that platform applies.
2225
3. Create a task id.
2326
4. Run `scripts/init-workspace.js` to create `.agent-workflows/review-loop/<task-id>/`.
24-
5. Run `scripts/prepare-agent-roles.js` to prepare real subagent roles.
27+
5. Run `scripts/prepare-agent-roles.js` to prepare the platform's real subagent roles.
2528
6. Run `scripts/validate-state.js` before advancing.
2629

2730
Default `maxRounds` is `3`. If the user specifies a maximum loop count, pass it to `init-workspace.js`.
2831

2932
## Hard Rules
3033

3134
- Do not implement code until the plan loop has ended and the user explicitly confirms the plan.
32-
- Do not let reviewer roles modify `plan.md` or source files; reviewers write JSON review files only.
33-
- Use `scripts/validate-review-json.js` after every reviewer output.
35+
- Do not let reviewer roles modify repository files. Reviewers return one strict
36+
JSON object; the orchestrator persists and validates it with
37+
`scripts/persist-review-json.js`.
38+
- Start every reviewer in a fresh context that does not inherit planner/coder conversation history.
39+
- On Codex or Claude Code, enter the reviewing phase, then run
40+
`scripts/run-reviewer.js`. It starts a new read-only CLI process with
41+
state-derived paths, binds every initial input to a SHA-256 digest, writes an
42+
immutable `runtime/reviewer-runs/*` artifact, validates the strict JSON
43+
result, and persists the canonical review. Code reviews also bind the
44+
validated Git snapshot tree. Reviewing-phase advancement fails when any
45+
bound input, snapshot, or run artifact changes. Confirmation gates check only
46+
`plan.md` or the Git tree, so later task-workspace patch, scope, review, and
47+
log edits do not block normal work by themselves. Do not invoke
48+
`scripts/persist-review-json.js` directly on either platform.
49+
- Use `scripts/validate-review-json.js` for later read-only revalidation.
3450
- Use `scripts/snapshot-diff.js` after every code loop implementation round.
51+
- `coder-complete` reconstructs the current Git tree, path partitions, and
52+
patches; rerun `snapshot-diff.js` if any code changes after snapshotting.
53+
- Once the current code reviewer-run artifact exists, do not replace its bound
54+
snapshot even when canonical review persistence has not completed.
3555
- Use `scripts/advance-state.js` for every state transition; never hand-edit `state.json`.
3656
- Stop a loop when the reviewer returns `approved` or when the loop reaches `state.json.maxRounds`.
3757
- When a loop stops because `maxRounds` is reached, summarize remaining findings and ask the user whether to continue, accept, or revise.
58+
- If reviewed plan/code changes while waiting at a confirmation gate, prefer a
59+
new review round. Override only after the user's current message explicitly
60+
accepts the changed content; pass `--accept-changed-inputs true` with a
61+
non-empty `--override-reason`. The transition records the accepted drift in
62+
`state.json.confirmationOverrides`.
63+
- Increase `maxRounds` only from that `max_rounds_reached` confirmation gate;
64+
rejecting at that gate cannot resume drafting until the limit is increased,
65+
after a current user message explicitly supplies a higher limit. Pass
66+
`--user-confirmed true`; never reuse an earlier general instruction to bypass
67+
the configured limit.
3868
- Preserve every round's revision record in `plan.md`.
3969

40-
## Subagent Roles
70+
## Workflow Roles
4171

4272
The four required roles are:
4373

@@ -46,7 +76,10 @@ The four required roles are:
4676
- `coder`
4777
- `code-reviewer`
4878

49-
Use the templates under `templates/roles/` to prepare role definitions. If project-level roles already exist, reuse them. If not, ask whether to create temporary roles under the task workspace or persist roles to the project agent config.
79+
Use the templates under `templates/roles/` as role definitions. On Codex and
80+
Claude Code, only `planner` and `coder` are custom subagents;
81+
`plan-reviewer` and `code-reviewer` templates are consumed by
82+
`run-reviewer.js`. Do not create reviewer agent definitions.
5083

5184
## User Confirmation Gates
5285

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"rootDir": ".",
3+
"testEnvironment": "node",
4+
"testMatch": ["<rootDir>/scripts/__tests__/**/*.spec.js"],
5+
"passWithNoTests": false,
6+
"watchman": false,
7+
"testTimeout": 10000
8+
}
Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,109 @@
11
# Claude Code Integration
22

3-
Claude Code support requires real subagents. Do not run this workflow as single-agent roleplay.
3+
Claude Code support uses real planner/coder subagents and standalone reviewer
4+
CLI processes. Do not run planner or coder as single-agent roleplay.
45

56
## Role Discovery
67

78
Check project agents first:
89

910
```text
1011
.claude/agents/planner.md
11-
.claude/agents/plan-reviewer.md
1212
.claude/agents/coder.md
13-
.claude/agents/code-reviewer.md
1413
```
1514

16-
If all four exist, reuse them.
15+
If both exist, reuse them. Reviewer instructions remain under
16+
`templates/roles/` and are consumed by `run-reviewer.js`; do not create Claude
17+
Code reviewer agents.
1718

18-
If any are missing, ask the user to choose:
19+
If either planner/coder role is missing, ask the user to choose:
1920

2021
- temporary roles under `.agent-workflows/review-loop/<task-id>/runtime/roles/`
2122
- persistent project agents under `.claude/agents/`
2223

23-
Use `scripts/prepare-agent-roles.js` for either path.
24+
Use `scripts/prepare-agent-roles.js` for either path. `auto` mode compares only
25+
the planner and coder project roles with their generated definitions.
26+
27+
## Agent Format
28+
29+
Claude Code custom agents are Markdown files with YAML frontmatter:
30+
31+
```yaml
32+
---
33+
name: planner
34+
description: Planner for review-loop workflows.
35+
---
36+
```
37+
38+
Planner and coder inherit the parent model, effort, tools, and permission mode.
2439

2540
## Temporary Roles
2641

27-
Temporary roles are copied from `templates/roles/` to:
42+
Temporary planner/coder roles are copied from `templates/roles/` to:
2843

2944
```text
3045
.agent-workflows/review-loop/<task-id>/runtime/roles/
3146
```
3247

33-
They are valid only for the current task.
48+
They are valid only for the current task. Claude Code automatically discovers
49+
named agents only from its configured agent locations. Use temporary
50+
definitions only when the host can register them for the current session.
51+
Otherwise choose project roles.
3452

3553
## Persistent Roles
3654

37-
Persistent roles are copied from `templates/roles/` to:
55+
Persistent planner/coder roles are copied to:
3856

3957
```text
4058
.claude/agents/
4159
```
4260

43-
This requires explicit user confirmation because it modifies project-level agent configuration.
61+
This requires explicit user confirmation because it modifies project-level
62+
agent configuration. Reload manually created agent files with `/agents` or
63+
restart the session before invoking them.
64+
65+
## Starting Roles
66+
67+
Start planner and coder as new named subagent invocations when required by the
68+
state machine. Reviewers are started only through:
69+
70+
```bash
71+
node .agents/skills/review-loop/scripts/run-reviewer.js \
72+
--task-id <task-id> \
73+
--kind plan|code \
74+
--round N
75+
```
76+
77+
For plan review, the script starts a new `claude -p` process with a paths-only
78+
review prompt. For code review, it starts a new `claude -p` process whose user
79+
message invokes `/code-review high` against the cumulative round patch. The
80+
native skill may use its own internal reviewer agents; the workflow does not
81+
create or resume an outer reviewer subagent.
82+
83+
Both commands pin `model = opus`, `effort = high`,
84+
`permission-mode = plan`, deny direct edit tools, omit `--fix`, and set
85+
`--no-session-persistence`. They request `--output-format json` with
86+
`--json-schema`; the runner extracts `structured_output`, validates it, writes
87+
the immutable reviewer-run artifact, and persists the canonical review. Every
88+
initial input is bound to a SHA-256 digest. Code reviews additionally bind and
89+
revalidate the snapshot tree and patches before launch, after completion, and
90+
during later state validation.
91+
92+
The runner derives `model = opus`, `reasoningEffort = high`, read-only mode, and
93+
the plan/code-specific source from the command and overwrites
94+
`evidence.reviewerConfig`; reviewer self-reporting is not trusted.
95+
96+
The fresh CLI process does not inherit the planner/coder conversation. It still
97+
loads repository-visible Claude Code configuration and can inspect files in the
98+
working tree. This is conversation isolation, not repository-read isolation.
99+
100+
Do not invoke `persist-review-json.js` directly for Claude Code reviews.
44101

45102
## Failure
46103

47-
If Claude Code cannot create real subagents in the current session, stop the workflow and tell the user:
104+
If Claude Code cannot create real planner/coder subagents in the current
105+
session, stop the workflow and tell the user:
48106

49107
```text
50-
review-loop requires real subagent support. Current Claude Code session cannot create subagents, so the workflow cannot continue.
108+
review-loop requires real planner/coder subagent support. Current Claude Code session cannot create subagents, so the workflow cannot continue.
51109
```
Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
# Codex Integration
22

3-
Codex support requires real subagents. Do not run this workflow as single-agent roleplay.
3+
Codex support uses real planner/coder subagents and standalone ephemeral
4+
`codex exec review` processes with JSON Schema output. Do not run planner or
5+
coder as single-agent roleplay.
46

57
## Role Discovery
68

79
Check project custom agents first:
810

911
```text
1012
.codex/agents/planner.toml
11-
.codex/agents/plan-reviewer.toml
1213
.codex/agents/coder.toml
13-
.codex/agents/code-reviewer.toml
1414
```
1515

16-
If all four exist, reuse them.
16+
If both exist, reuse them. Reviewer instructions remain under
17+
`templates/roles/` and are read by `run-reviewer.js`; do not create reviewer
18+
agent TOMLs.
1719

18-
If any are missing, ask the user to choose:
19-
20-
- temporary roles under `.agent-workflows/review-loop/<task-id>/runtime/roles/`
21-
- persistent project custom agents under `.codex/agents/`
22-
23-
Use `scripts/prepare-agent-roles.js` for either path.
20+
If any are missing or stale, ask the user for permission to create or refresh
21+
the project custom agents under `.codex/agents/`, then run
22+
`scripts/prepare-agent-roles.js --mode project`. Codex discovers custom agents
23+
only from its personal or project agent directories, so task-workspace
24+
temporary roles are not supported.
2425

2526
## Persistent Agent Format
2627

@@ -37,7 +38,9 @@ Do not implement code.
3738

3839
## Starting Roles
3940

40-
Codex does not spawn subagents without an explicit request. After roles are prepared, the orchestrator must explicitly start the four role subagents as the state machine requires.
41+
Codex does not spawn subagents without an explicit request. After roles are
42+
prepared, the orchestrator must explicitly start planner and coder as the state
43+
machine requires. Reviewers are started only through `scripts/run-reviewer.js`.
4144

4245
For each role, include:
4346

@@ -48,10 +51,43 @@ For each role, include:
4851
- required output path
4952
- instruction to return a concise summary to the orchestrator
5053

54+
After `planner-complete` or `coder-complete`, run the state-derived reviewer:
55+
56+
```bash
57+
node .agents/skills/review-loop/scripts/run-reviewer.js \
58+
--task-id <task-id> \
59+
--kind plan|code \
60+
--round N
61+
```
62+
63+
The script launches a new CLI process rather than resuming or forking the parent
64+
conversation. It passes only fixed instructions plus state-derived repository
65+
paths, records a SHA-256 digest for every initial input, explicitly selects a
66+
read-only sandbox, validates the returned strict JSON, and writes both the
67+
immutable run record and canonical review artifact. Code review runs also bind
68+
the validated snapshot tree and fail if the worktree or patches drift.
69+
Do not invoke `persist-review-json.js` directly for Codex reviews.
70+
71+
This isolates conversation history, not repository visibility. The reviewer can
72+
read any file visible inside the repository's read-only sandbox.
73+
74+
`run-reviewer.js` pins `model = "gpt-5.6"`, uses
75+
`--ephemeral --output-schema schemas/review.schema.json`,
76+
`model_reasoning_effort = "high"`, and `sandbox_mode = "read-only"` on the
77+
command line. Each review records those settings and
78+
`source = "codex-exec-review-command"` in `evidence.reviewerConfig`. The runner
79+
derives and overwrites this configuration from the actual command; reviewer
80+
self-reporting is not trusted as audit evidence.
81+
82+
In `auto` mode, `prepare-agent-roles.js` compares the planner and coder project
83+
roles with their current templates. A mismatch returns `stale_roles`; refresh
84+
project roles explicitly before spawning planner or coder.
85+
5186
## Failure
5287

53-
If Codex cannot create real subagents in the current session, stop the workflow and tell the user:
88+
If Codex cannot create real planner/coder subagents in the current session,
89+
stop the workflow and tell the user:
5490

5591
```text
56-
review-loop requires real subagent support. Current Codex session cannot create subagents, so the workflow cannot continue.
92+
review-loop requires real planner/coder subagent support. Current Codex session cannot create subagents, so the workflow cannot continue.
5793
```

0 commit comments

Comments
 (0)