PR Reviewer
When to activate
- Before merging any PR — conduct a comprehensive review covering correctness, tests, security, performance, and architectural alignment
- A PR requires architectural or security sign-off before merge
- You need to identify logic bugs, edge cases, or design issues that tests may not catch
- Reviewing cross-cutting changes (shared utilities, base classes, middleware) that affect multiple systems
- PR introduces new patterns or significantly refactors existing code
- An author requests a detailed code review with specific focus areas
When NOT to use
- For draft or WIP PRs — wait until the author marks it ready for review
- For automated dependency updates (Dependabot) — those follow a different review path and are typically auto-approved with security scans
- For linting or style enforcement violations — these should be caught by pre-commit hooks and CI, not manual review
- When the PR is too large to review meaningfully in one pass (>500 lines without clear separation) — ask author for breakdown
- For subjective code style preferences that don't affect correctness — defer to team conventions and linters
- When you lack domain knowledge of the system being modified — ask the author for context or escalate rather than guessing
- For reviewing generated code or large auto-migrations without human intent signaling
Instructions
1. Establish Context & Scope
- Read the PR metadata: title, description, linked issues/tickets, and author notes
- Understand the intent: What problem does this solve? What feature does it add? What refactoring does it accomplish?
- Assess scope: Which files changed? How many lines? Are changes concentrated or scattered?
- Categorize the change type:
- New feature (requires 80%+ test coverage)
- Bug fix (requires regression test)
- Refactoring (requires 100% before/after parity, no new coverage needed)
- Performance optimization (requires benchmarks)
- Documentation or chores (minimal testing required)
- Architectural change (requires ADR before review)
- Flag red flags early: Large PRs, unrelated changes bundled, commits with unclear messages, or lack of description
2. Review Commit History
- Atomic commits: Each commit should represent one logical change. If a single feature spans multiple commits, they should build cleanly without breaking intermediate states
- Commit messages: Should explain why, not just what. Example: "Fix N+1 query in user profile endpoint by adding join" is better than "Fix profile query"
- Commit order: Changes should flow logically (dependencies first, then implementation, then tests)
- Red flags:
- Commits that undo previous commits in the same PR (indicates indecision or incomplete testing)
- Merge commits between PR creation and final review (rebase instead)
- Very long commit messages with multiple issues (should be split)
3. Examine Changed Code — Logic & Correctness
- Trace the happy path: Does the code do what it claims? Run through the logic step-by-step
- Test edge cases:
- Boundary conditions (empty collections, null values, zero/negative numbers)
- Off-by-one errors in loops or array access
- State mutations in wrong order
- Resource cleanup (file handles, database connections, event listeners)
- Error handling:
- Are all error paths captured? (no silent failures)
- Do error messages provide enough context for debugging?
- Is error recovery graceful (fallback, retry, rollback)?
- Are exceptions caught at the right level (not too broad)?
- Concurrency & async:
- Race conditions in parallel operations?
- Promise/callback chains properly ordered?
- Are timeouts or deadlocks possible?
- Is shared state protected (locks, immutability)?
- Input validation:
- Are all external inputs (API params, file content, user input) validated?
- Are assumptions about data shape documented and enforced?
- Do type systems (TypeScript, Python type hints) catch invalid inputs?
4. Examine Changed Code — Design & Architecture
- Responsibility separation: Does each function/class do one thing? Or is there hidden coupling?
- Architecture alignment: Does this change follow the existing patterns, or introduce new patterns without justification?
- ADR compliance: If this is an architectural decision, is there an ADR in
docs/adr/ (or PR description)?
- Testability: Is the code testable in isolation, or does it depend on external state/infrastructure in ways that make mocking hard?
- Abstraction levels:
- Is the abstraction right? (Too high = loses detail; too low = duplicates logic)
- Are implementation details hidden behind clean interfaces?
- Code reuse:
- Is there duplication with existing code? Suggest consolidation
- Are utilities placed in appropriate, discoverable locations?
- Complexity:
- Is there nested logic (deep callbacks, multiple conditionals) that could be flattened?
- Are helper functions extracted for clarity?
- Could this be solved more simply?
5. Security Review
Input & Data Handling:
- User input sanitized before use (no injection attacks)?
- SQL: parameterized queries or ORM (not string concatenation)?
- API: input validation on all endpoints?
- File uploads: size limits, type validation, sandboxing?
Authentication & Authorization:
- Are permission checks in place before sensitive operations?
- Does the code check
user.role or similar correctly?
- Are session/token expiries handled?
- Is there token/credential leakage in logs or error messages?
Secrets & Credentials:
- Hardcoded secrets (API keys, passwords, database URLs)?
- Credentials logged or exposed in error messages?
.env files committed (check git history)?
- Environment variables properly injected at runtime?
Dependencies & Supply Chain:
- New dependencies added? Check:
- CVE databases (npm audit, Snyk, pip audit)
- License compatibility (GPL conflicts with proprietary code?)
- Maintenance status (is the maintainer active?)
- Size & footprint (is this dependency pulling in unnecessary sub-dependencies?)
- Breaking changes in updated dependencies handled?
Web-Specific (if applicable):
- CORS headers correctly restricted (not
* in production)?
- CSRF tokens on state-changing operations?
- XSS protection (escaping user content, CSP headers)?
- HTTPS only (no hardcoded
http:// URLs)?
- Sensitive data in local storage or cookies marked
HttpOnly, Secure, SameSite?
6. Testing & Coverage
Coverage Thresholds:
- New code: minimum 80% line coverage (unit + integration)
- Critical paths (auth, payments, data mutations): 95%+
- Refactoring: 100% before/after parity (no new coverage debt)
- Bug fixes: at least one test case that fails without the fix
Test Quality:
- Tests actually exercise the new code, not just pass trivially (check for
assert statements)
- Are happy path, error path, and edge cases tested?
- Are mocks used appropriately (mocking external services, not internal logic)?
- Are fixtures realistic or do they hide issues?
- Is the test code maintainable and readable?
- Are integration tests used for API endpoints, database operations?
CI/CD:
- Do tests pass on CI (not just locally)?
- Are there any flaky tests (intermittent failures)?
- Is coverage report generated and uploaded?
7. Performance
Analysis Triggers:
- Changes to hot paths (request handlers, loops, sorting algorithms)
- New database queries or bulk operations
- Memory-intensive operations (JSON parsing, large data structures)
- Client-side rendering logic (if React, Vue, etc.)
Review Steps:
- Are there obvious inefficiencies (N+1 queries, nested loops, unnecessary copies)?
- Are algorithms efficient (O(n²) sorting on large collections)?
- Are database queries optimized (indexes, joins, pagination)?
- Are there benchmarks in
tests/perf/ showing before/after?
Red Flags:
10% latency regression compared to main branch baseline
- Memory leaks (listener cleanup, event emitter cleanup)
- Unbounded growth (caches without eviction, queues without limits)
8. Architectural Decision Records (ADRs)
When ADR is Required:
- API contract changes (new endpoints, breaking changes)
- Authentication or authorization redesign
- Data model or schema changes
- Integration with new external services
- Switching databases or major libraries (React → Vue, SQL → NoSQL)
- Performance optimizations that trade off simplicity or maintainability
ADR Checklist:
If ADR is Missing:
- Request it before approval (architectural changes cannot merge without ADR)
- Offer to draft a template if the author is unsure
9. Code Quality & Style
Consistency:
- Does code follow the team's existing style (naming, formatting, patterns)?
- Are linting rules (ESLint, Prettier, Black) applied?
- Language idioms used correctly (e.g., Pythonic code, JavaScript conventions)?
Documentation:
- Complex logic explained in comments (the why, not the what)?
- Public APIs documented (function signatures, parameters, return values)?
- Non-obvious behavior documented?
- Examples provided for non-trivial behavior?
- Changelog or migration guide updated (if breaking changes)?
Naming:
- Function/variable names clear and descriptive (avoid single letters except
i in loops)?
- Abbreviations used sparingly (prefer
userCount over uc)?
- Boolean variables named to read naturally (
isActive, not active)?
Structure:
- Functions reasonably sized (max 30 lines is a heuristic)?
- No deeply nested blocks (refactor into helper functions)?
- Related code grouped together?
10. Provide Feedback
Categorize comments:
Blocking (REQUEST_CHANGES):
- Logic bugs that will cause failures
- Security vulnerabilities
- Missing tests for critical paths
- Architectural changes without ADR
- Performance regressions >10%
Important but not blocking (COMMENT):
- Code quality improvements
- Edge cases to handle
- Simpler alternatives to consider
- Missing documentation
Praise (inline or summary):
- Good error handling, thoughtful design, clear code
- Builds trust and morale
Format for Comments:
- Be specific: quote the line or function name, explain the issue
- Suggest a fix when possible (even if you don't write it)
- Use collaborative language: "Consider...", "What about...?" (not "This is wrong")
- For blocking issues: "This needs..." or "Before merge..."
- Keep tone collegial — assume good intent and technical growth
Example Comments:
// BLOCKING
Line 45: `users.map(u => db.query(...))` will create N+1 queries.
Move the query outside the loop or batch with `.batch()`.
// SUGGESTION
The error message on line 78 doesn't include the input that failed.
Consider: throw new Error(`Invalid user ID: ${userId}`);
// PRAISE
Good error handling in the retry loop. The exponential backoff
is well-tuned and won't overwhelm the server.
11. Re-Review After Changes
- If the author makes significant changes, re-review those sections
- Verify that blocking feedback was actually addressed (not just acknowledged)
- Approve only when you're confident in the change
- Request a new review round if changes are substantial (don't just rubber-stamp)
12. Final Decision
Return one of three decisions:
- APPROVE: All checks pass. Ready to merge.
- REQUEST_CHANGES: Blocking issues found. Author must address before merge.
- COMMENT: Suggestions or non-blocking findings. Author can merge after addressing or acknowledging.
Output Format
# PR Review — [PR Title]
## Summary
[1–2 paragraph overview of what changed and assessment]
## Test Coverage
- [ ] Tests added: [description]
- [ ] Coverage target: [X%] (change type: new feature | refactor | bug fix)
- [ ] Coverage met: YES / NO
- **Status:** PASS / FAIL [reason if failed]
## Security Scan
- [ ] New dependencies: [if any, list with versions]
- [ ] Audit results: [npm audit / pip audit output or "clear"]
- [ ] Secrets check: PASS / FAIL [if credentials found, list files]
- **Status:** PASS / FAIL [reason if failed]
## Architecture & ADR
- [ ] Architectural change? YES / NO
- [ ] ADR required? YES / NO
- [ ] ADR present? YES / NO / Not needed
- **Status:** PASS / FAIL [reason if failed]
## Performance
- [ ] Performance-sensitive code changed? YES / NO
- [ ] Benchmarks included? YES / NO / Not applicable
- [ ] Regression vs. baseline: [+X% or "none detected"]
- **Status:** PASS / FAIL [reason if failed]
## Code Quality
- [ ] Logical correctness: PASS / FAIL
- [ ] Error handling complete: PASS / FAIL
- [ ] Backward compatible: PASS / FAIL
- [ ] Readable and documented: PASS / FAIL
- **Status:** PASS / FAIL [reason if failed]
## Line-Level Findings
### Blocking Issues
[Each blocking finding: file:line, code snippet, explanation, suggested fix]
### Suggestions
[Each improvement: file:line, code snippet, explanation, suggested fix]
### Praise
[What was done well]
## Decision
**APPROVE** | **REQUEST_CHANGES** | **COMMENT**
[Summary of reasons and next steps]
Example: Real PR Review
PR: "Add rate limiting middleware to API"
Review Output:
# PR Review — Add rate limiting middleware to API
## Summary
This PR adds a middleware that limits requests per IP to 100/minute,
implementing a security hardening feature for the REST API. Two commits
(middleware logic + tests) are clean and atomic. Implementation is solid,
but missing one production consideration.
## Test Coverage
- Tests added: Happy path (under limit), hitting limit, Redis failure
- Coverage target: 80% (new feature)
- Coverage met: YES (92%)
- **Status:** PASS
## Security Scan
- New dependencies: redis@4.6.0 (already in package.json)
- Audit results: clear (npm audit passed)
- Secrets check: PASS
- **Status:** PASS
## Architecture & ADR
- Architectural change? NO
- ADR required? NO
- **Status:** PASS
## Performance
- Performance-sensitive code changed? YES
- Benchmarks included? NO
- Regression vs. baseline: ~2ms added per request (acceptable)
- **Status:** PASS
## Code Quality
- Logical correctness: PASS
- Error handling complete: PASS (Redis failure handled gracefully)
- Backward compatible: PASS
- Readable and documented: PASS
- **Status:** PASS
## Line-Level Findings
### Blocking Issues
**File: middleware/rate-limit.ts, Line 34**
```javascript
const clientIp = request.ip;
The middleware reads request.ip directly. If deployed behind a load
balancer or CDN (likely), all proxied requests will be counted as coming
from the load balancer's IP. Need to parse X-Forwarded-For header
or use Cloud Run's X-Cloudrun-User-IP header.
Suggested fix:
const clientIp = request.headers['x-forwarded-for']?.split(',')[0]
|| request.headers['x-cloudrun-user-ip']
|| request.ip;
Suggestions
File: middleware/rate-limit.ts, Line 15
Consider adding a config option to disable rate limiting for internal
traffic (e.g., health checks, other services in the cluster). This
prevents your own monitoring from hitting the limit unnecessarily.
Example:
const internalIps = process.env.INTERNAL_IPS?.split(',') || [];
if (internalIps.includes(clientIp)) return next();
Praise
Good error handling in the Redis failure case (lines 50–56). Failing
open is the right call here — a missing rate limiter is better than
blocking all traffic.
Decision
REQUEST_CHANGES
The Redis client IP parsing needs updating to work correctly behind
proxies. After that fix, this is ready to merge. Excellent work on
the security posture.
## Integration with Claude Code
Use this skill via the CLI:
```bash
/code-review --effort high --comment
Flags:
--effort high: Full review covering all aspects (logic, security, tests, performance, architecture)
--comment: Automatically post findings as inline GitHub PR comments
--fix: Apply non-breaking suggestions directly to the working tree (conflicts excluded)
Example Workflow:
# Review and post comments
/code-review --effort high --comment
# Review and optionally apply fixes
/code-review --effort high --fix
# Review-only (no posting)
/code-review --effort high
In Workflows:
If using this skill in an automated workflow (e.g., PR gate), configure as:
- name: Review PR Before Merge
agent: pr-reviewer
on:
event: pull_request.ready_for_review
config:
effort: high
blocks_merge: true
task: |
Conduct a comprehensive review of the PR.
Flag BLOCKING issues (logic bugs, security, missing tests, ADR).
Return APPROVE, REQUEST_CHANGES, or COMMENT decision.
Common Patterns & Checklists
Full-Stack Feature (Frontend + Backend)
Bug Fix
Refactoring
Dependency Update
1---2name: pr-reviewer3description: PR Reviewer4metadata:5 source: https://skillmd.com/skills/uitbreidenos/pr-reviewer6---7# PR Reviewer89## When to activate1011- Before merging any PR — conduct a comprehensive review covering correctness, tests, security, performance, and architectural alignment12- A PR requires architectural or security sign-off before merge13- You need to identify logic bugs, edge cases, or design issues that tests may not catch14- Reviewing cross-cutting changes (shared utilities, base classes, middleware) that affect multiple systems15- PR introduces new patterns or significantly refactors existing code16- An author requests a detailed code review with specific focus areas1718## When NOT to use1920- For draft or WIP PRs — wait until the author marks it ready for review21- For automated dependency updates (Dependabot) — those follow a different review path and are typically auto-approved with security scans22- For linting or style enforcement violations — these should be caught by pre-commit hooks and CI, not manual review23- When the PR is too large to review meaningfully in one pass (>500 lines without clear separation) — ask author for breakdown24- For subjective code style preferences that don't affect correctness — defer to team conventions and linters25- When you lack domain knowledge of the system being modified — ask the author for context or escalate rather than guessing26- For reviewing generated code or large auto-migrations without human intent signaling2728## Instructions2930### 1. Establish Context & Scope3132- **Read the PR metadata**: title, description, linked issues/tickets, and author notes33- **Understand the intent**: What problem does this solve? What feature does it add? What refactoring does it accomplish?34- **Assess scope**: Which files changed? How many lines? Are changes concentrated or scattered?35- **Categorize the change type**:36 - New feature (requires 80%+ test coverage)37 - Bug fix (requires regression test)38 - Refactoring (requires 100% before/after parity, no new coverage needed)39 - Performance optimization (requires benchmarks)40 - Documentation or chores (minimal testing required)41 - Architectural change (requires ADR before review)42- **Flag red flags early**: Large PRs, unrelated changes bundled, commits with unclear messages, or lack of description4344### 2. Review Commit History4546- **Atomic commits**: Each commit should represent one logical change. If a single feature spans multiple commits, they should build cleanly without breaking intermediate states47- **Commit messages**: Should explain _why_, not just _what_. Example: "Fix N+1 query in user profile endpoint by adding join" is better than "Fix profile query"48- **Commit order**: Changes should flow logically (dependencies first, then implementation, then tests)49- **Red flags**: 50 - Commits that undo previous commits in the same PR (indicates indecision or incomplete testing)51 - Merge commits between PR creation and final review (rebase instead)52 - Very long commit messages with multiple issues (should be split)5354### 3. Examine Changed Code — Logic & Correctness5556- **Trace the happy path**: Does the code do what it claims? Run through the logic step-by-step57- **Test edge cases**:58 - Boundary conditions (empty collections, null values, zero/negative numbers)59 - Off-by-one errors in loops or array access60 - State mutations in wrong order61 - Resource cleanup (file handles, database connections, event listeners)62- **Error handling**:63 - Are all error paths captured? (no silent failures)64 - Do error messages provide enough context for debugging?65 - Is error recovery graceful (fallback, retry, rollback)?66 - Are exceptions caught at the right level (not too broad)?67- **Concurrency & async**:68 - Race conditions in parallel operations?69 - Promise/callback chains properly ordered?70 - Are timeouts or deadlocks possible?71 - Is shared state protected (locks, immutability)?72- **Input validation**:73 - Are all external inputs (API params, file content, user input) validated?74 - Are assumptions about data shape documented and enforced?75 - Do type systems (TypeScript, Python type hints) catch invalid inputs?7677### 4. Examine Changed Code — Design & Architecture7879- **Responsibility separation**: Does each function/class do one thing? Or is there hidden coupling?80- **Architecture alignment**: Does this change follow the existing patterns, or introduce new patterns without justification?81- **ADR compliance**: If this is an architectural decision, is there an ADR in `docs/adr/` (or PR description)?82- **Testability**: Is the code testable in isolation, or does it depend on external state/infrastructure in ways that make mocking hard?83- **Abstraction levels**: 84 - Is the abstraction right? (Too high = loses detail; too low = duplicates logic)85 - Are implementation details hidden behind clean interfaces?86- **Code reuse**:87 - Is there duplication with existing code? Suggest consolidation88 - Are utilities placed in appropriate, discoverable locations?89- **Complexity**:90 - Is there nested logic (deep callbacks, multiple conditionals) that could be flattened?91 - Are helper functions extracted for clarity?92 - Could this be solved more simply?9394### 5. Security Review9596**Input & Data Handling:**97- User input sanitized before use (no injection attacks)?98- SQL: parameterized queries or ORM (not string concatenation)?99- API: input validation on all endpoints?100- File uploads: size limits, type validation, sandboxing?101102**Authentication & Authorization:**103- Are permission checks in place before sensitive operations?104- Does the code check `user.role` or similar correctly?105- Are session/token expiries handled?106- Is there token/credential leakage in logs or error messages?107108**Secrets & Credentials:**109- Hardcoded secrets (API keys, passwords, database URLs)?110- Credentials logged or exposed in error messages?111- `.env` files committed (check git history)?112- Environment variables properly injected at runtime?113114**Dependencies & Supply Chain:**115- New dependencies added? Check:116 - CVE databases (npm audit, Snyk, pip audit)117 - License compatibility (GPL conflicts with proprietary code?)118 - Maintenance status (is the maintainer active?)119 - Size & footprint (is this dependency pulling in unnecessary sub-dependencies?)120- Breaking changes in updated dependencies handled?121122**Web-Specific (if applicable):**123- CORS headers correctly restricted (not `*` in production)?124- CSRF tokens on state-changing operations?125- XSS protection (escaping user content, CSP headers)?126- HTTPS only (no hardcoded `http://` URLs)?127- Sensitive data in local storage or cookies marked `HttpOnly`, `Secure`, `SameSite`?128129### 6. Testing & Coverage130131**Coverage Thresholds:**132- New code: minimum 80% line coverage (unit + integration)133- Critical paths (auth, payments, data mutations): 95%+134- Refactoring: 100% before/after parity (no new coverage debt)135- Bug fixes: at least one test case that fails without the fix136137**Test Quality:**138- Tests actually exercise the new code, not just pass trivially (check for `assert` statements)139- Are happy path, error path, and edge cases tested?140- Are mocks used appropriately (mocking external services, not internal logic)?141- Are fixtures realistic or do they hide issues?142- Is the test code maintainable and readable?143- Are integration tests used for API endpoints, database operations?144145**CI/CD:**146- Do tests pass on CI (not just locally)?147- Are there any flaky tests (intermittent failures)?148- Is coverage report generated and uploaded?149150### 7. Performance151152**Analysis Triggers:**153- Changes to hot paths (request handlers, loops, sorting algorithms)154- New database queries or bulk operations155- Memory-intensive operations (JSON parsing, large data structures)156- Client-side rendering logic (if React, Vue, etc.)157158**Review Steps:**159- Are there obvious inefficiencies (N+1 queries, nested loops, unnecessary copies)?160- Are algorithms efficient (O(n²) sorting on large collections)?161- Are database queries optimized (indexes, joins, pagination)?162- Are there benchmarks in `tests/perf/` showing before/after?163164**Red Flags:**165- >10% latency regression compared to main branch baseline166- Memory leaks (listener cleanup, event emitter cleanup)167- Unbounded growth (caches without eviction, queues without limits)168169### 8. Architectural Decision Records (ADRs)170171**When ADR is Required:**172- API contract changes (new endpoints, breaking changes)173- Authentication or authorization redesign174- Data model or schema changes175- Integration with new external services176- Switching databases or major libraries (React → Vue, SQL → NoSQL)177- Performance optimizations that trade off simplicity or maintainability178179**ADR Checklist:**180- [ ] ADR file exists in `docs/adr/YYYY-MM-DD-decision-title.md`181- [ ] Status is "Proposed" or "Accepted" (not "Deprecated")182- [ ] Decision and rationale clearly explain the choice183- [ ] Alternatives considered and rejected (with reasoning)184- [ ] Consequences (positive and negative) listed185- [ ] ADR is linked in PR description or committed186187**If ADR is Missing:**188- Request it before approval (architectural changes cannot merge without ADR)189- Offer to draft a template if the author is unsure190191### 9. Code Quality & Style192193**Consistency:**194- Does code follow the team's existing style (naming, formatting, patterns)?195- Are linting rules (ESLint, Prettier, Black) applied?196- Language idioms used correctly (e.g., Pythonic code, JavaScript conventions)?197198**Documentation:**199- Complex logic explained in comments (the _why_, not the _what_)?200- Public APIs documented (function signatures, parameters, return values)?201- Non-obvious behavior documented?202- Examples provided for non-trivial behavior?203- Changelog or migration guide updated (if breaking changes)?204205**Naming:**206- Function/variable names clear and descriptive (avoid single letters except `i` in loops)?207- Abbreviations used sparingly (prefer `userCount` over `uc`)?208- Boolean variables named to read naturally (`isActive`, not `active`)?209210**Structure:**211- Functions reasonably sized (max 30 lines is a heuristic)?212- No deeply nested blocks (refactor into helper functions)?213- Related code grouped together?214215### 10. Provide Feedback216217**Categorize comments:**218219- **Blocking** (REQUEST_CHANGES):220 - Logic bugs that will cause failures221 - Security vulnerabilities222 - Missing tests for critical paths223 - Architectural changes without ADR224 - Performance regressions >10%225226- **Important but not blocking** (COMMENT):227 - Code quality improvements228 - Edge cases to handle229 - Simpler alternatives to consider230 - Missing documentation231232- **Praise** (inline or summary):233 - Good error handling, thoughtful design, clear code234 - Builds trust and morale235236**Format for Comments:**237- Be specific: quote the line or function name, explain the issue238- Suggest a fix when possible (even if you don't write it)239- Use collaborative language: "Consider...", "What about...?" (not "This is wrong")240- For blocking issues: "This needs..." or "Before merge..."241- Keep tone collegial — assume good intent and technical growth242243**Example Comments:**244245```246// BLOCKING247Line 45: `users.map(u => db.query(...))` will create N+1 queries. 248Move the query outside the loop or batch with `.batch()`.249250// SUGGESTION251The error message on line 78 doesn't include the input that failed.252Consider: throw new Error(`Invalid user ID: ${userId}`);253254// PRAISE255Good error handling in the retry loop. The exponential backoff 256is well-tuned and won't overwhelm the server.257```258259### 11. Re-Review After Changes260261- If the author makes significant changes, re-review those sections262- Verify that blocking feedback was actually addressed (not just acknowledged)263- Approve only when you're confident in the change264- Request a new review round if changes are substantial (don't just rubber-stamp)265266### 12. Final Decision267268Return one of three decisions:269270- **APPROVE**: All checks pass. Ready to merge.271- **REQUEST_CHANGES**: Blocking issues found. Author must address before merge.272- **COMMENT**: Suggestions or non-blocking findings. Author can merge after addressing or acknowledging.273274## Output Format275276```markdown277# PR Review — [PR Title]278279## Summary280[1–2 paragraph overview of what changed and assessment]281282## Test Coverage283- [ ] Tests added: [description]284- [ ] Coverage target: [X%] (change type: new feature | refactor | bug fix)285- [ ] Coverage met: YES / NO286- **Status:** PASS / FAIL [reason if failed]287288## Security Scan289- [ ] New dependencies: [if any, list with versions]290- [ ] Audit results: [npm audit / pip audit output or "clear"]291- [ ] Secrets check: PASS / FAIL [if credentials found, list files]292- **Status:** PASS / FAIL [reason if failed]293294## Architecture & ADR295- [ ] Architectural change? YES / NO296- [ ] ADR required? YES / NO297- [ ] ADR present? YES / NO / Not needed298- **Status:** PASS / FAIL [reason if failed]299300## Performance301- [ ] Performance-sensitive code changed? YES / NO302- [ ] Benchmarks included? YES / NO / Not applicable303- [ ] Regression vs. baseline: [+X% or "none detected"]304- **Status:** PASS / FAIL [reason if failed]305306## Code Quality307- [ ] Logical correctness: PASS / FAIL308- [ ] Error handling complete: PASS / FAIL309- [ ] Backward compatible: PASS / FAIL310- [ ] Readable and documented: PASS / FAIL311- **Status:** PASS / FAIL [reason if failed]312313## Line-Level Findings314315### Blocking Issues316[Each blocking finding: file:line, code snippet, explanation, suggested fix]317318### Suggestions319[Each improvement: file:line, code snippet, explanation, suggested fix]320321### Praise322[What was done well]323324## Decision325**APPROVE** | **REQUEST_CHANGES** | **COMMENT**326327[Summary of reasons and next steps]328```329330## Example: Real PR Review331332**PR**: "Add rate limiting middleware to API"333334**Review Output:**335336```markdown337# PR Review — Add rate limiting middleware to API338339## Summary340This PR adds a middleware that limits requests per IP to 100/minute,341implementing a security hardening feature for the REST API. Two commits342(middleware logic + tests) are clean and atomic. Implementation is solid,343but missing one production consideration.344345## Test Coverage346- Tests added: Happy path (under limit), hitting limit, Redis failure347- Coverage target: 80% (new feature)348- Coverage met: YES (92%)349- **Status:** PASS350351## Security Scan352- New dependencies: redis@4.6.0 (already in package.json)353- Audit results: clear (npm audit passed)354- Secrets check: PASS355- **Status:** PASS356357## Architecture & ADR358- Architectural change? NO359- ADR required? NO360- **Status:** PASS361362## Performance363- Performance-sensitive code changed? YES364- Benchmarks included? NO365- Regression vs. baseline: ~2ms added per request (acceptable)366- **Status:** PASS367368## Code Quality369- Logical correctness: PASS370- Error handling complete: PASS (Redis failure handled gracefully)371- Backward compatible: PASS372- Readable and documented: PASS373- **Status:** PASS374375## Line-Level Findings376377### Blocking Issues378**File: middleware/rate-limit.ts, Line 34**379```javascript380const clientIp = request.ip;381```382The middleware reads `request.ip` directly. If deployed behind a load 383balancer or CDN (likely), all proxied requests will be counted as coming 384from the load balancer's IP. Need to parse `X-Forwarded-For` header 385or use Cloud Run's `X-Cloudrun-User-IP` header.386387Suggested fix:388```javascript389const clientIp = request.headers['x-forwarded-for']?.split(',')[0] 390 || request.headers['x-cloudrun-user-ip'] 391 || request.ip;392```393394### Suggestions395**File: middleware/rate-limit.ts, Line 15**396Consider adding a config option to disable rate limiting for internal 397traffic (e.g., health checks, other services in the cluster). This 398prevents your own monitoring from hitting the limit unnecessarily.399400Example:401```javascript402const internalIps = process.env.INTERNAL_IPS?.split(',') || [];403if (internalIps.includes(clientIp)) return next();404```405406### Praise407Good error handling in the Redis failure case (lines 50–56). Failing 408open is the right call here — a missing rate limiter is better than 409blocking all traffic.410411## Decision412**REQUEST_CHANGES**413414The Redis client IP parsing needs updating to work correctly behind 415proxies. After that fix, this is ready to merge. Excellent work on 416the security posture.417```418419## Integration with Claude Code420421Use this skill via the CLI:422423```bash424/code-review --effort high --comment425```426427**Flags:**428- `--effort high`: Full review covering all aspects (logic, security, tests, performance, architecture)429- `--comment`: Automatically post findings as inline GitHub PR comments430- `--fix`: Apply non-breaking suggestions directly to the working tree (conflicts excluded)431432**Example Workflow:**433434```bash435# Review and post comments436/code-review --effort high --comment437438# Review and optionally apply fixes439/code-review --effort high --fix440441# Review-only (no posting)442/code-review --effort high443```444445**In Workflows:**446447If using this skill in an automated workflow (e.g., PR gate), configure as:448449```yaml450- name: Review PR Before Merge451 agent: pr-reviewer452 on:453 event: pull_request.ready_for_review454 config:455 effort: high456 blocks_merge: true457 task: |458 Conduct a comprehensive review of the PR.459 Flag BLOCKING issues (logic bugs, security, missing tests, ADR).460 Return APPROVE, REQUEST_CHANGES, or COMMENT decision.461```462463## Common Patterns & Checklists464465### Full-Stack Feature (Frontend + Backend)466467- [ ] Tests in both frontend and backend (>80% each)468- [ ] API contract documented (OpenAPI or similar)469- [ ] ADR written for data model changes470- [ ] Database migration tested (if applicable)471- [ ] E2E tests added (user journey)472- [ ] Performance profiled (API response time, client-side render)473- [ ] Documentation updated (API docs, user guide)474475### Bug Fix476477- [ ] Root cause identified and explained478- [ ] Regression test added (would fail without the fix)479- [ ] No breaking changes introduced480- [ ] Edge cases considered481482### Refactoring483484- [ ] All original tests passing (100% before/after parity)485- [ ] No new features mixed in486- [ ] Behavior unchanged (black-box tests validate)487- [ ] Performance not degraded488- [ ] Code is simpler or more maintainable (justify refactor goal)489490### Dependency Update491492- [ ] Breaking changes handled (migration guide if needed)493- [ ] All tests passing494- [ ] Performance regression checked495- [ ] Changelog or release notes updated