|
| 1 | +--- |
| 2 | +name: review-pr |
| 3 | +description: Run the Mouse2Joy multi-angle review locally on a PR or the current branch. Spawns 8 review subagents (security, correctness, regression, ux, stability, convention-compliance, performance, code-reuse) using the same reviewer prompts as the CI pipeline. Reports findings in the conversation instead of posting to GitHub. Use when the user wants to review a PR before opening it, double-check a branch, or get a second opinion on changes without waiting for CI. |
| 4 | +--- |
| 5 | + |
| 6 | +# review-pr |
| 7 | + |
| 8 | +This is the **interactive / local** counterpart to the CI workflow at |
| 9 | +[`.github/workflows/claude-review.yml`](../../../.github/workflows/claude-review.yml). |
| 10 | +Same 8 reviewer angles, same prompts, but it runs from a Claude Code session |
| 11 | +and reports findings as text in the conversation instead of posting a GitHub |
| 12 | +review. |
| 13 | + |
| 14 | +## When to use |
| 15 | + |
| 16 | +Trigger this skill when the user asks for things like: |
| 17 | + |
| 18 | +- "Review this PR" / "review PR #12" / "give me a review of branch X" |
| 19 | +- "Check my branch before I open the PR" |
| 20 | +- "What would the CI reviewer flag on this?" |
| 21 | +- "Run the multi-agent review locally" |
| 22 | + |
| 23 | +Do **not** trigger if the user just wants a quick code-quality scan of one |
| 24 | +file or a specific question about one change — those don't need 8 angles. |
| 25 | + |
| 26 | +## What it does |
| 27 | + |
| 28 | +1. Resolves the target: PR number (via `gh pr view <n>`), explicit branch |
| 29 | + name, or "the current branch" by default. |
| 30 | +2. Loads the 8 reviewer system prompts from |
| 31 | + [`.github/claude-review/reviewers/`](../../../.github/claude-review/reviewers/). |
| 32 | + These files are the **single source of truth** — they are also used by |
| 33 | + the CI workflow. |
| 34 | +3. Lists the changed files in the diff. |
| 35 | +4. Runs each reviewer as a `Task` subagent in turn (sequentially, not in |
| 36 | + parallel — the local skill optimizes for transparency in the conversation |
| 37 | + over throughput). |
| 38 | +5. Aggregates findings into a single response in the conversation, with one |
| 39 | + section per angle. |
| 40 | + |
| 41 | +## How to run it |
| 42 | + |
| 43 | +Follow these steps in order. The user is in this Claude Code session; you |
| 44 | +are the orchestrator. |
| 45 | + |
| 46 | +### Step 1: Resolve the target |
| 47 | + |
| 48 | +Look at the user's request: |
| 49 | + |
| 50 | +- If they named a PR number (e.g. "review PR #8"): use that. |
| 51 | +- If they named a branch: use `git diff <base>...<branch>` against |
| 52 | + `origin/main`. |
| 53 | +- Otherwise: default to the current branch vs `origin/main`. Run |
| 54 | + `git rev-parse --abbrev-ref HEAD` and check that it isn't `main`. If it |
| 55 | + is, ask the user which branch / PR they meant. |
| 56 | + |
| 57 | +### Step 2: Identify changed files |
| 58 | + |
| 59 | +Run one of: |
| 60 | + |
| 61 | +- For a PR: `gh pr view <n> --json files --jq '.files[].path'` |
| 62 | +- For a branch: `git diff --name-only origin/main...<branch>` |
| 63 | + |
| 64 | +Hold this list — you'll pass it to every reviewer. |
| 65 | + |
| 66 | +If the list is empty, say so and stop. |
| 67 | + |
| 68 | +If the list is *only* docs (`ai-docs/**`, `**/*.md`, `LICENSE`) or *only* |
| 69 | +dependency files (`Directory.Packages.props`, `global.json`, csproj package |
| 70 | +references), tell the user "this matches the CI gate's skip rules and |
| 71 | +wouldn't be reviewed automatically — running anyway since you asked |
| 72 | +explicitly" and continue. |
| 73 | + |
| 74 | +### Step 3: Load reviewer prompts |
| 75 | + |
| 76 | +Read all 8 files from `.github/claude-review/reviewers/`: |
| 77 | + |
| 78 | +- `security.md` |
| 79 | +- `correctness.md` |
| 80 | +- `regression.md` |
| 81 | +- `ux.md` |
| 82 | +- `stability.md` |
| 83 | +- `convention-compliance.md` |
| 84 | +- `performance.md` |
| 85 | +- `code-reuse.md` |
| 86 | + |
| 87 | +You'll inject each one as the `Task` subagent's instructions. |
| 88 | + |
| 89 | +### Step 4: Run reviewers sequentially |
| 90 | + |
| 91 | +For each of the 8 reviewer prompts, invoke the `Task` tool with: |
| 92 | + |
| 93 | +- `subagent_type: "general-purpose"` |
| 94 | +- `description`: short (e.g. "Security review of PR #8") |
| 95 | +- `prompt`: the full text of the reviewer prompt file, followed by: |
| 96 | + |
| 97 | + ``` |
| 98 | + --- |
| 99 | +
|
| 100 | + ## This review |
| 101 | +
|
| 102 | + Target: <PR #N | branch <name>> |
| 103 | + Base: origin/main |
| 104 | + Head: <head ref> |
| 105 | +
|
| 106 | + Changed files: |
| 107 | + <bulleted list of paths> |
| 108 | +
|
| 109 | + Use Read / Grep / Glob / Bash (for `git diff` and `gh pr diff`) to |
| 110 | + investigate. Don't dump everything — pull only what you actually need |
| 111 | + for your angle. Output the structured JSON your instructions require. |
| 112 | + ``` |
| 113 | + |
| 114 | +After each subagent returns, summarize its findings into the conversation |
| 115 | +under a short heading like `## Security (N findings)` so the user sees |
| 116 | +progress, then move on. Don't try to render the JSON literally — turn it |
| 117 | +into readable markdown: |
| 118 | + |
| 119 | +- Summary as a sentence. |
| 120 | +- Critical findings as bullets with `path:L<line>` references. |
| 121 | +- Suggestions / nits collapsed under a "more" or omitted if low value (the |
| 122 | + user is reading in real-time; respect their attention). |
| 123 | + |
| 124 | +### Step 5: Final wrap-up |
| 125 | + |
| 126 | +After all 8 finish, post one short consolidated summary: |
| 127 | + |
| 128 | +- "**Critical**: N findings" with a one-line description each. |
| 129 | +- "**Suggestions worth considering**: N" — list 3–5 of the most useful. |
| 130 | +- Token usage if you tracked it (optional). |
| 131 | + |
| 132 | +Offer to dive deeper into any specific finding the user wants to discuss. |
| 133 | + |
| 134 | +## Important constraints |
| 135 | + |
| 136 | +- **Do NOT post to GitHub.** This skill is local-only. The CI workflow |
| 137 | + handles GitHub reviews. If the user wants the same review posted as a |
| 138 | + GitHub review, point them at the CI pipeline (push the branch, open |
| 139 | + the PR, CI runs the review automatically). |
| 140 | +- **Sequential, not parallel.** The CI script fan-outs 8 agents in |
| 141 | + parallel; this skill runs them one at a time so the user sees progress |
| 142 | + and can interrupt. If they want speed, the CI workflow exists. |
| 143 | +- **Reviewer prompts are the contract.** Don't paraphrase or summarize |
| 144 | + them when injecting into a subagent — pass the file content verbatim. |
| 145 | + This is what keeps CI review and local review in sync. |
| 146 | +- **Conventions referenced by the prompts** (`CLAUDE.md`, the |
| 147 | + "Things that are easy to get wrong" section, `ai-docs/implementations/`) |
| 148 | + are read by the subagents themselves via tool calls. You don't need to |
| 149 | + pre-load them; the agent will reach for them when relevant. |
| 150 | + |
| 151 | +## What this skill does NOT do |
| 152 | + |
| 153 | +- Open PRs / push branches / merge anything. |
| 154 | +- Modify files (it's a review, not a fix). |
| 155 | +- Run the .NET build or tests (CI does that; this skill is post-CI in |
| 156 | + spirit, even if there's no formal gate). |
| 157 | +- Replace [`/review`](https://docs.claude.com/claude-code) — that's the |
| 158 | + generic Claude Code review command. This skill is the Mouse2Joy-specific |
| 159 | + 8-angle methodology. |
| 160 | + |
| 161 | +## Example invocations |
| 162 | + |
| 163 | +User: "Review my current branch." |
| 164 | + |
| 165 | +You: |
| 166 | +1. `git rev-parse --abbrev-ref HEAD` → `feature/widget-rotation`. |
| 167 | +2. `git diff --name-only origin/main...feature/widget-rotation` → 4 files. |
| 168 | +3. Read the 8 reviewer prompts. |
| 169 | +4. Run each via `Task` in turn, posting per-angle summaries as you go. |
| 170 | +5. Final consolidated summary. |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +User: "Run the multi-agent review on PR #12." |
| 175 | + |
| 176 | +You: |
| 177 | +1. `gh pr view 12 --json files,headRefName --jq ...` |
| 178 | +2. Same as above, but with PR-specific context. |
0 commit comments