Review a Pull Request
Purpose
Catch defects and design problems before merge, at a cost proportional to the change's risk, and give the author feedback they can act on immediately. The output is a verdict plus a prioritized list of findings, not a line-by-line style commentary.
When to use
- A PR or diff is ready for review.
- An author wants a pre-review before requesting human reviewers.
- A risky change (data, security, concurrency, public contract) needs a focused second look.
When not to use
- A deep dive into only one dimension. Use
secure-code-review, concurrency-review, error-handling-review or clean-code-review.
- Polishing the wording of comments you already have. Use
review-comment-writing.
- Assessing the whole codebase rather than a change. Use
code-quality-report or tech-debt-assessment.
Inputs
Required:
- The diff or changed code, with enough surrounding context to understand it.
Optional, improves quality:
- PR description and linked work item / acceptance criteria.
- Team coding standards, architecture constraints, test results.
- Language/framework versions and runtime context (service, library, UI).
If only a fragment is given and correctness depends on unseen code, review what is visible and list the assumptions as [ASSUMPTION] and open questions.
Process
- Establish intent: read the description or infer it from the diff; if intent is unclear, say so first, because correctness can only be judged against intent.
- Size the risk and the change: public contracts, persistence, money, auth, concurrency and migrations raise the review depth. Around 100 changed lines is easy to review well; near 1000 lines, recommend splitting into independently mergeable PRs (refactor, behavior change, cleanup).
- Tests first: read the tests before the implementation to learn the intended behavior. Would they fail if the change were reverted? Are edge cases and error paths covered? Are they deterministic?
- Correctness: trace the main path and edge cases (null/empty, boundaries, time zones, rounding, idempotency, retries, partial failure). Check that acceptance criteria are actually met.
- Architecture and design: responsibility placement, coupling, layering violations, leaky abstractions, duplication with existing code, backward compatibility of contracts.
- Security: input validation, authorization on every new entry point, injection, secrets in code, sensitive data in logs (OWASP ASVS as reference).
- Operability and performance: N+1 queries, unbounded loops or payloads, missing timeouts, logging and metrics on new paths, resource cleanup.
- Readability: names, function size, comments explaining why; only raise style issues that a linter would not catch.
- Label each finding:
Critical (blocks merge), Required (the default, no prefix: must be addressed before merge), Nit (trivial, author may ignore), Optional (worth considering), FYI (information only); add question and praise where genuine. Anchor each to file and line and propose the concrete fix, not only the problem. Mark anything inferred about unseen code as [ASSUMPTION].
- Give the verdict: Approve, Approve with comments, Request changes, or Needs discussion, with a one-line reason. Approve a change that improves overall code health even if it is not perfect; never approve without stating what was checked (no rubber-stamp LGTM).
- If the user wants the findings posted as PR comments, continue with
review-comment-writing; for a deeper look at one axis, suggest secure-code-review or error-handling-review.
Output format
# Review: <PR title>
**Verdict:** <Approve | Approve with comments | Request changes | Needs discussion> — <reason>
**Risk level:** <High/Medium/Low> — <why>
## Summary
<2-3 sentences: what the change does and overall assessment>
## Findings
| # | Severity | Location | Finding | Suggested fix |
|---|---|---|---|---|
| 1 | Critical | <file:line> | <issue and consequence> | <concrete change> |
## Tests
- Covered: ...
- Missing: ...
## Questions for the Author
- ...
## What Is Good
- ...
Quality checklist
Common pitfalls
- Spending the review on formatting while missing a missing authorization check. Review in risk order.
- Reviewing only the diff lines. Many bugs sit in unchanged callers or in what the diff forgot to change.
- Requesting a redesign at PR time without a blocker-level reason. Propose a follow-up instead.
- Rubber-stamp approval ("LGTM") on a large diff. Say what was reviewed and what was not; ask for a split if the size prevents a real review.
Example
Input: Diff adding POST /orders/{id}/discount that computes total * (1 - pct/100) with double and saves the result.
Excerpt of output:
- Verdict: Request changes — money is computed in floating point and the endpoint lacks an ownership check.
- 1 | Critical | OrderController:42 | Any authenticated user can apply a discount to any order ID. | Verify order ownership or a staff role before applying.
- 2 | Critical | DiscountService:18 |
double arithmetic causes rounding errors on totals. | Use a decimal type and an explicit rounding mode.
- 3 | (Required) | DiscountServiceTest | No test for pct > 100 or negative pct. | Add boundary tests and validation.
1---2name: code-review3description: "Reviews a pull request or diff for correctness, design, tests, security, performance and readability, and returns prioritized, actionable findings with a clear verdict. Use when someone asks to review a PR, a diff, a patch or a code snippet before merge, or wants a second opinion on a change."4license: MIT5metadata:6 source: https://skillmd.com/skills/muratdincer/code-review7 version: "1.0.0"8 language: en9 category: 05-engineering10 role: developer11 area: collaboration12 title: "Review a pull request"13 related: "review-comment-writing, clean-code-review, secure-code-review, error-handling-review, pull-request-description"14 prompt: "Review this pull request diff. It adds a discount calculation endpoint to the order service."15---1617# Review a Pull Request1819## Purpose20Catch defects and design problems before merge, at a cost proportional to the change's risk, and give the author feedback they can act on immediately. The output is a verdict plus a prioritized list of findings, not a line-by-line style commentary.2122## When to use23- A PR or diff is ready for review.24- An author wants a pre-review before requesting human reviewers.25- A risky change (data, security, concurrency, public contract) needs a focused second look.2627## When not to use28- A deep dive into only one dimension. Use `secure-code-review`, `concurrency-review`, `error-handling-review` or `clean-code-review`.29- Polishing the wording of comments you already have. Use `review-comment-writing`.30- Assessing the whole codebase rather than a change. Use `code-quality-report` or `tech-debt-assessment`.3132## Inputs33Required:34- The diff or changed code, with enough surrounding context to understand it.3536Optional, improves quality:37- PR description and linked work item / acceptance criteria.38- Team coding standards, architecture constraints, test results.39- Language/framework versions and runtime context (service, library, UI).4041If only a fragment is given and correctness depends on unseen code, review what is visible and list the assumptions as `[ASSUMPTION]` and open questions.4243## Process441. Establish intent: read the description or infer it from the diff; if intent is unclear, say so first, because correctness can only be judged against intent.452. Size the risk and the change: public contracts, persistence, money, auth, concurrency and migrations raise the review depth. Around 100 changed lines is easy to review well; near 1000 lines, recommend splitting into independently mergeable PRs (refactor, behavior change, cleanup).463. Tests first: read the tests before the implementation to learn the intended behavior. Would they fail if the change were reverted? Are edge cases and error paths covered? Are they deterministic?474. Correctness: trace the main path and edge cases (null/empty, boundaries, time zones, rounding, idempotency, retries, partial failure). Check that acceptance criteria are actually met.485. Architecture and design: responsibility placement, coupling, layering violations, leaky abstractions, duplication with existing code, backward compatibility of contracts.496. Security: input validation, authorization on every new entry point, injection, secrets in code, sensitive data in logs (OWASP ASVS as reference).507. Operability and performance: N+1 queries, unbounded loops or payloads, missing timeouts, logging and metrics on new paths, resource cleanup.518. Readability: names, function size, comments explaining why; only raise style issues that a linter would not catch.529. Label each finding: `Critical` (blocks merge), Required (the default, no prefix: must be addressed before merge), `Nit` (trivial, author may ignore), `Optional` (worth considering), `FYI` (information only); add `question` and `praise` where genuine. Anchor each to file and line and propose the concrete fix, not only the problem. Mark anything inferred about unseen code as `[ASSUMPTION]`.5310. Give the verdict: Approve, Approve with comments, Request changes, or Needs discussion, with a one-line reason. Approve a change that improves overall code health even if it is not perfect; never approve without stating what was checked (no rubber-stamp LGTM).5411. If the user wants the findings posted as PR comments, continue with `review-comment-writing`; for a deeper look at one axis, suggest `secure-code-review` or `error-handling-review`.5556## Output format57```markdown58# Review: <PR title>59**Verdict:** <Approve | Approve with comments | Request changes | Needs discussion> — <reason>60**Risk level:** <High/Medium/Low> — <why>6162## Summary63<2-3 sentences: what the change does and overall assessment>6465## Findings66| # | Severity | Location | Finding | Suggested fix |67|---|---|---|---|---|68| 1 | Critical | <file:line> | <issue and consequence> | <concrete change> |6970## Tests71- Covered: ...72- Missing: ...7374## Questions for the Author75- ...7677## What Is Good78- ...79```8081## Quality checklist82- [ ] Every Critical finding states the concrete failure scenario, not just a principle.83- [ ] Findings are anchored to a location and include a suggested fix.84- [ ] Severity is proportionate; Nits are not mixed in with Critical findings.85- [ ] Assumptions about unseen code are labeled `[ASSUMPTION]`.86- [ ] Tests were assessed for whether they would catch a regression.87- [ ] The verdict is consistent with the findings.88- [ ] All checks pass; if any fails, revise the output and re-run this checklist before answering.8990## Common pitfalls91- Spending the review on formatting while missing a missing authorization check. Review in risk order.92- Reviewing only the diff lines. Many bugs sit in unchanged callers or in what the diff forgot to change.93- Requesting a redesign at PR time without a blocker-level reason. Propose a follow-up instead.94- Rubber-stamp approval ("LGTM") on a large diff. Say what was reviewed and what was not; ask for a split if the size prevents a real review.9596## Example97Input: Diff adding `POST /orders/{id}/discount` that computes `total * (1 - pct/100)` with `double` and saves the result.9899Excerpt of output:100- Verdict: Request changes — money is computed in floating point and the endpoint lacks an ownership check.101- 1 | Critical | OrderController:42 | Any authenticated user can apply a discount to any order ID. | Verify order ownership or a staff role before applying.102- 2 | Critical | DiscountService:18 | `double` arithmetic causes rounding errors on totals. | Use a decimal type and an explicit rounding mode.103- 3 | (Required) | DiscountServiceTest | No test for pct > 100 or negative pct. | Add boundary tests and validation.