Pull Request Code Review
Structured GitHub PR review with severity-ranked, citation-bound findings and a clear verdict.
Goal
Structured code review of a GitHub Pull Request — correctness, security, performance, maintainability. Findings ranked by severity, each tied to a verbatim diff citation, plus a verdict (Approve / Request Changes / Comment).
When to Use
- The user names a PR by number, URL, or branch and asks for a review.
- The user asks for "feedback", "thoughts", or "concerns" on a pull request.
- The user explicitly invokes
/github-pr-review or /valarmindskills:github-pr-review.
Do not use when
- The user asks about code-review methodology, not a specific GitHub PR → use
@code-review.
- The user wants to author a commit or PR description, not review one → use
@github-commit or @github-release-note.
- The PR contains no code diff (docs only, lockfile bumps, config-only) and the user wants security/perf analysis — refuse with
out of scope: no code diff to analyze and hand off.
Inputs you must collect before starting
| Input |
Required |
How to obtain |
| PR identifier |
Yes |
Number, URL, or branch name; ask if missing |
| Repository |
Yes |
Infer from current directory; ask if ambiguous |
| Review depth |
No |
quick (high-level) or deep (line-by-line) — default: deep |
Procedure
Step 1 — Fetch PR metadata
gh pr view <number> --json title,body,author,baseRefName,headRefName,files,additions,deletions,commits,labels,state,isDraft
Record: title, author, base/head branch, files changed, lines added/removed, commits, state (open/closed/merged), draft flag.
If state != "OPEN" or isDraft == true, warn the user and ask whether to continue. Do not refuse — historical reviews are valid use cases.
Step 2 — Get the full diff
gh pr diff <number>
If the PR has more than 1000 changed lines, inform the user and ask whether to (a) continue full review, (b) prioritize a file subset, or (c) abort. Do not silently truncate.
Step 3 — Read description and linked issues
- Read the PR description for context and intent.
- Look up linked issues via
gh issue view <number> for Closes #N, Fixes #N, Refs #N.
- Identify acceptance criteria, if any.
Step 4 — Analyze the changes
Analyze the diff across four dimensions. Only review changed code — not surrounding unchanged code.
Logic & Correctness
- Business requirements met?
- Edge cases (null, empty, boundaries, concurrency)?
- Error flows correct?
- Loop / recursion termination?
- Type consistency?
Security
- Inputs validated and sanitized?
- Injection risk (SQL, XSS, command, SSRF, path traversal)?
- AuthN / AuthZ checks?
- Sensitive data exposure (logs, responses, env)?
- OWASP Top 10 alignment?
Performance
- N+1 queries or inefficient DB access?
- Unbounded iteration?
- Allocation in hot loops?
- Algorithmic complexity vs. expected volume?
- Blocking calls where async fits?
Maintainability
- Naming clarity (variables, functions, classes)?
- Single responsibility, function size?
- Module coupling?
- Test coverage for the changes?
- Style consistency with the rest of the codebase?
Step 5 — Categorize each finding
Each finding must include Severity, Confidence, and a verbatim citation:
| Severity |
Criteria |
| Critical |
Crash, data loss, exploitable vulnerability, breaks existing functionality |
| Major |
Bug in a likely scenario, significant performance issue, important standard violation |
| Minor |
Recommended improvement, readability impact, incomplete error handling |
| Nitpick |
Stylistic or naming suggestion — does not block approval |
| Confidence |
Meaning |
| High |
Mechanical evidence in the diff; reasoning is deterministic |
| Medium |
Pattern matches but intent may justify it — flag for author |
| Low |
A second opinion would change the verdict — escalate or downgrade |
Citation requirement. Cite path:line AND quote the exact code (3–8 lines from the diff). A finding without both is rejected. Never paraphrase the code; never invent paths, line numbers, or function names.
Step 6 — Write the executive summary
2–4 sentences with:
- What the PR does (paraphrased from the diff, not the description).
- Quality assessment.
- Key concerns, if any.
- Verdict: Approve, Request Changes, or Comment.
The verdict must match the highest finding severity:
- Any
Critical or Major → Request Changes.
- Only
Minor / Nitpick → Comment or Approve (author discretion).
- Zero findings after Step 8 verification →
Approve with LGTM.
Step 7 — Present the review
Follow the template in EXAMPLE.md. For zero-findings PRs, follow the LGTM template in the same file.
If the user explicitly approves, publish via:
gh pr review <number> --approve --body "<message>"
gh pr review <number> --request-changes --body "<message>"
gh pr review <number> --comment --body "<message>"
Never publish without explicit user approval — one approval is scoped to one publish action.
Step 8 — Verify before presenting
Before returning the review, check:
- Every cited
path:line appears in the diff from Step 2.
- Every code quote is verbatim from the diff (no paraphrase, no fabricated lines).
- Every finding has a
Severity and a Confidence field.
- The verdict in the executive summary matches the highest finding severity per Step 6.
- If zero findings, the output uses the
LGTM template — not a synthesized Minor.
- No finding was promoted from Minor to Major to fill the report.
If any check fails, repair before returning.
Refusal hooks
- Out of scope (non-code PR): if the PR is docs-only, lockfile-only, or config-only and the user asked for security / performance analysis, respond
out of scope: no code diff to analyze — switching to <appropriate skill> and hand off.
- Ambiguous PR identifier: if multiple PRs match (e.g., a branch name with multiple open PRs), ask exactly one clarifying question listing the candidates, then stop.
- Base branch missing locally: if
gh pr diff fails because the base ref is not fetched, request git fetch <remote> <base> from the user and stop.
- Publish without approval: never call
gh pr review --approve|--request-changes|--comment without an explicit, in-conversation approval scoped to that PR.
Constraints
- Only review changed code — do not review surrounding unchanged code.
- Do not assume context not visible in the diff; read referenced files via
Read to understand the change, but do not flag them.
- Be constructive — propose a fix alongside every finding.
- Prioritize by severity; do not bury Critical issues under Nitpicks.
- Cite
path:line AND a verbatim 3–8 line code quote per finding. Never invent paths, line numbers, function names, CVE IDs, or RFC numbers.
- Never fabricate findings to fill the report. Zero findings is a valid outcome — emit the
LGTM template and stop.
- Never promote a Minor to Major to look thorough. Severity is bound to impact × likelihood, not to report length.
- If the PR is > 1000 lines, ask before proceeding (Step 2).
- Never publish the review on GitHub without explicit, scoped user approval.
Output format
Structured review following the template in EXAMPLE.md:
- Executive summary (2–4 sentences) ending with the verdict.
- Findings grouped by severity (Critical → Major → Minor → Nitpick), each with
Confidence, path:line, code quote, suggested fix.
- Summary by severity table.
- Zero-findings path:
LGTM template from EXAMPLE.md.
Example request
- "Review PR #42"
- "Analyze this pull request: https://github.com/org/repo/pull/123"
- "Do a quick review of the payment feature PR"
- "Revisar PR #87 desse repo"
- "Feedback no PR mais recente"
Related Skills
@code-review — lifecycle code-review skill (multi-language Go/Rust/TS). Use when the user wants methodology-driven review not tied to a GitHub PR (audit, pre-merge gate, refactor review).
@code-debugger — when a finding here uncovers a runtime bug that needs root-cause analysis.
@github-commit — when the review concludes Approve and the user wants to author the merge commit.
@code-security-review — hand off security findings into a stack-aware audit (Go branch — references/golang/; Next branch — references/nextjs/).
References
| File |
Purpose |
| EXAMPLE.md |
Worked review (Request Changes) + zero-findings (Approve / LGTM) template |
1---2name: github-pr-review3description: Structured GitHub PR review — correctness, security, performance, maintainability. Severity-ranked findings + verdict (Approve/Request Changes/Comment). Non-PR: @code-review. Triggers: 'review PR', 'revisar PR', 'analisar pull request', '/github-pr-review'.4---56# Pull Request Code Review78> Structured GitHub PR review with severity-ranked, citation-bound findings and a clear verdict.910## Goal1112Structured code review of a GitHub Pull Request — correctness, security, performance, maintainability. Findings ranked by severity, each tied to a verbatim diff citation, plus a verdict (Approve / Request Changes / Comment).1314## When to Use1516- The user names a PR by number, URL, or branch and asks for a review.17- The user asks for "feedback", "thoughts", or "concerns" on a pull request.18- The user explicitly invokes `/github-pr-review` or `/valarmindskills:github-pr-review`.1920## Do not use when2122- The user asks about code-review methodology, not a specific GitHub PR → use `@code-review`.23- The user wants to author a commit or PR description, not review one → use `@github-commit` or `@github-release-note`.24- The PR contains no code diff (docs only, lockfile bumps, config-only) and the user wants security/perf analysis — refuse with `out of scope: no code diff to analyze` and hand off.2526## Inputs you must collect before starting2728| Input | Required | How to obtain |29| :--- | :--- | :--- |30| PR identifier | Yes | Number, URL, or branch name; ask if missing |31| Repository | Yes | Infer from current directory; ask if ambiguous |32| Review depth | No | `quick` (high-level) or `deep` (line-by-line) — default: `deep` |3334## Procedure3536### Step 1 — Fetch PR metadata3738```bash39gh pr view <number> --json title,body,author,baseRefName,headRefName,files,additions,deletions,commits,labels,state,isDraft40```4142Record: title, author, base/head branch, files changed, lines added/removed, commits, state (open/closed/merged), draft flag.4344If `state != "OPEN"` or `isDraft == true`, warn the user and ask whether to continue. Do not refuse — historical reviews are valid use cases.4546### Step 2 — Get the full diff4748```bash49gh pr diff <number>50```5152If the PR has more than 1000 changed lines, inform the user and ask whether to (a) continue full review, (b) prioritize a file subset, or (c) abort. Do not silently truncate.5354### Step 3 — Read description and linked issues5556- Read the PR description for context and intent.57- Look up linked issues via `gh issue view <number>` for `Closes #N`, `Fixes #N`, `Refs #N`.58- Identify acceptance criteria, if any.5960### Step 4 — Analyze the changes6162Analyze the diff across four dimensions. Only review changed code — not surrounding unchanged code.6364#### Logic & Correctness65- Business requirements met?66- Edge cases (null, empty, boundaries, concurrency)?67- Error flows correct?68- Loop / recursion termination?69- Type consistency?7071#### Security72- Inputs validated and sanitized?73- Injection risk (SQL, XSS, command, SSRF, path traversal)?74- AuthN / AuthZ checks?75- Sensitive data exposure (logs, responses, env)?76- OWASP Top 10 alignment?7778#### Performance79- N+1 queries or inefficient DB access?80- Unbounded iteration?81- Allocation in hot loops?82- Algorithmic complexity vs. expected volume?83- Blocking calls where async fits?8485#### Maintainability86- Naming clarity (variables, functions, classes)?87- Single responsibility, function size?88- Module coupling?89- Test coverage for the changes?90- Style consistency with the rest of the codebase?9192### Step 5 — Categorize each finding9394Each finding must include `Severity`, `Confidence`, and a verbatim citation:9596| Severity | Criteria |97| :--- | :--- |98| **Critical** | Crash, data loss, exploitable vulnerability, breaks existing functionality |99| **Major** | Bug in a likely scenario, significant performance issue, important standard violation |100| **Minor** | Recommended improvement, readability impact, incomplete error handling |101| **Nitpick** | Stylistic or naming suggestion — does not block approval |102103| Confidence | Meaning |104| :--- | :--- |105| **High** | Mechanical evidence in the diff; reasoning is deterministic |106| **Medium** | Pattern matches but intent may justify it — flag for author |107| **Low** | A second opinion would change the verdict — escalate or downgrade |108109**Citation requirement.** Cite `path:line` AND quote the exact code (3–8 lines from the diff). A finding without both is rejected. Never paraphrase the code; never invent paths, line numbers, or function names.110111### Step 6 — Write the executive summary1121132–4 sentences with:114- What the PR does (paraphrased from the diff, not the description).115- Quality assessment.116- Key concerns, if any.117- Verdict: **Approve**, **Request Changes**, or **Comment**.118119The verdict must match the highest finding severity:120- Any `Critical` or `Major` → `Request Changes`.121- Only `Minor` / `Nitpick` → `Comment` or `Approve` (author discretion).122- Zero findings after Step 8 verification → `Approve` with `LGTM`.123124### Step 7 — Present the review125126Follow the template in [`EXAMPLE.md`](./EXAMPLE.md). For zero-findings PRs, follow the LGTM template in the same file.127128If the user explicitly approves, publish via:129130```bash131gh pr review <number> --approve --body "<message>"132gh pr review <number> --request-changes --body "<message>"133gh pr review <number> --comment --body "<message>"134```135136Never publish without explicit user approval — one approval is scoped to one publish action.137138### Step 8 — Verify before presenting139140Before returning the review, check:1411421. Every cited `path:line` appears in the diff from Step 2.1432. Every code quote is verbatim from the diff (no paraphrase, no fabricated lines).1443. Every finding has a `Severity` and a `Confidence` field.1454. The verdict in the executive summary matches the highest finding severity per Step 6.1465. If zero findings, the output uses the `LGTM` template — not a synthesized Minor.1476. No finding was promoted from Minor to Major to fill the report.148149If any check fails, repair before returning.150151## Refusal hooks152153- **Out of scope (non-code PR):** if the PR is docs-only, lockfile-only, or config-only and the user asked for security / performance analysis, respond `out of scope: no code diff to analyze — switching to <appropriate skill>` and hand off.154- **Ambiguous PR identifier:** if multiple PRs match (e.g., a branch name with multiple open PRs), ask exactly one clarifying question listing the candidates, then stop.155- **Base branch missing locally:** if `gh pr diff` fails because the base ref is not fetched, request `git fetch <remote> <base>` from the user and stop.156- **Publish without approval:** never call `gh pr review --approve|--request-changes|--comment` without an explicit, in-conversation approval scoped to that PR.157158## Constraints159160- Only review changed code — do not review surrounding unchanged code.161- Do not assume context not visible in the diff; read referenced files via `Read` to understand the change, but do not flag them.162- Be constructive — propose a fix alongside every finding.163- Prioritize by severity; do not bury Critical issues under Nitpicks.164- Cite `path:line` AND a verbatim 3–8 line code quote per finding. Never invent paths, line numbers, function names, CVE IDs, or RFC numbers.165- Never fabricate findings to fill the report. Zero findings is a valid outcome — emit the `LGTM` template and stop.166- Never promote a Minor to Major to look thorough. Severity is bound to impact × likelihood, not to report length.167- If the PR is > 1000 lines, ask before proceeding (Step 2).168- Never publish the review on GitHub without explicit, scoped user approval.169170## Output format171172Structured review following the template in [`EXAMPLE.md`](./EXAMPLE.md):173174- Executive summary (2–4 sentences) ending with the verdict.175- Findings grouped by severity (Critical → Major → Minor → Nitpick), each with `Confidence`, `path:line`, code quote, suggested fix.176- Summary by severity table.177- Zero-findings path: `LGTM` template from `EXAMPLE.md`.178179## Example request180181- "Review PR #42"182- "Analyze this pull request: https://github.com/org/repo/pull/123"183- "Do a quick review of the payment feature PR"184- "Revisar PR #87 desse repo"185- "Feedback no PR mais recente"186187## Related Skills188189- `@code-review` — lifecycle code-review skill (multi-language Go/Rust/TS). Use when the user wants methodology-driven review not tied to a GitHub PR (audit, pre-merge gate, refactor review).190- `@code-debugger` — when a finding here uncovers a runtime bug that needs root-cause analysis.191- `@github-commit` — when the review concludes `Approve` and the user wants to author the merge commit.192- `@code-security-review` — hand off security findings into a stack-aware audit (Go branch — `references/golang/`; Next branch — `references/nextjs/`).193194## References195196| File | Purpose |197| :--- | :--- |198| [EXAMPLE.md](./EXAMPLE.md) | Worked review (Request Changes) + zero-findings (Approve / LGTM) template |