|
1 | 1 | # Claude Code Integration |
2 | 2 |
|
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. |
5 | 6 |
|
6 | 7 | ## Role Discovery |
7 | 8 |
|
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: |
9 | 11 |
|
10 | 12 | ```text |
11 | 13 | .claude/agents/planner.md |
| 14 | +.claude/agents/plan-reviewer.md |
12 | 15 | .claude/agents/coder.md |
| 16 | +.claude/agents/code-reviewer.md |
13 | 17 | ``` |
14 | 18 |
|
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. |
64 | 22 |
|
65 | 23 | ## Starting Roles |
66 | 24 |
|
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. |
101 | 48 |
|
102 | 49 | ## Failure |
103 | 50 |
|
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. |
0 commit comments