phx-review · diff
git:20260721.df395b3 to git:20260724.1e78fba
77 added, 146 removed. Audit A to A.
---
name: phx-review
- description: Review code with parallel agents — tests, security, Ecto, LiveView, Oban.
- Use after implementation to catch bugs and anti-patterns before committing.
+ description: Review changed Elixir/Phoenix code read-only. Check requirements, cite
+ evidence, deduplicate findings, and return a severity-based verdict.
---
-
# Review Elixir/Phoenix Code
- Review code by spawning parallel specialist agents. Find and
- explain issues — do NOT create tasks or fix anything.
+ Perform an evidence-based, read-only review of changed code. Find and explain
+ issues; do not edit files, create tasks, or fix findings.
## Usage
- ```
- phx-review # Auto-detects task ID from branch/commits
- phx-review test # Review test files only
- phx-review security # Run security audit only
- phx-review oban # Review Oban workers only
- phx-review deploy # Validate deployment config
- phx-review iron-laws # Check Iron Law violations only
- phx-review ENA-8931 # Force Linear issue
- phx-review #42 # Force GitHub issue
- phx-review .claude/plans/auth/plan.md # Force plan / spec file
- phx-review --no-requirements # Skip requirements coverage check
- phx-review --codex # Add Codex CLI as cross-model reviewer
+ ```text
+ phx-review
+ phx-review test
+ phx-review security
+ phx-review .claude/plans/auth/plan.md
+ phx-review --no-requirements
```
- ## Arguments
+ Treat the text after the skill name as a focus area, issue identifier, or path to
+ a plan/specification.
- `$ARGUMENTS` = Focus area, task ID, or path to plan/spec file.
+ ## Iron Laws
- When no requirements argument is passed, the skill auto-detects a task ID
- from the current git branch name and recent commits (see
- `references/requirements-detection.md`).
+ 1. **Review is read-only** — inspect and report; never modify the worktree.
+ 2. **Scope to changed code** — distinguish new defects from pre-existing issues.
+ 3. **Every finding needs evidence** — cite a path and line, explain impact, and
+ describe the concrete failure mode.
+ 4. **Check requirements when available** — unmet requirements affect the verdict.
+ 5. **Deduplicate and prioritize** — one root cause is one finding, with the
+ highest justified severity.
+ 6. **Do not require custom agents, hooks, MCP, or unavailable task APIs** — use
+ optional runtime capabilities only when present.
## Workflow
- ### Step 1: Identify Changed Files and Prepare Directories
-
- **CRITICAL**: Create output dirs BEFORE spawning agents — agents cannot
- create directories and writes will fail.
-
- 1. Determine SLUG via Glob on `.claude/plans/*/` (default: `"review"`)
- 2. Run `mkdir -p ".claude/plans/${SLUG}/reviews" ".claude/plans/${SLUG}/summaries" .claude/reviews`
- 3. Run `git diff --name-only HEAD~5` and `git diff --name-only main`
- 4. Save the diff base for pre-existing detection in Step 3b
-
- ### Step 1b: Load Plan Context and Prior Reviews
-
- - Read `.claude/plans/${SLUG}/scratchpad.md` for planning decisions and rationale
- - Pass relevant decisions to agents as WHY-context (eliminates session archaeology)
- - Check `.claude/plans/${SLUG}/reviews/` for prior output; if present, include a
- consolidated summary as "PRIOR FINDINGS" with: "Focus on NEW issues. Mark
- still-present issues as PERSISTENT."
-
- ### Step 1c: Detect Requirements Source (skip on `--no-requirements`)
-
- Find a task/spec whose requirements should be cross-checked against the diff.
- Priority order (stop at first match): explicit arg → conversation context →
- branch regex → commit subjects → latest plan → none. Full table, regexes,
- and fetch mapping in `references/requirements-detection.md`.
-
- Fetch the detected source into `.claude/plans/${SLUG}/reviews/.requirements-input.md`
- (Linear via `mcp__linear__get_issue`, GitHub via `gh issue view`, file via Read).
- Record `REQ_SOURCE` label (e.g. `"Linear ENA-8931"`) for the verifier heading.
- On fetch failure, set `SOURCE_STATUS=FETCH_FAILED` and continue — verifier
- will emit `NOT AVAILABLE` rather than block the review.
-
- ### Step 2: Spawn Review Agents (MANDATORY)
-
- **NEVER** spawn the same agent role twice per review. One pass per role.
- **NEVER** analyze code yourself — use the Agent tool only. Zero agents = failure.
-
- 1. Create a Claude Code task per agent via `TaskCreate` and `TaskUpdate` to `in_progress`
- 2. For `phx-review` or `phx-review all`: select agents dynamically per the
- selection table in `references/agent-spawning.md`
- 3. For focused reviews (`test|security|oban|deploy|iron-laws`): spawn only the
- matching specialist from the focused mode table in the same reference
- 4. **If Step 1c succeeded** (REQ_SOURCE non-empty and `--no-requirements`
- not passed): add `elixir-phoenix:requirements-verifier` to the same
- parallel batch. Pass these prompt inputs: `REQUIREMENTS_TEXT` (content
- of `.requirements-input.md`), `REQUIREMENTS_SOURCE` (REQ_SOURCE label),
- `DIFF_FILES` (git diff --name-only output), `SOURCE_STATUS` (only if
- FETCH_FAILED), `output_file: .claude/plans/{slug}/reviews/requirements.md`
- 5. Spawn in ONE message with `mode: "bypassPermissions"` and `run_in_background: true`
- 6. **MANDATORY**: pass explicit `output_file` per-agent (mapping in the reference)
- 7. Include the CRITICAL prompt block: write by turn ~12, chat body ≤300 words
- 8. Scope every agent to the diff: pass `git diff --name-only` output with
- "Focus on NEW code. Pre-existing: one-line `{file}:{line} — {brief}`. Do
- NOT deep-analyze unchanged files."
- 9. **With `--codex`**: add `elixir-phoenix:codex-reviewer` to the same batch
- (prompt template in agent-spawning.md). Missing CLI degrades to SKIPPED.
-
- ### Step 3: Collect and Compress Findings
-
- Wait for ALL agents to complete. **Do NOT report status until every agent
- completes.** Mark each task `completed` via `TaskUpdate` as it finishes.
-
- **Missing file fallback** — after each agent finishes, verify its expected
- `output_file` exists. If missing (turn exhaustion, error):
-
- 1. Append to `.claude/plans/{slug}/scratchpad.md`:
- `[HH:MM] WARN: {agent} did not write {expected_path} — extracting from message`
- 2. Parse findings from the agent's return message as fallback
- 3. Mark the section in the final review with
- `⚠️ EXTRACTED FROM AGENT MESSAGE (see scratchpad)` — never silent
-
- **Verification-runner fallback** — if it times out, run directly:
- `mix compile --warnings-as-errors && mix format --check-formatted $(git diff --name-only HEAD~5 | grep '\.exs\?$' | tr '\n' ' ') && mix credo --strict && mix test`
+ ### 1. Establish Scope
- **Context supervision** — for 4+ agents, spawn `elixir-phoenix:context-supervisor`:
+ Determine the merge base or user-specified base, then inspect:
- ```
- Prompt: "Compress review agent output.
- input_dir: .claude/plans/{slug}/reviews
- output_dir: .claude/plans/{slug}/summaries
- output_file: review-consolidated.md
- priority_instructions: BLOCKERs and WARNINGs: KEEP ALL.
- SUGGESTIONs: COMPRESS similar ones into groups.
- Deconfliction: when iron-law-judge and elixir-reviewer
- flag same code, keep iron-law-judge finding."
+ ```bash
+ git status --short
+ git diff --name-only <base>...HEAD
+ git diff --stat <base>...HEAD
+ git diff <base>...HEAD -- <changed-files>
```
- Skip the supervisor for focused (1-agent) reviews — read output directly.
-
- ### Step 3b: Filter Findings (Anti-Noise)
+ Do not assume `HEAD~5` is the correct base. Include uncommitted changes when the
+ user asks to review the current worktree. Record the chosen scope in the result.
- Before writing the review, apply these overriding filters to each finding:
+ ### 2. Load Requirements
- 1. Would a senior Elixir dev dismiss this as noise?
- 2. Does the finding add complexity exceeding the problem's complexity?
- 3. Are any findings duplicates reworded by different agents?
- 4. Does the finding affect code actually changed in this diff?
- 5. Is the finding on unchanged code (not in diff)? → Mark PRE-EXISTING
- 6. Flagged by both a Claude agent AND `[codex]`? → mark HIGH CONFIDENCE
+ Unless `--no-requirements` is set, look for an explicit plan/spec path, current
+ conversation requirements, a branch or commit issue identifier, or the latest
+ relevant plan. Use available integrations or `gh issue view` when configured;
+ otherwise mark requirements `NOT AVAILABLE` and continue.
- Demote or remove findings that fail filters 1-4. Mark pre-existing per filter 5.
+ Read `references/requirements-detection.md` for detection order. Never let a
+ missing Linear, GitHub, hook, or MCP integration block code review.
- ### Step 4: Generate Review Summary
+ ### 3. Review by Concern
- Read consolidated/agent output. Write to `.claude/plans/{slug}/reviews/{feature}-review.md`
- with verdict: PASS | PASS WITH WARNINGS | REQUIRES CHANGES | BLOCKED.
+ Select only concerns relevant to the diff:
- **Requirements Coverage in verdict**: if the verifier ran, read its
- summary line and fold into the verdict:
+ - Elixir/Phoenix correctness and idioms;
+ - Ecto queries, changesets, transactions, migrations, and N+1 risks;
+ - LiveView lifecycle, reconnect, forms, streams, and assigns;
+ - authentication, authorization, secrets, and input handling;
+ - Oban idempotency, retries, uniqueness, and transaction boundaries;
+ - tests, regressions, and verification gaps;
+ - deployment/runtime configuration when those files changed.
- - Any `UNMET` → escalate to `REQUIRES CHANGES` (even if code-quality PASS)
- - Any `PARTIAL` (no UNMET) → downgrade PASS → `PASS WITH WARNINGS`
- - `NOT AVAILABLE` / all `MET` / `UNCLEAR` only → no verdict change
+ Native Amp subagents may run independent read-only concern tracks in parallel.
+ Use generic subagents with the complete diff scope and return findings to this
+ session; do not depend on separately installed named agents. If subagents are
+ unavailable or unnecessary, run every selected concern sequentially here. A
+ sequential review is fully valid.
- Insert the verifier's `## Requirements Coverage` block into the
- review document **before** the per-agent findings so it's the first
- thing the user sees.
+ ### 4. Verify Findings
- ### Step 5: Present Findings and Ask User
+ For each candidate:
- **STOP and present the review.** Do NOT create tasks or fix
- anything.
+ 1. Confirm it is in changed code or label it `PRE-EXISTING`.
+ 2. Trace the actual runtime or data-flow consequence.
+ 3. Check nearby tests and requirements.
+ 4. Remove style-only noise and speculative concerns.
+ 5. Merge duplicates under the clearest root cause.
- **On BLOCKED or REQUIRES CHANGES**: Show finding count by severity,
- then offer via `AskUserQuestion`: `phx-triage` (recommended),
- `phx-plan .claude/plans/{slug}/reviews/{feature}-review.md` (converts
- findings into a follow-up plan — pass the review file path, not a
- re-description), fix directly (`phx-codex-loop` when codex ran), or "I'll handle it myself".
+ Run targeted read-only verification when it materially changes confidence. Do
+ not alter files or suppress failures. If a check cannot run, report that clearly.
- **On PASS / PASS WITH WARNINGS**: Suggest `phx-compound`, `phx-learn-from-fix`.
+ ### 5. Report a Verdict
- **Convention extraction**: After presenting findings, offer: "Any findings
- to suppress or enforce as conventions?" See `references/conventions.md`.
+ Return one verdict:
- ## Iron Laws
+ - `PASS`
+ - `PASS WITH WARNINGS`
+ - `REQUIRES CHANGES`
+ - `BLOCKED`
- 1. **Review is READ-ONLY** — Find and explain, never fix
- 2. **NEVER auto-fix after review** — Always ask the user first
- 3. **Always offer both paths**: `phx-plan` and `phx-work`
- 4. **Research before claiming** — Agents MUST research before
- making claims about CI/CD or external services
+ List findings in descending severity as `BLOCKER`, `WARNING`, or `SUGGESTION`.
+ Each finding must include `path:line`, evidence, impact, and the smallest
+ appropriate correction. Add requirements coverage before findings; any `UNMET`
+ requirement requires `REQUIRES CHANGES`.
- ## Integration
+ If there are no findings, say so explicitly and list residual risks or checks not
+ run. Stop after presenting the review. Suggest `phx-triage`, `phx-plan`, or
+ `phx-compound` as optional next steps without invoking them automatically.
- `phx-plan` → `phx-work` → `phx-review` (YOU ARE HERE) → Blocked? `phx-triage` or `phx-plan` | Pass? `phx-compound`
+ ## References
- See: `references/review-template.md`, `references/example-review.md`, `references/blocker-handling.md`, `references/requirements-detection.md`
+ - `references/requirements-detection.md` — requirements source and coverage rules
+ - `references/agent-spawning.md` — Amp concern selection and optional parallelism