Review a diff before it becomes a Pull Request (or an open PR) against the intent it was written for: the agreed plan posted by `gh-issue-planner`, the Issue's Done conditions, or the PR description. Checks that the change stays inside the agreed impact scope, covers every Done condition, keeps what the plan said must not be cut, and does not weaken tests or thresholds; then has the diff read once in a fresh context for bugs. Reports findings with `file:line`, classified Important / Nit / Pre...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Gh Pr Reviewer?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/northraystudio-gh-pr-reviewer)
---
name: gh-pr-reviewer
description: >
Review a diff before it becomes a Pull Request (or an open PR) against the intent it was
written for: the agreed plan posted by `gh-issue-planner`, the Issue's Done conditions,
or the PR description. Checks that the change stays inside the agreed impact scope,
covers every Done condition, keeps what the plan said must not be cut, and does not
weaken tests or thresholds; then has the diff read once in a fresh context for bugs.
Reports findings with `file:line`, classified Important / Nit / Pre-existing, in a
fixed header `gh-issue-resolver` and `gh-batch-runner` read.
Triggers on requests like "review this diff", "review the PR", "PRをレビューして",
"差分をレビューして", "プラン通りか確認して", "/maruda:gh-pr-reviewer", or when
`gh-issue-resolver` reviews its own change, or `gh-batch-runner` a whole epic branch,
before opening a PR.
Does NOT modify code, Issues or PRs — read-only. Produces no JSON.
---
# GitHub PR Reviewer
## Overview
A change written by an agent has usually been read by nobody when it reaches a Pull
Request. This skill is the read that happens first: it checks the diff against **what was
agreed**, and has the diff read once more by a reader that did not write it.
It owns one thing other reviewers cannot do — **plan conformance**. A general-purpose
reviewer does not know that an agreed plan exists, what its impact scope was, or what it
promised not to cut. Bug-hunting itself is delegated (Step 4); this skill does not
re-implement a review engine. See `docs/adr/0007`.
**Read-only.** Never edit code, never comment on or change an Issue or PR, never create
Issues. Fixing belongs to `gh-issue-resolver`; filing belongs to `report-to-issues`.
## Inputs
- **The change**: a base ref and the current branch, or a PR number.
- **The intent**: an Issue number, a PR number, or a statement from the user. Optional —
but without it plan conformance cannot run, and the output says so.
Issues and PRs share one number space, so a bare `#<n>` is exactly one of them:
`gh pr view <n>` succeeds only for a PR. A **PR** number means "review that PR" — the
diff and both ends come from the PR, the intent from the Issue it closes (or its own
description). An **Issue** number means "review the current branch against that Issue's
plan"; the base is the one the caller names, else the integration branch recorded in
`CLAUDE.md`, else the repository's default branch. Say in `BASELINE` which one was used.
## Workflow
### Step 1: Find the intent
Take the first of these that exists and name it in the output (`INTENT:`):
1. The most recent comment on the Issue containing `<!-- gh-issue-planner:agreed-plan -->`
— its 対応方針 / どこまで作るか / 影響範囲 / 実装方法 sections. Plans are written in
the user's language; find each section by meaning, not by the Japanese heading.
2. The Issue's Done conditions (完了条件) and Out of scope (触らない範囲), when the body
carries `<!-- gh-issue-drafter:scoped-issue -->` or states them plainly.
3. The PR description.
4. What the user said the change is for.
```bash
gh issue view <id> --json number,title,body,comments
gh pr view <n> --json number,title,body,state,baseRefName,headRefName,baseRefOid,headRefOid,closingIssuesReferences
```
An agreed plan and the Issue's Done conditions are used together when both exist: the
plan is how, the Done conditions are the contract.
**Several Issues at once** (a batch reviewed as one change): collect the most recent
agreed plan of every Issue named. The scope is the **union** of their 影響範囲 and of what
each keeps under 削らないもの; every Issue's Done conditions must hold; a file is out of
scope only if no member's plan covers it. One member's 触らない範囲 or 作らないもの does
not fail what another member's plan agreed to — an exclusion binds the Issue that wrote
it. Name all of them on `INTENT:`, and say in a
finding which Issue's plan or condition it is about.
A plan the user pastes or points to counts as an agreed plan even with no Issue behind it.
If none exists, do **not** invent an intent. Set `INTENT: none (plan conformance not checked)`, run only the
**Weakened checks** row of Step 3 (it needs no intent), and say in the report that plan
conformance was not checked.
### Step 2: Get the diff
```bash
git diff --stat <base-ref>...HEAD
git diff <base-ref>...HEAD
git diff --name-status <base-ref>...HEAD
# or, for a PR (open or already merged):
gh pr diff <n>
```
These are three-dot diffs: they compare `HEAD` with the commit the branch was cut from,
so record the baseline as `<base-ref>@<short sha of the merge base>`
(`git merge-base <base-ref> HEAD`).
**Only committed work is in that diff.** If `git status --porcelain` shows uncommitted
changes, review the working tree instead — `git diff $(git merge-base <base-ref> HEAD)` for
tracked files, plus every untracked file (`git ls-files --others --exclude-standard`),
read whole and treated as added — and say so in the report; do not silently review less
than what is there.
For a
PR, take both ends from the PR itself — `baseRefOid` and `headRefOid` — and use them
wherever this skill writes `<base-ref>` and `HEAD`: after a merge the base branch already
contains the change, so the branch name is no longer its baseline. If either commit is missing locally, fetch it
(`git fetch origin <oid>`) or fall back to `gh pr diff <n>` and say that line attribution
came from the PR diff. Line numbers in findings always refer to the **head** side of the
diff.
An empty diff ends the review, and it is **not a pass**: nothing was read. Emit
`RESULT: FAIL` with the single finding `R-01 | Important | <base-ref>...HEAD | empty diff —
nothing was reviewed`, and say what to check (the base ref, whether the work is
committed, whether the branch is the right one). A caller that expected changes must not
be able to mistake "reviewed nothing" for "found nothing".
### Step 3: Plan conformance — this skill's own check
Compare the diff with the intent. Each failed check below is an **Important** finding.
A check runs only against what the intent actually states. An agreed plan carries every
section below; a PR description or a one-line statement usually carries none of them. Do
not derive a 影響範囲, a Done condition or a list of safeguards from an intent that does
not state one — with a loose intent, check that the diff does what it says and nothing
unrelated, run the Weakened checks row, and leave the rest.
| Check | Fails when |
|---|---|
| **Scope** | A changed file is neither listed in the plan's 影響範囲 (files, modules, tests) nor an obvious consequence of a listed step (a test for a listed file, a lockfile for a listed manifest). Name the file. |
| **Out of scope** | The diff changes something the Issue's 触らない範囲 or the plan's 作らないもの excludes. |
| **Done** | A Done condition is not made true by the diff — or is made true, but a test the plan promised for it (its テスト entry) is missing or would not fail if the condition stopped being true. Name the condition. A condition the plan agreed to verify by hand, or by running something this skill does not run, is not a failure: list it under `Not checked`. |
| **Kept safeguards** | Something the plan lists under 削らないもの (a security boundary, data-loss protection, authorization, input validation, error handling, accessibility) is removed, bypassed or left unhandled. |
| **Weakened checks** | The diff makes a check pass by weakening it: an assertion deleted or loosened, a test skipped or removed, a threshold, lint rule, type or constraint relaxed, an error swallowed. A test that changed because the agreed behaviour changed is not a weakening — say which it is. |
| **Built more than agreed** | The diff builds something the plan's どこまで作るか stopped short of (a new abstraction, option or dependency the plan did not call for). |
Do not report a plan step that was implemented differently but still satisfies the Done
conditions and stays in scope — how is the implementer's call. The same goes for a
tightening made after the plan (a stricter condition added in response to a review) as
long as it stays inside the agreed files and breaks no Done condition.
A condition that cannot be judged from the diff — it points at behaviour recorded
elsewhere, or needs something run that this skill does not run — is not a finding. List
it in the `Not checked` line of the report (Step 6) instead of guessing either way.
**One row per location and cause.** When one change fails several checks (a deleted
assertion is both a weakened check and a cut safeguard), report it once and name every
check it fails in the Finding. A file outside the agreed scope gets one Scope row; say in
that row what the out-of-scope change does, and do not raise its content again as a
separate defect — the fix is the same (take it out of this change).
### Step 4: Bug hunt — read by a fresh context
The reader that wrote a change is the worst reader of it. Hand the diff to a reader with
no memory of writing it:
- **With subagents** (the default): start **one** fresh-context subagent. Give it the diff,
the intent from Step 1, the project's own rules (`CLAUDE.md`, `.claude/rules/`) by path
when they exist, and the classification in Step 5. Ask for correctness defects only:
logic errors, unhandled edge and error paths, broken contracts with callers, data loss,
races, security defects, and tests that no longer check what they claim to. Its scope
is the files the diff touches: defects on changed lines, and defects it notices on
untouched lines of those same files, each marked **changed** or **untouched** so Step 5
can attribute them. It does not go hunting through the rest of the codebase. Ask for
`file:line`, why it is wrong, and the direction of the fix. Do not hand it your own
conclusions.
- **Without subagents**: re-read the diff yourself from the top, file by file, against the
same list, and say in the report that the read was not independent.
One reader, one pass. Do not build voting, multiple reviewers or effort levels here; a
project that wants a deeper review runs its platform's own review on top
(e.g. Claude Code's `/code-review`).
Check each reported defect against the code before keeping it: open the cited line and
confirm the failure is real. Drop what you cannot confirm — an unverified finding costs
the author more than a missed nit. A finding you can confirm only as an ambiguity (the
text or code *can* be read in a way that fails, and nothing forces that reading) is kept
as a Nit, with the uncertainty stated in the row — when it is on code the change altered.
The same doubt about untouched code is dropped: Pre-existing is for defects that are
real, not for everything a reader could question.
### Step 5: Classify
| Class | Meaning | What the caller does |
|---|---|---|
| **Important** | A plan-conformance failure (Step 3), or a real defect on a line this diff added or changed | Fix before the PR |
| **Nit** | Style, naming, formatting, a preference; anything the project's formatter or linter owns; and a real but minor weakness a careful reviewer would mention without blocking the merge | Nothing required |
| **Pre-existing** | A real defect on a line this diff did **not** change | Not fixed here — handed to `report-to-issues` |
Attribution is by what the change altered: `git diff -U0 <base-ref>...HEAD` shows which
lines the change owns, and within a changed line only the part that actually differs is
the change's — a clause carried over verbatim on an edited line is still untouched code. A defect in untouched code that the change merely sits next to is Pre-existing,
however serious. A defect in untouched code that the change **newly reaches** (a new
caller passing a value the callee never handled) is Important — the change caused the
failure, and the finding is anchored on the changed line.
When unsure between Important and Nit, ask: would a careful reviewer block the merge on
it? If not, it is a Nit.
### Step 5.5: Flag what a human must read
Some changes are read by a person however clean the review is. The project's cycle rules
(`.claude/rules/maruda-cycle.md`, *Changes a human must read*) list them; use that list
when it exists, including categories the project added. Without it, use these:
authentication and authorization · money (billing, payment, pricing) · secrets and
cryptography · personal data · data migration and destructive operations · the checks
themselves (CI, hooks, harness and scanner configuration, thresholds) · dependencies
Judge by **what the change does, not by the file's name or path**: a permission check
changed in `utils/helpers.ts` is an authorization change; a typo fixed in
`auth/README.md` is not. For each category the diff falls into, emit one entry on the
`HUMAN-REVIEW` line with the file and a one-clause reason.
This is a flag, not a finding. It does not change `RESULT`, it is not counted in
`SUMMARY`, and a change may be flagged with zero findings.
### Step 6: Report
Emit this header first, exactly, so `gh-issue-resolver` and `gh-batch-runner` can read it:
```
<!-- gh-pr-reviewer:result -->
RESULT: PASS | FAIL
SUMMARY: important <n> / nit <n> / pre-existing <n>
INTENT: agreed plan on Issue #<id>[, #<id> …] | agreed plan (handed over by the user) | Done conditions on Issue #<id> | PR #<n> description | user statement | none (plan conformance not checked)
BASELINE: <base-ref>@<sha>
READ: independent | not independent
HUMAN-REVIEW: none | <category>: <file> — <reason>[; <category>: <file> — <reason>]
```
`RESULT` is `FAIL` when there is at least one Important finding, otherwise `PASS`.
`SUMMARY` counts rows of the table below.
Then the findings, Important first, in the user's language:
```
| ID | Class | Location | Finding | Direction |
|----|-------|----------|---------|-----------|
| R-01 | Important | internal/order/service.go:88 | Scope: file is outside the agreed 影響範囲 (db/migrations/ only) | Move the change behind the agreed step, or return to the planner |
| R-02 | Important | internal/order/service_test.go:41 | Weakened check: `assert.Equal(want, got)` replaced by `assert.NotNil(got)` | Restore the assertion and fix the writer |
| R-03 | Pre-existing | internal/order/repo.go:120 | `rows.Err()` is never checked after the loop | Hand to report-to-issues |
```
Every finding carries a location: a `file:line`, or — for a plan-conformance finding about
something missing (an uncovered Done condition) — the file where the change should have
been, or the plan itself (`plan: 完了条件 2`).
After the table, when Step 3 left something unjudged, add one line — and nothing else
that is not a finding:
```
Not checked: 完了条件 3 (regression scenarios are recorded in PR #57, not in this diff)
```
With no findings, say so in one line under the header — **問題なし (no findings)** — rather
than leaving the table empty. Never pad the report with praise or a summary of the diff.
## When called again on the same change
A second run after fixes reports the current state only. A finding that no longer
reproduces is gone — do not list it as resolved. A Nit the author left alone is still
true and stays listed, so the counts describe the diff being shipped; it still never
fails the review. If the same Important finding survives a fix attempt unchanged, say so on
its row (`unchanged since the previous run`); the caller uses that to stop retrying.
## Key Principles
- **Read-only.** No edits, no comments, no Issues
- **Plan conformance is the job; bug-hunting is delegated** to one fresh-context read
- **No intent, no conformance check** — say it was not checked; never guess an intent.
Weakened checks are still reported: that row needs no intent
- **Attribution by line**: only what the diff added, changed or newly reaches is Important
- **Verify before reporting.** A finding that was not confirmed against the code is dropped
- **Weakening a check is always Important**, whatever it made pass
- Nits never fail the review
- **`HUMAN-REVIEW` is judged by what the change does**, never by its path, and never
changes the result