review-pr · diff

v1.0.0 to git:20260907.d3189a9

228 added, 107 removed. Audit A to B.

What this update changes in the checks

No check changed: every fixed check gives the same answer before and after this update.

A tripped check is a label, not a verdict: read the matched text and the lines below. This week's updates that newly trip a check.

---
- name: PR Review Committee
- version: 1.0.0
- description: This skill should be used when the user asks to "review this PR", "review my pull request", "check the diff", "code review", "review changes", or mentions reviewing code before merge. Spawns parallel subagents for comprehensive Rails PR review.
+ description: Multi-agent PR review with four modes (review, re-review, self-review, address-feedback) - spawns parallel subagents, saves diff to /tmp for context efficiency, supports file exclusion patterns
+ argument-hint: "[review|re-review|self-review|address-feedback] <pr> [additional instructions]"
---
- # PR Review Committee
+ ## Input Format
- Multi-agent review system for Ruby on Rails pull requests. Spawns five parallel subagents, each focused on a specific review domain, then merges findings into a unified review.
+ ```
+ /rpi:review-pr [mode] [PR] [additional instructions]
+ ```
+ - **mode** (optional): `review` (default), `re-review`, `self-review`, or `address-feedback`
+ - **PR**: PR number or link (required)
+ - **additional instructions** (optional): file exclusions, focus areas, or any custom guidance
+
+ Examples:
+ ```
+ /rpi:review-pr #1234
+ /rpi:review-pr re-review #1234
+ /rpi:review-pr self-review #1234
+ /rpi:review-pr address-feedback #1234
+ /rpi:review-pr #1234 exclude config/locales and .yml files
+ /rpi:review-pr re-review #1234 skip rails guru because it is not a rails project
+ ```
+
## Process
- ### Step 1: Get the Diff
+ Your role is **orchestrator and judge**, not doer. You collect artifacts, delegate analysis to subagents, and apply judgment to their output. The subagents read the code and comments — you decide what to do about their findings.
- Obtain the PR diff using one of these methods:
+ Steps are sequential — later steps depend on earlier results. Complete each step and wait for its results before starting the next. Skipping ahead without subagent results means the judgment layer in "Step 6: Judge Findings" has nothing to work with. Only parallelize where explicitly marked (e.g., "spawn in parallel").
+ ### Step 1: Gather PR Metadata
+
```bash
- # If PR number is known
- gh pr diff <PR_NUMBER>
+ gh pr view <PR_NUMBER> --json number,title,body,url,headRefName,baseRefName
+ ```
- # If reviewing current branch against base
- git diff origin/master...HEAD
+ If re-review or address-feedback mode is activated, also save all existing review feedback to `/tmp/`:
- # If reviewing staged changes
- git diff --cached
+ **Do not read these files — pass them to subagents by path only.** The subagents will read and analyze the content.
+ ```bash
+ # Review verdicts and bodies (APPROVED, CHANGES_REQUESTED, COMMENTED)
+ gh api repos/<OWNER>/<REPO>/pulls/<PR_NUMBER>/reviews \
+ --jq '[.[] | {id, state, body, html_url, commit_id, submitted_at, author_association, user: .user.login}]' \
+ | tee /tmp/pr_<NUMBER>_reviews.json | jq length
+
+ # Inline review comments on specific diff lines
+ gh api repos/<OWNER>/<REPO>/pulls/<PR_NUMBER>/comments \
+ --jq '[.[] | {id, pull_request_review_id, body, path, line, start_line, side, diff_hunk, commit_id, created_at, author_association, in_reply_to_id, user: .user.login}]' \
+ | tee /tmp/pr_<NUMBER>_inline_comments.json | jq length
+
+ # Conversation-level comments
+ gh api repos/<OWNER>/<REPO>/issues/<PR_NUMBER>/comments \
+ --jq '[.[] | {id, body, html_url, created_at, updated_at, author_association, user: .user.login}]' \
+ | tee /tmp/pr_<NUMBER>_conversation.json | jq length
```
- ### Step 2: Spawn Review Subagents
+ If `toon` is available, pipe each extraction through it and save as `.txt` instead — token-efficient artifacts, and every subagent that reads them benefits. Note the sanity check changes with the format: toon output is not JSON, so end the pipeline with `| tee /tmp/pr_<NUMBER>_reviews.txt | wc -l` instead of `| jq length`.
- Spawn all five subagents **in parallel** using the Task tool with `subagent_type: Explore`. Each subagent receives the diff and its specific review focus.
+ ### Step 2: Fetch and Save Diff
- **Critical:** Send a single message with all five Task tool calls to ensure parallel execution.
+ Checkout the PR branch locally and generate the diff. Save it to `/tmp/`.
- #### Subagent 1: RailsGuru
+ ```bash
+ git fetch origin
+ git checkout <branch>
+ # Use merge-base for a clean diff (handles diverged base branch)
+ BASE=$(git merge-base origin/<baseRefName> HEAD)
+ git diff $BASE -- . > /tmp/pr_<NUMBER>_diff.txt
```
- Prompt: "Review this Rails PR diff for conventions and architecture.
- IMPORTANT: Activate the activerecord:activerecord skill for AR patterns reference.
+ If the user provided file exclusion or inclusion patterns in additional instructions, apply them using git's pathspec syntax:
- Focus areas:
- - MVC boundary violations (fat controllers, logic in views)
- - Rails idioms (proper use of scopes, callbacks, concerns)
- - REST conventions and route design
- - ActiveRecord patterns (associations, validations placement)
- - Service object patterns and naming
+ ```bash
+ # Exclude specific paths
+ git diff $BASE -- . ':(exclude)path/to/noisy/dir' ':(exclude)*.ext' > /tmp/pr_<NUMBER>_diff.txt
- Diff:
- <paste diff here>
+ # Include only specific directories
+ git diff $BASE -- path/to/dir1/ path/to/dir2/ > /tmp/pr_<NUMBER>_diff.txt
- Output: List findings tagged [major], [minor], or [nit] with file:line references."
+ # Combine inclusion with exclusion
+ git diff $BASE -- path/to/dir/ ':(exclude)path/to/dir/subdir' > /tmp/pr_<NUMBER>_diff.txt
```
- #### Subagent 2: SecurityHawk
+ Verify the diff is non-empty: `wc -l < /tmp/pr_<NUMBER>_diff.txt`
- ```
- Prompt: "Review this Rails PR diff for security vulnerabilities.
+ ### Step 3: Fetch Original Ticket
- IMPORTANT: Activate the activerecord:activerecord skill for SQL injection prevention patterns.
+ The PR references the original ticket (e.g., ENG-123, PROJ-456). Fetch full ticket details — requirements and acceptance criteria define what "correct" looks like for this change. You can't review a feature without knowing what was in the task description before it was implemented.
- Focus areas:
- - SQL injection (raw queries, interpolation in where clauses)
- - XSS vulnerabilities (unescaped output, html_safe misuse)
- - CSRF protection gaps
- - Mass assignment vulnerabilities (permit params)
- - Authentication/authorization bypasses
- - Secrets or credentials in code
- - Insecure direct object references
+ Save the ticket **verbatim** to `/tmp/pr_<NUMBER>_ticket.md` — full title, description, every Task, every Acceptance Criterion, plus the ticket comments. Do not summarize, annotate, or reorder it: a paraphrase is where your conclusions leak into the reviewers' inputs, and a reviewer fed conclusions ratifies them instead of auditing the code.
- Diff:
- <paste diff here>
+ Wait for ticket details before proceeding — "Step 4: Gather Historical Context" needs the ticket context to ask the right questions.
- Output: List findings tagged [major], [minor], or [nit] with file:line references."
- ```
+ ### Step 4: Gather Historical Context
- #### Subagent 3: PerfPro
+ Spawn the **thoughts-analyzer** subagent to find historical knowledge about affected features.
```
- Prompt: "Review this Rails PR diff for performance issues.
+ subagent_type: rpi:thoughts-analyzer
- IMPORTANT: Activate the activerecord:activerecord skill for N+1 and query optimization patterns.
- IMPORTANT: Activate the appsignal-perf skill for performance monitoring insights.
+ Prompt: "What do we know about <ticket reference and title from "Step 3: Fetch Original Ticket">? What decisions, constraints, and trade-offs should reviewers be aware of?"
+ ```
- Focus areas:
- - N+1 query patterns (missing includes/preload/eager_load)
- - Expensive queries in loops
- - Missing database indexes for new queries
- - Inefficient ActiveRecord usage (pluck vs select, find_each vs each)
- - Memory bloat (loading large datasets)
- - Missing caching opportunities
- - Background job considerations (should this be async?)
+ The harness saves the subagent's report to a task output file and shows the path when it completes — note that path. It is the historical-context artifact you pass to reviewers. If no path was surfaced (the report came back inline), save it verbatim to `/tmp/pr_<NUMBER>_context.md` yourself. Either way the artifact is a copy, never a rewrite: a re-summary is exactly where your conclusions leak in.
- Diff:
- <paste diff here>
+ **Wait for this subagent to complete, then proceed to "Step 5-a: Spawn Review Subagents".**
- Output: List findings tagged [major], [minor], or [nit] with file:line references."
- ```
+ ### Step 5-a: Spawn Review Subagents
- #### Subagent 4: TestCoach
+ If address-feedback mode is activated, skip to "Step 5-b: Spawn Codebase Research Subagents (address-feedback)" below.
+ Spawn the review subagents **in parallel** using the Task tool, each by its own `subagent_type` from the roster below. Their review instructions live in their agent definitions — you hand each one **paths and parameters only**:
+
+ - PR number
+ - Path to the diff file: `/tmp/pr_<NUMBER>_diff.txt`
+ - Path to the ticket artifact: `/tmp/pr_<NUMBER>_ticket.md`
+ - Path to the historical-context artifact: the thoughts-analyzer task output file from "Step 4: Gather Historical Context"
+ - Any additional instructions from the user's input (if any), passed through verbatim
+
+ **Why subagents review at all: they are fresh eyes.** Each reviewer arrives with zero knowledge of this PR beyond its own charter — that absence of bias is exactly what finds the gaps and blind spots you've already rationalized past. **Never add interpretation, summaries, or framing** — no "this looks consistent with…", no digest of what the metadata showed you. A reviewer fed your conclusions ratifies them instead of auditing the code; the bare prompt is what keeps the eyes fresh.
+
+ If re-review mode is activated, each subagent also receives the paths to `/tmp/pr_<NUMBER>_reviews.json`, `/tmp/pr_<NUMBER>_inline_comments.json`, and `/tmp/pr_<NUMBER>_conversation.json` (or `.txt` when `| toon` was applied at extraction — prefer token-efficient artifact formats) — receiving prior-feedback paths is what tells a reviewer it is a re-review; no mode flag is needed.
+
+ **Spawn every reviewer whose domain exists in this repo — coverage is the point.** The full roster is the default; an omission needs a reason: the test-framework twin that doesn't apply (`rpi:review-tests-rspec` for RSpec repos, `rpi:review-tests-minitest` for minitest repos — pick the one matching the stack, never both), a domain genuinely absent from the repo (no Rails reviewer in a non-Rails project), or an explicit user skip. Never trim the roster for brevity or token thrift — an unreviewed domain is a silent LGTM.
+
+ **No expert for a domain in the diff? Spawn the generalist.** When the stack includes a domain no expert reviewer covers (say, a Python service in the diff), spawn `rpi:review-generic` with the domain and a focus list — scope only: what to look for, never what you expect it to find. Better a generic reviewer than an unreviewed domain.
+
+ **Critical:** Send a single message with all the Task tool calls to ensure parallel execution.
+
+ #### The reviewer roster
+
+ | `subagent_type` | Audits |
+ |---|---|
+ | `rpi:review-rails` | Rails conventions and architecture |
+ | `rpi:review-ticket-delivery` | whether the PR delivers the ticket (always runs; carries the security sweep) |
+ | `rpi:review-performance` | performance and cross-tenant leakage |
+ | `rpi:review-tests-rspec` | test quality and coverage (RSpec repos) |
+ | `rpi:review-tests-minitest` | test quality and coverage (minitest repos) |
+ | `rpi:review-docs` | documentation quality and clarity |
+ | `rpi:review-generic` | any domain in the diff with no expert reviewer (focus list from you) |
+
+ Example spawn — same shape for all:
+
```
- Prompt: "Review this Rails PR diff for test quality and coverage.
+ subagent_type: rpi:review-rails
- IMPORTANT: Activate the rspec:rspec skill for RSpec best practices reference.
+ Prompt: "PR #<number>.
+ Diff: /tmp/pr_<number>_diff.txt
+ Ticket: /tmp/pr_<number>_ticket.md
+ Historical context: <thoughts-analyzer task output file path>
+ <re-review only — Reviews: /tmp/pr_<number>_reviews.json, Inline comments: /tmp/pr_<number>_inline_comments.json, Conversation: /tmp/pr_<number>_conversation.json>
+ <additional instructions from user input, verbatim>"
+ ```
- Focus areas:
- - Missing test coverage for new code paths
- - Flaky test patterns (time-dependent, order-dependent)
- - Factory usage (proper traits, avoiding create when build suffices)
- - Test isolation issues (shared state, missing cleanup)
- - Assertion quality (testing behavior vs implementation)
- - Missing edge case coverage
+ ### Step 5-b: Spawn Codebase Research Subagents (address-feedback)
- Diff:
- <paste diff here>
+ Unless address-feedback mode is activated, skip to "Step 6: Judge Findings" below.
- Output: List findings tagged [major], [minor], or [nit] with file:line references."
+ Spawn **rpi:codebase-analyzer** and **rpi:codebase-pattern-finder** in parallel. Each receives:
+ - Paths to comment files and diff file in `/tmp/`
+ - Historical context (from "Step 4: Gather Historical Context")
+ - Any additional instructions from the user's input
+
+ ### Step 6: Judge Findings
+
+ After all subagents complete, compile findings into a unified review.
+
+ Read `/tmp/pr_<NUMBER>_diff.txt` now, plus the prior-feedback artifacts from "Step 1: Gather PR Metadata" if the mode saved any. An informed decision requires you to know the full context of the PR.
+
+ **Critical: Subagents are pattern matchers. You are the judgment layer.** Subagents are designed to be paranoid and thorough — they flag everything that matches their heuristics. Your job is to filter their output, not rubber-stamp it. A [major] from a subagent can become a [nit] or be dropped entirely after applying judgment.
+
+ For each concern, evaluate:
+ - **Real-world probability** — Can this actually happen in practice, or is it purely theoretical? A race condition that requires two users to open a personal link within the same millisecond is not a real issue.
+ - **Cost-benefit** — Does the fix add more complexity than the problem warrants? If the "fix" makes the code harder to read without solving a problem a human would encounter, drop it.
+ - **Scope** — Review fixes should improve code you're touching, not introduce new artifacts. Clean up, don't build out.
+ - **Design intent** — Was this a deliberate choice? A concern that flags a conscious trade-off documented in historical context is a decline, not a fix.
+ - **Precedent** — "Existing code does the same" declines nothing on its own: a precedent does not legitimize an antipattern, it locates another instance of it. Legitimacy comes from documented standards, not recurrence.
+
+ Then classify:
+ - **Accept & fix** — concern valid, apply the suggested fix or a better one
+ - **Accept, different approach** — concern valid, but context points to a different solution
+ - **Decline** — not valid in context, or a deliberate design choice
+
+ Then compile:
+
+ 1. **Group by severity** — [major] first, then [minor], then [nit]
+ 2. **Remove duplicates** — Multiple sources may flag the same issue
+ 3. **Add actionable suggestions** — Include code snippets where helpful
+ 4. **Preserve file:line references** — Format as `app/models/user.rb:42`
+
+ Determine verdict:
+ - **REQUEST_CHANGES** — If any [major] or multiple [minor] concerns are accepted
+ - **APPROVE** — If no significant concerns survive the judgment filter
+
+ In re-review, REQUEST_CHANGES when a previously requested change is unaddressed or a new [major] is accepted. A couple of new [minor]/[nit] findings don't restart the cycle — carry them in the review body as non-blocking suggestions. (A pile-up of accepted minors is judgment territory, as always.)
+
+ ### Step 7: Present Review (review / re-review)
+
+ If self-review or address-feedback mode is activated, skip to "Step 9: Apply Fixes".
+
+ Present the merged review to the user, including:
+ - PR reference and ticket (if found)
+ - Determined verdict
+ - All findings grouped by severity
+
+ ### Step 8: Confirm and Post (review / re-review)
+
+ Use the AskUserQuestion tool to confirm: "Shall I post this review to the PR? [Yes/Edit/Cancel]"
+ - **Yes** — post the review
+ - **Edit** — let the user modify the review, then ask again
+ - **Cancel** — discard
+
+ If the verdict is APPROVE and nothing in the gathered artifacts blocks delivery (no "don't merge until…" notes, dependent PRs, or coordinated-deploy requirements in the ticket, reviews, or findings), include a fourth option: **Approve & merge**.
+ - **Approve & merge** — post the approving review, then monitor `gh pr checks <PR_NUMBER> --watch`; when green, merge using the repository's convention (e.g. squash). If CI fails, stop and report — never merge red.
+
+ Once confirmed, post the review:
+
+ ```bash
+ gh pr review <PR_NUMBER> --approve --body "<review body>"
+ # or
+ gh pr review <PR_NUMBER> --request-changes --body "<review body>"
```
- #### Subagent 5: DocScribe
+ ### Step 9: Apply Fixes (self-review / address-feedback)
+ Your role changes from orchestrator to doer. You now have the judgment results — act on them.
+
+ 1. **Fix concerns** — Address [major] and [minor] issues directly in code. Apply [nit]s at own discretion.
+ 2. **Commit and push** — Commit the fixes with a descriptive message and push to the PR branch.
+ 3. **Monitor CI** — Wait for CI to pass. The PR cannot be finalized until CI is green.
+
+ ```bash
+ gh pr checks <PR_NUMBER> --watch
```
- Prompt: "Review this Rails PR diff for documentation and clarity.
- Focus areas:
- - Method and class naming clarity
- - Missing YARD documentation on public interfaces
- - Complex logic lacking explanatory comments
- - Changelog updates for notable changes
- - Misleading or outdated comments
- - Magic numbers or strings needing constants
+ Fixes are pushed and CI is green. Now finalize the PR — proceed to the section matching your mode below.
- Diff:
- <paste diff here>
+ #### Self-Review Finalization
- Output: List findings tagged [major], [minor], or [nit] with file:line references."
+ Assign the user and request review from anyone mentioned in additional instructions. Then mark the PR as ready for human review.
+
+ ```bash
+ gh pr edit <PR_NUMBER> --add-assignee <user> --add-reviewer <reviewer>
+ gh pr ready <PR_NUMBER>
```
- ### Step 3: Merge Results
+ Done when the PR is marked ready and appears in the reviewer's queue.
- After all subagents complete, compile findings into a unified review:
+ #### Address-Feedback Finalization
- 1. **Group by severity** - [major] first, then [minor], then [nit]
- 2. **Remove duplicates** - Multiple agents may flag the same issue
- 3. **Add actionable suggestions** - Include code snippets where helpful
- 4. **Preserve file:line references** - Format as `app/models/user.rb:42`
+ Reply to each reviewer comment on GitHub with the resolution:
+ - Accept & fix: "Fixed in `<commit sha>`."
+ - Accept, different approach: "Agreed with the concern. Took a different approach: [explanation]. Fixed in `<commit sha>`."
+ - Decline: "This was intentional — [rationale]."
- ### Step 4: Deliver Verdict
+ ```bash
+ # Reply to an inline comment
+ gh api repos/<OWNER>/<REPO>/pulls/<PR_NUMBER>/comments/<COMMENT_ID>/replies -f body="<reply>"
- End the review with one of:
- - **"Changes requested"** - If any [major] or multiple [minor] issues exist
- - **"Approved with suggestions"** - If only [minor] issues or [nit]s remain
- - **"Approved"** - If no significant issues found
+ # Reply to a conversation-level comment
+ gh api repos/<OWNER>/<REPO>/issues/<PR_NUMBER>/comments -f body="<reply>"
+ ```
- ## Output Format
+ Then request re-review from the original reviewers:
+ ```bash
+ gh pr edit <PR_NUMBER> --add-reviewer <original_reviewer>
+ ```
+
+ Done when all comments are answered and re-review is requested.
+
+ ## Posted Review Format
+
```markdown
- # PR Review: [Branch Name or PR Title]
+ ## PR Review Summary
- ## Major Issues
- - [major] `app/models/user.rb:42` - SQL injection via string interpolation in where clause
+ **Verdict: REQUEST_CHANGES**
+
+ ### Major Issues
+ - `app/models/user.rb:42` - SQL injection via string interpolation in where clause
```ruby
# Instead of:
User.where("name = '#{params[:name]}'")
# Use:
User.where(name: params[:name])
```
- ## Minor Issues
- - [minor] `app/controllers/users_controller.rb:15` - Business logic belongs in model or service
+ ### Minor Issues
+ - `app/controllers/users_controller.rb:15` - Business logic belongs in model or service
- ## Suggestions
- - [nit] `app/services/user_service.rb:8` - Consider more descriptive method name
+ ### Suggestions
+ - `app/services/user_service.rb:8` - Consider more descriptive method name
---
- **Verdict: Changes requested**
+ *Review generated with multi-agent analysis*
```
## Guidelines
- - Reference code lines as `file_path:line_number`
- Focus only on changed lines, not surrounding unchanged code
- Provide concrete fix suggestions for [major] issues
- - Keep findings concise and actionable
+ - The main agent must not read the diff file before Step 6
+ - Pass additional instructions from user input through to all subagents