Paths: File paths (shared/, references/, ../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.
Agent Reviewer (Code)
Runs parallel external agent reviews on code implementation, critically verifies suggestions, returns filtered improvements.
Purpose & Scope
- Worker in ln-510 quality coordinator pipeline (invoked by ln-511 Step 7)
- Run codex-review + gemini-review as background tasks in parallel
- Process results as they arrive (first-finished agent processed immediately)
- Critically verify each suggestion; debate with agent if Claude disagrees
- Return filtered, deduplicated, verified suggestions with confidence scoring
- Health check + prompt execution in single invocation
When to Use
- Invoked by ln-511-code-quality-checker Step 7 (Agent Review)
- All implementation tasks in Story status = Done
- Code quality analysis (Steps 1-6) already completed by ln-511
Inputs (from parent skill)
storyId: Linear Story identifier (e.g., "PROJ-123")
Workflow
MANDATORY READ: Load shared/references/agent_delegation_pattern.md for Reference Passing Pattern, Review Persistence Pattern, Agent Timeout Policy, and Debate Protocol (Challenge Round 1 + Follow-Up Round).
Health check: python shared/agents/agent_runner.py --health-check
- Filter output by
skill_groups containing "512"
- If 0 agents available -> return
{verdict: "SKIPPED", reason: "no agents available"}
- Display:
"Agent Health: codex-review OK, gemini-review UNAVAILABLE" (or similar)
Get references: Call Linear MCP get_issue(storyId) -> extract URL + identifier. Call list_issues(filter: {parent: {id: storyId}, status: "Done"}) -> extract Done implementation Task URLs/identifiers (exclude label "tests").
- If project stores tasks locally (e.g.,
docs/tasks/) -> use local file paths instead of Linear URLs.
Ensure .agent-review/:
- If
.agent-review/ exists -> reuse as-is, do NOT recreate .gitignore
- If
.agent-review/ does NOT exist -> create it + .agent-review/.gitignore (content: * + !.gitignore)
- Create
.agent-review/{agent}/ subdirs only if they don't exist
- Do NOT add
.agent-review/ to project root .gitignore
Build prompt: Read template shared/agents/prompt_templates/code_review.md.
- Replace
{story_ref} with - Linear: {url} or - File: {path}
- Replace
{task_refs} with bullet list: - {identifier}: {url_or_path} per task
- Save to
.agent-review/{agent}/{identifier}_codereview_prompt.md (one copy per agent — identical content)
Run agents (background, process-as-arrive):
a) Launch BOTH agents as background Bash tasks (run_in_background=true):
python shared/agents/agent_runner.py --agent codex-review --prompt-file .agent-review/codex/{identifier}_codereview_prompt.md --output-file .agent-review/codex/{identifier}_codereview_result.md --cwd {cwd}
python shared/agents/agent_runner.py --agent gemini-review --prompt-file .agent-review/gemini/{identifier}_codereview_prompt.md --output-file .agent-review/gemini/{identifier}_codereview_result.md --cwd {cwd}
b) When first agent completes (background task notification):
- Read its result file from
.agent-review/{agent}/{identifier}_codereview_result.md
- Parse JSON between
<!-- AGENT_REVIEW_RESULT --> / <!-- END_AGENT_REVIEW_RESULT --> markers
- Parse
session_id from runner JSON output; write .agent-review/{agent}/{identifier}_session.json: {"agent": "...", "session_id": "...", "review_type": "codereview", "created_at": "..."}
- Proceed to Step 6 (Critical Verification) for this agent's suggestions
c) When second agent completes:
- Read its result file, parse suggestions
- Run Step 6 for second batch
- Merge verified suggestions from both agents
d) If an agent fails: log failure, continue with available results
Critical Verification + Debate (per Debate Protocol in shared/references/agent_delegation_pattern.md):
For EACH suggestion from agent results:
a) Claude Evaluation: Independently assess — is the issue real? Actionable? Conflicts with project patterns?
b) AGREE → accept as-is. DISAGREE/UNCERTAIN → initiate challenge.
c) Challenge + Follow-Up (with session resume): Follow Debate Protocol (Challenge Round 1 → Follow-Up Round if not resolved). Resume agent's review session for full context continuity:
- Read
session_id from .agent-review/{agent}/{identifier}_session.json
- Run with
--resume-session {session_id} — agent continues in same session, preserving file analysis and reasoning
- If
session_resumed: false in result → log warning, result still valid (stateless fallback)
{review_type} = "Code Implementation"
- Challenge files:
.agent-review/{agent}/{identifier}_codereview_challenge_{N}_prompt.md / _result.md
- Follow-up files:
.agent-review/{agent}/{identifier}_codereview_followup_{N}_prompt.md / _result.md
d) Persist: all challenge and follow-up prompts/results in .agent-review/{agent}/
Aggregate + Return: Collect ACCEPTED suggestions only (after verification + debate).
Deduplicate by (area, issue) — keep higher confidence.
Filter: confidence >= 90 AND impact_percent > 2.
Return JSON with suggestions + agent_stats + debate_log to parent skill. NO cleanup/deletion.
Output Format
verdict: CODE_ACCEPTABLE | SUGGESTIONS | SKIPPED
suggestions:
- area: "security | performance | architecture | correctness | best_practices"
issue: "What is wrong"
suggestion: "Specific fix"
confidence: 95
impact_percent: 15
source: "codex-review"
resolution: "accepted | accepted_after_debate | accepted_after_followup | rejected"
agent_stats:
- name: "codex-review"
duration_s: 12.4
suggestion_count: 3
accepted_count: 2
challenged_count: 1
followup_count: 1
status: "success | failed | timeout"
debate_log:
- suggestion_summary: "N+1 query in UserRepository.GetAll()"
agent: "gemini-review"
rounds:
- round: 1
claude_position: "Query uses Include() which resolves N+1"
agent_decision: "WITHDRAW"
resolution: "rejected"
final_resolution: "rejected"
Fallback Rules
| Condition |
Action |
| Both agents succeed |
Aggregate verified suggestions from both |
| One agent fails |
Use successful agent's verified suggestions, log failure |
| Both agents fail |
Return {verdict: "SKIPPED", reason: "agents failed"} |
| Parent skill (ln-511) |
Falls back to Self-Review (native Claude) |
Verdict Escalation
- Findings with
area=security or area=correctness -> parent skill can escalate PASS -> CONCERNS
- This skill returns raw verified suggestions; escalation decision is made by ln-511
Critical Rules
- Read-only review — agents must NOT modify project files (enforced by prompt CRITICAL CONSTRAINTS)
- Same prompt to all agents (identical input for fair comparison)
- JSON output schema required from agents (via
--json / --output-format json)
- Log all attempts for user visibility (agent name, duration, suggestion count)
- Persist prompts, results, and challenge artifacts in
.agent-review/{agent}/ — do NOT delete
- Ensure
.agent-review/.gitignore exists before creating files (only create if .agent-review/ is new)
- MANDATORY INVOCATION: Parent skills MUST invoke this skill. Returns SKIPPED gracefully if agents unavailable. Parent must NOT pre-check and skip.
- NO TIMEOUT KILL — WAIT FOR RESPONSE: Do NOT kill agent background tasks. WAIT until agent completes and delivers its response — do NOT proceed without it, do NOT use TaskStop. Agents are instructed to respond within 10 minutes via prompt constraint, but the hard behavior is: wait for completion or crash. Only a hard crash (non-zero exit code, connection error) is treated as failure. TaskStop is FORBIDDEN for agent tasks.
- CRITICAL VERIFICATION: Do NOT trust agent suggestions blindly. Claude MUST independently verify each suggestion and debate if disagreeing. Accept only after verification.
Definition of Done
- Health check executed; available agents identified (or SKIPPED returned if none)
- Story + Done implementation Tasks fetched from Linear (or local files)
.agent-review/ directory ensured (reused if exists, created with .gitignore if new) with per-agent subdirs
- Prompt built from template with story/task references, saved per agent
- All available agents launched as background tasks; raw results saved to
.agent-review/{agent}/
- Each suggestion critically verified by Claude; challenges executed for disagreements
- Follow-up rounds executed for suggestions rejected after Round 1 (DEFEND+weak / MODIFY+disagree)
- Challenge and follow-up prompts/results persisted alongside review artifacts
- Suggestions aggregated, deduplicated by (area, issue), filtered (confidence >= 90, impact > 2%)
- Session files persisted in
.agent-review/{agent}/{identifier}_session.json for debate resume
- JSON result returned to parent skill with verdict, suggestions list, agent_stats, and debate_log
Reference Files
- Agent delegation pattern:
shared/references/agent_delegation_pattern.md
- Prompt template (review):
shared/agents/prompt_templates/code_review.md
- Prompt template (challenge):
shared/agents/prompt_templates/challenge_review.md
- Agent registry:
shared/agents/agent_registry.json
- Agent runner:
shared/agents/agent_runner.py
- Challenge schema:
shared/agents/schemas/challenge_review_schema.json
Version: 2.0.0
Last Updated: 2026-02-11
1---2name: ln-512-agent-reviewer3description: Worker that runs parallel external agent reviews (Codex + Gemini) on code changes. Background tasks, process-as-arrive, critical verification with debate. Returns filtered suggestions with confidence scoring.4---5
6> **Paths:** File paths (`shared/`, `references/`, `../ln-*`) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.
7
8# Agent Reviewer (Code)
9
10Runs parallel external agent reviews on code implementation, critically verifies suggestions, returns filtered improvements.
11
12## Purpose & Scope
13- Worker in ln-510 quality coordinator pipeline (invoked by ln-511 Step 7)
14- Run codex-review + gemini-review as background tasks in parallel
15- Process results as they arrive (first-finished agent processed immediately)
16- Critically verify each suggestion; debate with agent if Claude disagrees
17- Return filtered, deduplicated, verified suggestions with confidence scoring
18- Health check + prompt execution in single invocation
19
20## When to Use
21- **Invoked by ln-511-code-quality-checker** Step 7 (Agent Review)
22- All implementation tasks in Story status = Done
23- Code quality analysis (Steps 1-6) already completed by ln-511
24
25## Inputs (from parent skill)
26- `storyId`: Linear Story identifier (e.g., "PROJ-123")
27
28## Workflow
29
30**MANDATORY READ:** Load `shared/references/agent_delegation_pattern.md` for Reference Passing Pattern, Review Persistence Pattern, Agent Timeout Policy, and Debate Protocol (Challenge Round 1 + Follow-Up Round).
31
321) **Health check:** `python shared/agents/agent_runner.py --health-check`
33 - Filter output by `skill_groups` containing "512"
34 - If 0 agents available -> return `{verdict: "SKIPPED", reason: "no agents available"}`
35 - Display: `"Agent Health: codex-review OK, gemini-review UNAVAILABLE"` (or similar)
36
372) **Get references:** Call Linear MCP `get_issue(storyId)` -> extract URL + identifier. Call `list_issues(filter: {parent: {id: storyId}, status: "Done"})` -> extract Done implementation Task URLs/identifiers (exclude label "tests").
38 - If project stores tasks locally (e.g., `docs/tasks/`) -> use local file paths instead of Linear URLs.
39
403) **Ensure .agent-review/:**
41 - If `.agent-review/` exists -> reuse as-is, do NOT recreate `.gitignore`
42 - If `.agent-review/` does NOT exist -> create it + `.agent-review/.gitignore` (content: `*` + `!.gitignore`)
43 - Create `.agent-review/{agent}/` subdirs only if they don't exist
44 - Do NOT add `.agent-review/` to project root `.gitignore`
45
464) **Build prompt:** Read template `shared/agents/prompt_templates/code_review.md`.
47 - Replace `{story_ref}` with `- Linear: {url}` or `- File: {path}`
48 - Replace `{task_refs}` with bullet list: `- {identifier}: {url_or_path}` per task
49 - Save to `.agent-review/{agent}/{identifier}_codereview_prompt.md` (one copy per agent — identical content)
50
515) **Run agents (background, process-as-arrive):**
52
53 a) Launch BOTH agents as background Bash tasks (run_in_background=true):
54 - `python shared/agents/agent_runner.py --agent codex-review --prompt-file .agent-review/codex/{identifier}_codereview_prompt.md --output-file .agent-review/codex/{identifier}_codereview_result.md --cwd {cwd}`
55 - `python shared/agents/agent_runner.py --agent gemini-review --prompt-file .agent-review/gemini/{identifier}_codereview_prompt.md --output-file .agent-review/gemini/{identifier}_codereview_result.md --cwd {cwd}`
56
57 b) When first agent completes (background task notification):
58 - Read its result file from `.agent-review/{agent}/{identifier}_codereview_result.md`
59 - Parse JSON between `<!-- AGENT_REVIEW_RESULT -->` / `<!-- END_AGENT_REVIEW_RESULT -->` markers
60 - Parse `session_id` from runner JSON output; write `.agent-review/{agent}/{identifier}_session.json`: `{"agent": "...", "session_id": "...", "review_type": "codereview", "created_at": "..."}`
61 - Proceed to Step 6 (Critical Verification) for this agent's suggestions
62
63 c) When second agent completes:
64 - Read its result file, parse suggestions
65 - Run Step 6 for second batch
66 - Merge verified suggestions from both agents
67
68 d) If an agent fails: log failure, continue with available results
69
706) **Critical Verification + Debate** (per Debate Protocol in `shared/references/agent_delegation_pattern.md`):
71
72 For EACH suggestion from agent results:
73
74 a) **Claude Evaluation:** Independently assess — is the issue real? Actionable? Conflicts with project patterns?
75
76 b) **AGREE** → accept as-is. **DISAGREE/UNCERTAIN** → initiate challenge.
77
78 c) **Challenge + Follow-Up (with session resume):** Follow Debate Protocol (Challenge Round 1 → Follow-Up Round if not resolved). Resume agent's review session for full context continuity:
79 - Read `session_id` from `.agent-review/{agent}/{identifier}_session.json`
80 - Run with `--resume-session {session_id}` — agent continues in same session, preserving file analysis and reasoning
81 - If `session_resumed: false` in result → log warning, result still valid (stateless fallback)
82 - `{review_type}` = "Code Implementation"
83 - Challenge files: `.agent-review/{agent}/{identifier}_codereview_challenge_{N}_prompt.md` / `_result.md`
84 - Follow-up files: `.agent-review/{agent}/{identifier}_codereview_followup_{N}_prompt.md` / `_result.md`
85
86 d) **Persist:** all challenge and follow-up prompts/results in `.agent-review/{agent}/`
87
887) **Aggregate + Return:** Collect ACCEPTED suggestions only (after verification + debate).
89 Deduplicate by `(area, issue)` — keep higher confidence.
90 **Filter:** `confidence >= 90` AND `impact_percent > 2`.
91 **Return** JSON with suggestions + agent_stats + debate_log to parent skill. **NO cleanup/deletion.**
92
93## Output Format
94
95```yaml
96verdict: CODE_ACCEPTABLE | SUGGESTIONS | SKIPPED
97suggestions:
98 - area: "security | performance | architecture | correctness | best_practices"
99 issue: "What is wrong"
100 suggestion: "Specific fix"
101 confidence: 95
102 impact_percent: 15
103 source: "codex-review"
104 resolution: "accepted | accepted_after_debate | accepted_after_followup | rejected"
105agent_stats:
106 - name: "codex-review"
107 duration_s: 12.4
108 suggestion_count: 3
109 accepted_count: 2
110 challenged_count: 1
111 followup_count: 1
112 status: "success | failed | timeout"
113debate_log:
114 - suggestion_summary: "N+1 query in UserRepository.GetAll()"
115 agent: "gemini-review"
116 rounds:
117 - round: 1
118 claude_position: "Query uses Include() which resolves N+1"
119 agent_decision: "WITHDRAW"
120 resolution: "rejected"
121 final_resolution: "rejected"
122```
123
124## Fallback Rules
125
126| Condition | Action |
127|-----------|--------|
128| Both agents succeed | Aggregate verified suggestions from both |
129| One agent fails | Use successful agent's verified suggestions, log failure |
130| Both agents fail | Return `{verdict: "SKIPPED", reason: "agents failed"}` |
131| Parent skill (ln-511) | Falls back to Self-Review (native Claude) |
132
133## Verdict Escalation
134- Findings with `area=security` or `area=correctness` -> parent skill can escalate PASS -> CONCERNS
135- This skill returns raw verified suggestions; escalation decision is made by ln-511
136
137## Critical Rules
138- Read-only review — agents must NOT modify project files (enforced by prompt CRITICAL CONSTRAINTS)
139- Same prompt to all agents (identical input for fair comparison)
140- JSON output schema required from agents (via `--json` / `--output-format json`)
141- Log all attempts for user visibility (agent name, duration, suggestion count)
142- **Persist** prompts, results, and challenge artifacts in `.agent-review/{agent}/` — do NOT delete
143- Ensure `.agent-review/.gitignore` exists before creating files (only create if `.agent-review/` is new)
144- **MANDATORY INVOCATION:** Parent skills MUST invoke this skill. Returns SKIPPED gracefully if agents unavailable. Parent must NOT pre-check and skip.
145- **NO TIMEOUT KILL — WAIT FOR RESPONSE:** Do NOT kill agent background tasks. WAIT until agent completes and delivers its response — do NOT proceed without it, do NOT use TaskStop. Agents are instructed to respond within 10 minutes via prompt constraint, but the hard behavior is: wait for completion or crash. Only a hard crash (non-zero exit code, connection error) is treated as failure. TaskStop is FORBIDDEN for agent tasks.
146- **CRITICAL VERIFICATION:** Do NOT trust agent suggestions blindly. Claude MUST independently verify each suggestion and debate if disagreeing. Accept only after verification.
147
148## Definition of Done
149
150- Health check executed; available agents identified (or SKIPPED returned if none)
151- Story + Done implementation Tasks fetched from Linear (or local files)
152- `.agent-review/` directory ensured (reused if exists, created with `.gitignore` if new) with per-agent subdirs
153- Prompt built from template with story/task references, saved per agent
154- All available agents launched as background tasks; raw results saved to `.agent-review/{agent}/`
155- Each suggestion critically verified by Claude; challenges executed for disagreements
156- Follow-up rounds executed for suggestions rejected after Round 1 (DEFEND+weak / MODIFY+disagree)
157- Challenge and follow-up prompts/results persisted alongside review artifacts
158- Suggestions aggregated, deduplicated by (area, issue), filtered (confidence >= 90, impact > 2%)
159- Session files persisted in `.agent-review/{agent}/{identifier}_session.json` for debate resume
160- JSON result returned to parent skill with verdict, suggestions list, agent_stats, and debate_log
161
162## Reference Files
163- **Agent delegation pattern:** `shared/references/agent_delegation_pattern.md`
164- **Prompt template (review):** `shared/agents/prompt_templates/code_review.md`
165- **Prompt template (challenge):** `shared/agents/prompt_templates/challenge_review.md`
166- **Agent registry:** `shared/agents/agent_registry.json`
167- **Agent runner:** `shared/agents/agent_runner.py`
168- **Challenge schema:** `shared/agents/schemas/challenge_review_schema.json`
169
170---
171**Version:** 2.0.0
172**Last Updated:** 2026-02-11