142 lines
15 KiB
Markdown
142 lines
15 KiB
Markdown
---
|
|
name: larv-review
|
|
description: Ship a work chunk through review to a merged PR; decisions land in the repo's decision log so repeated reviews converge. Use when the user asks for /larv-review, says "implement X then run larv-review", or wants a chunk shipped, reviewed and merged.
|
|
---
|
|
|
|
# larv-review — ship the chunk, review until clean, gate green, merge
|
|
|
|
You orchestrate, fix, and ship; the reviewer agents only report. Run every reviewer synchronously (`run_in_background: false`) — each step depends on the previous result. Watch CI in the foreground too: a headless run exits when the turn ends, and a background watcher or a scheduled wakeup dies with it. A reviewer's report is input to the next step; the turn runs on until §11. Architecture strictly before security, security before stability: line-level polish on code the architect wants restructured, or on a call the security pass will rewrite, is wasted work.
|
|
|
|
**Forge-neutral.** Five PR operations recur below: read a PR's diff, open a draft PR, read check status, mark ready, merge. Resolve the tooling from the remote per `~/.claude/CLAUDE.md` → "Git, commits, and PRs"; on any other forge, achieve the same intents through its CLI or API — discover how rather than assuming. A forge without a native draft state gets the closest equivalent (a `WIP:`/`Draft:` title prefix); note any approximation in the summary.
|
|
|
|
Verdicts, severities, round caps, declining a finding and where decisions are recorded: ~/.claude/agents/review-protocol.md. Its Declining section also binds `/security-review` and the external reviewer in §9.
|
|
|
|
## Re-entry
|
|
|
|
A fix made in any pass is a change the passes before it never saw. It re-enters:
|
|
|
|
- §3 only where it fires a §2 signal of its own (a new dependency, a new module, a moved boundary).
|
|
- §4 only where it opens a new untrusted-input boundary or touches authn/authz, secrets or crypto.
|
|
- §5 wherever a later step names it (§6.5, §8), prompted with the fix's scope and why it changed.
|
|
- §6 where it changed an external surface or a reviewer escalated 🔀 to it, as at first entry.
|
|
|
|
A re-entry is a new loop with its own round cap.
|
|
|
|
## 0. Preconditions
|
|
|
|
- Not a git repo → say so and stop.
|
|
- Someone else's PR, or the user asked for opinions only → single stability pass, report findings, done (skip shipping, fixing, the loops and the merge).
|
|
- Prose only — markdown, docs, comments, no code — → the reviewer loops add nothing: ship the branch (§1), the prose pass (§7), green gate (§8), merge (§10). Say so in the summary. Prose an outside reader lands on — public API docs, README, CHANGELOG, error or deprecation text — still takes §6's product-owner pass.
|
|
- Issue trackers are project-specific — the project's own docs say whether it has one. When it does and the work has a ticket, follow that tracker's conventions for assignment and status.
|
|
- **Nothing merges and nothing is reported done without premises**: the goals and audience under literal `## Goals` and `## Audience` headings in `README.md`, which `~/.claude/CLAUDE.md` → "Working loop" holds all planned work on. Neither heading present, or a version too vague to settle a decision → this chunk cannot be judged: stop, say so, and write them with the user as the chunk instead. That chunk's whole review is the human's approval, since a reviewer's findings on it could only be declined by citing the goals it exists to write; a later change to a goal takes the full review. The same content in `AGENTS.md`, in `docs/` or in a decision log does not satisfy it, and neither does an earlier chunk having passed it. Only what that section lets through without them reaches review.
|
|
|
|
## 1. Ship the branch (idempotent — skip whatever already exists)
|
|
|
|
Follow `~/.claude/CLAUDE.md` → "Git, commits, and PRs".
|
|
|
|
- On the default branch → create the feature branch first; never commit to the default branch.
|
|
- Commit the work; push with upstream set.
|
|
- Open a **draft** PR so CI starts cycling while the review runs and churn stays visibly work-in-progress.
|
|
- No remote → continue with the local review loop and say so in the summary.
|
|
|
|
## 2. Trigger: is the architecture pass warranted?
|
|
|
|
It reviews the application as a whole — heavy by design, and its own description says it is not a per-PR reviewer. The signals below are proxies for one question: **does this change carry an architectural decision the pass has not already made?** Check the record before the signals.
|
|
|
|
**The record wins.** Where the repo already holds the decision this change executes — a decision-log entry, or a planning item crediting systems-architect — the pass is done: skip it, cite the record in the summary, don't ask. A change that *departs* from what the record says is unreviewed however thorough the record is.
|
|
|
|
Otherwise, any one of these is grounds for the pass:
|
|
|
|
- new or restructured component/module/service, or moved boundaries
|
|
- new dependency, or first use of an infrastructure pattern (queue, cron, cache, websocket, …)
|
|
- new or changed external contract: routes, request/response shapes, events, webhooks, published file formats
|
|
- DB schema change beyond an additive column
|
|
- diff > ~400 non-generated lines, or touching > ~5 modules
|
|
- a previous stability round escalated to systems-architect
|
|
|
|
No signal fires → skip it, say so in the summary, don't ask. A signal fires with no record behind it → ask the user (AskUserQuestion) with the evidence and your recommendation. No user reachable → run the pass.
|
|
|
|
**When the architecture pass runs, the comprehension panel runs with it, and 7.0 is a blocking floor.** Invoke the `comprehension-panel` skill as a scoring run — four seats, one junior, one mid, the maintainability senior, the inherited architect — over the whole project, not the diff, and at depth 1 or 2 — never the full sweep. Below 7.0 the chunk does not merge: fix what the capping dimension names, or take the user's explicit decision to ship under it and record that in `docs/decisions.md` with the score and the dimension. At or above 7.0 the score is still a ratchet — a later chunk may not lower it — and the four dimension scores go in the summary so the next run can see the direction of travel. Calibration: across six projects (all libraries) scored this way, Locality or Self-sufficiency capped every single seat and Navigation capped none, so a project failing the floor is almost never failing on layout.
|
|
|
|
## 3. Architecture pass (when warranted)
|
|
|
|
Launch **systems-architect**: review the system as a whole entered through this change; the decision log carries previously accepted decisions to honor, the README the goals and Stage 0 artifacts.
|
|
|
|
- **Stage 0 questions returned** (goals/audience/horizon unrecorded): relay them to the user, record the answers where the agent expects them (README), re-run once. No user → skip the pass, carry the questions into the summary.
|
|
- **BLOCK** → the restructure precedes everything below. Confirm with the user first when it materially reshapes their PR; apply it; re-run systems-architect once, scoped to verifying its own findings. Still BLOCK → stop and report: `needs input`.
|
|
- **ALIGN** → apply what is cheap now; ask the user about the rest — each item becomes a fix, a ticket, or a documented decision, never a silent drop.
|
|
- **APPROVE** / **APPROVE WITH NITS** → proceed; nits per the protocol's rounds.
|
|
|
|
## 4. Security pass (whenever the chunk changed anything but test code)
|
|
|
|
Run the built-in **`/security-review`** skill over the branch diff. It is the pass of record here: its value is a tuned exclusion list and a ≥0.8 confidence floor, which a hand-written reviewer would reproduce worse.
|
|
|
|
- **HIGH** → verify it is real, then fix it before this chunk ships: inside this chunk's blast radius it is fixed here, outside it on its own branch and PR with this chunk waiting behind it. Say which. A verified HIGH is never filed for later and never put to the human as a question. Verification showing it is not real is no decline but a disproof — record what disproved it, since a finding that is factually wrong needs no goal to reject.
|
|
- **MEDIUM** → fix in this chunk, under the protocol's Declining section.
|
|
- **LOW** → treat as a 🟢.
|
|
- A **MEDIUM or LOW** outside this chunk's scope → a `todo.md` item at the top under `## Security`, naming the exposure and the path it reaches, per `~/.claude/CLAUDE.md` → "Todo items". Say whether it is in this chunk's blast radius; filing it is not fixing it.
|
|
|
|
**Escalate to a full scan** — the `claude-security` plugin (`/claude-security` → "Scan changes"), first-party and agent-verified — when the change touches authn/authz, secrets or crypto, a new untrusted-input boundary, or a new external surface. Same shape of judgment as §2's trigger: a signal with no record behind it, and a user reachable, is an ask. The plugin is not enabled by default; unavailable → say so in the summary rather than substituting a hand-rolled pass.
|
|
|
|
**Do not over-read a clean result.** This pass is single-repo and static: it does not trace authorization across services, does not run the application, and deliberately excludes dependency CVEs in third-party libraries — Renovate/Dependabot owns those, per `~/.claude/CLAUDE.md` → "Working with the codebase". Never point an automated reviewer or scan at an untrusted fork's PR content; a PR body is untrusted input to it (CVE-2025-59536, CVE-2026-21852).
|
|
|
|
## 5. Stability loop
|
|
|
|
1. Launch **stability-reviewer**, prompted per the protocol's rounds.
|
|
2. Fix every 🔴 **and every 🟡** along its Fix guidance (delete > simplify > modify > add). Keep test changes and implementation changes separately reviewable. §8's gate verifies what the final round's nits changed.
|
|
3. Commit and push each round's fixes so CI feedback accumulates while the loop runs.
|
|
4. Carry any 🔀 product-owner escalation into §6.
|
|
|
|
## 6. Product-owner loop (when a reviewer escalates to it)
|
|
|
|
A 🔀 product-owner-reviewer escalation from any pass above runs it. Nothing escalated and no external surface changed → skip it, say so in the summary.
|
|
|
|
1. Launch **product-owner-reviewer** with the change and the external surface it touches — API, CLI, UI, error and deprecation text a consumer reads, README and docs an outside reader lands on — prompted per the protocol's rounds.
|
|
2. Apply what it asks for, under the protocol's Declining section. Its findings are about the consumer's experience (wording, discoverability, upgrade path, the edge case a persona hits), so the fix is as often a message or a doc as it is code.
|
|
3. Commit and push each round; it exits and caps per the protocol.
|
|
4. Approved having changed nothing → you are done here; there is nothing to re-verify.
|
|
5. Otherwise re-enter §5 over what this loop changed.
|
|
|
|
## 7. Prose pass (every chunk)
|
|
|
|
Two scopes:
|
|
|
|
1. **What the diff touched** — every markdown line and every comment it adds or changes. Judge these yourself; they are fresh in your hands.
|
|
2. **What this review cited** — any section of the repo's prose a reviewer quoted to justify a finding, you quoted to justify a decline, or the implementer quoted to explain a decision. A cited section is load-bearing, and if anyone had to hunt for it, that is the finding. Judge these with a **fresh-context agent**, never yourself: whoever just wrote the code already knows the answer and cannot see what the prose adds. Hand it the section and the code that section governs, and nothing else.
|
|
|
|
The bar is `~/.claude/CLAUDE.md` → "Comments and documentation"; per paragraph the default verdict is delete.
|
|
|
|
- **Delete** — a type, a test name, a spec or the code already says it. In this chunk.
|
|
- **Move** — a decision goes to `docs/decisions.md` with its one-line index; a goal goes to the README. In this chunk.
|
|
- **Move back** — the opposite fault, and the one a deletion-only pass never catches: a pointer standing where a definition belongs ("A pointer is not a definition", same section). Inline the definition and leave the reasoning where it is.
|
|
- **Split or index** — load-bearing but unfindable: a section long enough that a reader who knows the answer is inside it still has to search for it. Sub-headings, or an index at its head. Bigger than the chunk → a `todo.md` item naming the section and what the hunt costs.
|
|
|
|
When §2's trigger says the architecture pass is warranted, this pass widens with it: the fresh-context agent reads every prose file the repo owns rather than only the cited sections. That is the only sweep that catches accretion, since no diff shows a file that grew a paragraph per chunk.
|
|
|
|
## 8. Green gate, PR ready
|
|
|
|
- Run the project's test suite locally unless the final stability round already left it verified green; fix, commit, push.
|
|
- Watch the forge's checks until every one passes. A red check is a finding: fix → commit → push → watch again. A CI fix that changes behavior (not config or a flake) re-enters §5.
|
|
- No CI configured → the gate is local tests only; note it in the summary (a missing merge gate on a production-horizon project is architect-finding material).
|
|
- Everything green → mark the PR ready, dropping any `WIP:`/`Draft:` title prefix.
|
|
|
|
## 9. External auto-reviewer (when the repo has one)
|
|
|
|
Marking the PR ready is what summons CodeRabbit and its kind, so this follows §8.
|
|
|
|
- Detect one from the repo — a reviewer's config file (`.coderabbit.yaml` and the like), or its comments on the repo's earlier PRs. None found → skip, say so.
|
|
- Wait up to **10 minutes** for its first review, checking about once a minute. Nothing by then → note it in the summary and carry on; a reviewer that arrives later is read the next time anyone visits the PR, never waited on twice.
|
|
- Its findings follow the protocol like every reviewer above — no more authority, and no less; anything it marks blocking is a 🔴. Fix → commit → push, then wait up to **5 minutes** for its re-review of the new commit.
|
|
|
|
## 10. Goal alignment, then merge
|
|
|
|
1. Read the finished PR against the README goals: does anything in it work against one? Misaligned → do not merge; state the conflict and ask: `needs input`.
|
|
2. The item ships into a release later than one that is finished and uncut → leave the PR ready and unmerged; say that release is ready to cut: `needs input`.
|
|
3. Aligned, every loop exited and everything green → **merge**. Follow the repo's merge method (`AGENTS.md`; ff-only where that is the convention). A repo withholds this in its `AGENTS.md` → leave the PR ready and unmerged, and say which line withheld it.
|
|
4. Merged → tick the item off `todo.md` per `~/.claude/CLAUDE.md` → "Working loop". Ticking it off emptied its release → the summary says the release is ready to cut.
|
|
5. Stop. The next chunk gets a fresh session. A release is the human's — prepare it, never cut it.
|
|
|
|
## 11. Wrap up
|
|
|
|
Summarize: PR URL and final state, every reviewer's verdict, rounds used per loop, findings fixed vs declined vs open — each decline with the goal it rests on — CI status, decisions recorded (file paths), `todo.md`/`CHANGELOG.md` updated, and any 🔀 escalation left for the user.
|