Skip to content

Commit 37184f1

Browse files
committed
update review-loop skill
1 parent e533ff0 commit 37184f1

20 files changed

Lines changed: 915 additions & 695 deletions

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

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +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 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.
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.
1818

1919
## Required Setup
2020

@@ -33,19 +33,16 @@ Default `maxRounds` is `3`. If the user specifies a maximum loop count, pass it
3333

3434
- Do not implement code until the plan loop has ended and the user explicitly confirms the plan.
3535
- 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`.
36+
JSON object; the orchestrator persists and validates it through
37+
`scripts/review-manager.js --finalize`.
3838
- 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.
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.
4946
- Use `scripts/validate-review-json.js` for later read-only revalidation.
5047
- Use `scripts/snapshot-diff.js` after every code loop implementation round.
5148
- `coder-complete` reconstructs the current Git tree, path partitions, and
@@ -77,9 +74,8 @@ The four required roles are:
7774
- `code-reviewer`
7875

7976
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.
77+
Claude Code all four roles are native subagents, and reviewer roles must start
78+
with no inherited planner/coder conversation.
8379

8480
## User Confirmation Gates
8581

Lines changed: 36 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,53 @@
11
# Claude Code Integration
22

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.
3+
Claude Code support uses real native subagents for `planner`, `plan-reviewer`,
4+
`coder`, and `code-reviewer`. Do not run any role as single-agent roleplay and
5+
do not start standalone `claude -p` reviewer processes.
56

67
## Role Discovery
78

8-
Check project agents first:
9+
Prepare all four roles with `scripts/prepare-agent-roles.js` either as temporary
10+
task roles or project agents:
911

1012
```text
1113
.claude/agents/planner.md
14+
.claude/agents/plan-reviewer.md
1215
.claude/agents/coder.md
16+
.claude/agents/code-reviewer.md
1317
```
1418

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.
18-
19-
If either planner/coder role is missing, ask the user to choose:
20-
21-
- temporary roles under `.agent-workflows/review-loop/<task-id>/runtime/roles/`
22-
- persistent project agents under `.claude/agents/`
23-
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.
39-
40-
## Temporary Roles
41-
42-
Temporary planner/coder roles are copied from `templates/roles/` to:
43-
44-
```text
45-
.agent-workflows/review-loop/<task-id>/runtime/roles/
46-
```
47-
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.
52-
53-
## Persistent Roles
54-
55-
Persistent planner/coder roles are copied to:
56-
57-
```text
58-
.claude/agents/
59-
```
60-
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.
19+
Temporary roles are valid only when the host can register them for the current
20+
session. Project roles require explicit user confirmation and a `/agents`
21+
reload or session restart.
6422

6523
## Starting Roles
6624

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.
25+
Start planner and coder as new named native subagents when required by the
26+
state machine. Start reviewers through Claude Code's native Agent/Task tool as
27+
new tasks with no resumed session or inherited planner/coder conversation.
28+
Restrict reviewer tools to read-only inspection when the host supports tool
29+
allow/deny configuration.
30+
31+
For a reviewer round:
32+
33+
1. Run `review-manager.js --task-id <id> --kind plan|code --round N --prepare`.
34+
2. Pass the returned prompt unchanged to the matching reviewer role.
35+
3. Require the reviewer to run its context-isolation preflight before reading
36+
repository files and return exactly one JSON object with no repository writes.
37+
4. Save the response to a temporary file outside the repository.
38+
5. Run `review-manager.js ... --finalize --input <file> --agent-id <id>`.
39+
40+
Prepare binds input digests and the current Git tree. Finalize reconstructs the
41+
request and rejects input, snapshot, or worktree drift before writing the
42+
immutable reviewer-run and canonical review. The orchestrator normalizes
43+
`reviewerConfig` to the host-native contract with source
44+
`claude-native-subagent`; it does not trust reviewer self-reporting.
45+
Finalize also rejects output that lacks the exact passed
46+
`context-isolation-preflight` evidence. This self-check supplements, but does
47+
not replace, starting a new native task without a resumed session.
10148

10249
## Failure
10350

104-
If Claude Code cannot create real planner/coder subagents in the current
105-
session, stop the workflow and tell the user:
106-
107-
```text
108-
review-loop requires real planner/coder subagent support. Current Claude Code session cannot create subagents, so the workflow cannot continue.
109-
```
51+
If Claude Code cannot create fresh native subagents, stop the workflow and
52+
report that review-loop requires native planner, reviewer, and coder subagent
53+
support.
Lines changed: 36 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,53 @@
11
# Codex Integration
22

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.
3+
Codex support uses real native subagents for `planner`, `plan-reviewer`,
4+
`coder`, and `code-reviewer`. Do not run any role as single-agent roleplay and
5+
do not start a nested `codex exec` process.
66

77
## Role Discovery
88

9-
Check project custom agents first:
9+
Prepare these project agents with `scripts/prepare-agent-roles.js --mode project`:
1010

1111
```text
1212
.codex/agents/planner.toml
13+
.codex/agents/plan-reviewer.toml
1314
.codex/agents/coder.toml
15+
.codex/agents/code-reviewer.toml
1416
```
1517

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.
19-
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.
25-
26-
## Persistent Agent Format
27-
28-
Codex custom agents are TOML files. Each file must define:
29-
30-
```toml
31-
name = "planner"
32-
description = "Planner for review-loop workflows."
33-
developer_instructions = """
34-
Read the review-loop workspace inputs and produce or revise plan.md.
35-
Do not implement code.
36-
"""
37-
```
18+
In `auto` mode the preparation script verifies all four definitions. Ask before
19+
creating or refreshing project agent files.
3820

3921
## Starting Roles
4022

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`.
44-
45-
For each role, include:
46-
47-
- role name
48-
- task id
49-
- workspace path
50-
- input files
51-
- required output path
52-
- instruction to return a concise summary to the orchestrator
53-
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.
23+
Start planner and coder as named native subagents when required by the state
24+
machine. Start every reviewer with `spawn_agent` and `fork_turns: "none"` so it
25+
does not inherit planner, coder, or orchestrator conclusions.
26+
27+
For a reviewer round:
28+
29+
1. Run `review-manager.js --task-id <id> --kind plan|code --round N --prepare`.
30+
2. Pass the returned prompt unchanged to the matching reviewer role.
31+
3. Require the reviewer to run its context-isolation preflight before reading
32+
repository files and return exactly one JSON object with no repository writes.
33+
4. Save the response to a temporary file outside the repository.
34+
5. Run `review-manager.js ... --finalize --input <file> --agent-id <id>`.
35+
36+
Prepare binds the input digests and current Git tree. Finalize reconstructs the
37+
request and rejects any input, snapshot, or worktree drift before writing the
38+
immutable reviewer-run and canonical review.
39+
Finalize also rejects output that lacks the exact passed
40+
`context-isolation-preflight` evidence. This self-check supplements, but does
41+
not replace, `fork_turns: "none"`.
42+
43+
Codex native subagents do not currently expose a per-agent sandbox override.
44+
The reviewer role is therefore a no-write contract backed by Git-tree drift
45+
validation, not a separately enforced OS sandbox. `reviewerConfig` records
46+
`model = host-selected`, `reasoningEffort = host-selected`,
47+
`sandboxMode = read-only`, and `source = codex-native-subagent`; these describe
48+
the host-native review contract and do not claim a pinned CLI model.
8549

8650
## Failure
8751

88-
If Codex cannot create real planner/coder subagents in the current session,
89-
stop the workflow and tell the user:
90-
91-
```text
92-
review-loop requires real planner/coder subagent support. Current Codex session cannot create subagents, so the workflow cannot continue.
93-
```
52+
If Codex cannot create fresh native subagents, stop the workflow and report
53+
that review-loop requires native planner, reviewer, and coder subagent support.

0 commit comments

Comments
 (0)