Comprehensive PR code review - checks diff, patterns, runs validation, comments on PR
Performs comprehensive PR code review, validates changes, and posts structured feedback to GitHub.
/plugin marketplace add Wirasm/PRPs-agentic-eng/plugin install prp-core@prp-marketplace<pr-number|pr-url> [--approve|--request-changes]Input: $ARGUMENTS
Perform a thorough, senior-engineer-level code review:
Golden Rule: Be constructive and actionable. Every issue should have a clear recommendation. Acknowledge good work too.
Determine input type:
| Input Format | Action |
|---|---|
Number (123, #123) | Use as PR number |
URL (https://github.com/.../pull/123) | Extract PR number |
Branch name (feature-x) | Find associated PR |
# If branch name provided, find PR
gh pr list --head {branch-name} --json number -q '.[0].number'
# Get comprehensive PR details
gh pr view {NUMBER} --json number,title,body,author,headRefName,baseRefName,state,additions,deletions,changedFiles,files,reviews,comments
# Get the diff
gh pr diff {NUMBER}
# List changed files
gh pr diff {NUMBER} --name-only
Extract:
# Fetch and checkout the PR branch
gh pr checkout {NUMBER}
| State | Action |
|---|---|
MERGED | STOP: "PR already merged. Nothing to review." |
CLOSED | WARN: "PR is closed. Review anyway? (historical analysis)" |
DRAFT | NOTE: "Draft PR - focusing on direction, not polish" |
OPEN | PROCEED with full review |
PHASE_1_CHECKPOINT:
Read and internalize:
# Project conventions
cat CLAUDE.md
# Check for additional reference docs
ls -la .claude/docs/ 2>/dev/null
ls -la docs/ 2>/dev/null
Extract key constraints:
Look for implementation artifacts:
# Find implementation report by branch name
ls .claude/PRPs/reports/*{branch-name}*.md 2>/dev/null
# Find completed plans
ls .claude/PRPs/plans/completed/ 2>/dev/null
# Find issue investigations
ls .claude/PRPs/issues/completed/ 2>/dev/null
If implementation report exists:
If no implementation report:
/prp-implementFrom PR title, description, AND implementation report (if available):
For each changed file, determine:
PHASE_2_CHECKPOINT:
For each file in the diff:
For EVERY changed file, check:
any)?Important: Check implementation report first!
If a deviation from expected patterns is documented in the implementation report with a valid reason, it is NOT an issue - it's an intentional decision. Only flag undocumented deviations.
Issue Severity Levels:
| Level | Icon | Criteria | Examples |
|---|---|---|---|
| Critical | RED | Blocking - must fix | Security vulnerabilities, data loss potential, crashes |
| High | ORANGE | Should fix before merge | Type safety violations, missing error handling, logic errors |
| Medium | YELLOW | Should consider | Pattern inconsistencies, missing edge cases, undocumented deviations |
| Low | BLUE | Suggestions | Style preferences, minor optimizations, documentation |
PHASE_3_CHECKPOINT:
# Type checking (adapt to project)
npm run type-check || bun run type-check || npx tsc --noEmit
# Linting
npm run lint || bun run lint
# Tests
npm test || bun test
# Build
npm run build || bun run build
Capture for each:
Based on what changed:
| Change Type | Additional Validation |
|---|---|
| New API endpoint | Test with curl/httpie |
| Database changes | Check migration exists |
| Config changes | Verify .env.example updated |
| New dependencies | Check package.json/lock file |
# Full test suite
npm test || bun test
# Specific tests for changed functionality
npm test -- {relevant-test-pattern}
PHASE_4_CHECKPOINT:
APPROVE if:
REQUEST CHANGES if:
BLOCK if:
| Situation | Handling |
|---|---|
| Draft PR | Comment only, no approve/block |
| Large PR (>500 lines) | Note thoroughness limits, suggest splitting |
| Security-sensitive | Extra scrutiny, err on caution |
| Missing tests | Strong recommendation, may not block |
PHASE_5_CHECKPOINT:
mkdir -p .claude/PRPs/reviews
Path: .claude/PRPs/reviews/pr-{NUMBER}-review.md
---
pr: {NUMBER}
title: "{TITLE}"
author: "{AUTHOR}"
reviewed: {ISO_TIMESTAMP}
recommendation: {approve|request-changes|block}
---
# PR Review: #{NUMBER} - {TITLE}
**Author**: @{author}
**Branch**: {head} -> {base}
**Files Changed**: {count} (+{additions}/-{deletions})
---
## Summary
{2-3 sentences: What this PR does and overall assessment}
---
## Implementation Context
| Artifact | Path |
|----------|------|
| Implementation Report | `{path}` or "Not found" |
| Original Plan | `{path}` or "Not found" |
| Documented Deviations | {count} or "N/A" |
{If implementation report exists: Brief note about deviation documentation quality}
---
## Changes Overview
| File | Changes | Assessment |
|------|---------|------------|
| `{path/to/file.ts}` | +{N}/-{M} | {PASS/WARN/FAIL} |
---
## Issues Found
### Critical
{If none: "No critical issues found."}
- **`{file.ts}:{line}`** - {Issue description}
- **Why**: {Explanation of the problem}
- **Fix**: {Specific recommendation}
### High Priority
{Issues that should be fixed before merge}
### Medium Priority
{Issues worth addressing but not blocking}
### Suggestions
{Nice-to-haves and future improvements}
---
## Validation Results
| Check | Status | Details |
|-------|--------|---------|
| Type Check | {PASS/FAIL} | {notes} |
| Lint | {PASS/WARN} | {count} warnings |
| Tests | {PASS/FAIL} | {count} passed |
| Build | {PASS/FAIL} | {notes} |
---
## Pattern Compliance
- [{x}] Follows existing code structure
- [{x}] Type safety maintained
- [{x}] Naming conventions followed
- [{x}] Tests added for new code
- [{x}] Documentation updated
---
## What's Good
{Acknowledge positive aspects - good patterns, clean code, thorough tests, etc.}
---
## Recommendation
**{APPROVE/REQUEST CHANGES/BLOCK}**
{Clear explanation of recommendation and what needs to happen next}
---
*Reviewed by Claude*
*Report: `.claude/PRPs/reviews/pr-{NUMBER}-review.md`*
PHASE_6_CHECKPOINT:
Based on recommendation and flags:
# If --approve flag AND no critical/high issues
gh pr review {NUMBER} --approve --body-file .claude/PRPs/reviews/pr-{NUMBER}-review.md
# If --request-changes flag OR high issues found
gh pr review {NUMBER} --request-changes --body-file .claude/PRPs/reviews/pr-{NUMBER}-review.md
# Otherwise just comment
gh pr comment {NUMBER} --body-file .claude/PRPs/reviews/pr-{NUMBER}-review.md
# Get the review/comment URL
gh pr view {NUMBER} --json reviews,comments --jq '.reviews[-1].url // .comments[-1].url'
PHASE_7_CHECKPOINT:
## PR Review Complete
**PR**: #{NUMBER} - {TITLE}
**URL**: {PR_URL}
**Recommendation**: {APPROVE/REQUEST CHANGES/BLOCK}
### Issues Found
| Severity | Count |
|----------|-------|
| Critical | {N} |
| High | {N} |
| Medium | {N} |
| Suggestions | {N} |
### Validation
| Check | Result |
|-------|--------|
| Type Check | {PASS/FAIL} |
| Lint | {PASS/FAIL} |
| Tests | {PASS/FAIL} |
| Build | {PASS/FAIL} |
### Artifacts
- Report: `.claude/PRPs/reviews/pr-{NUMBER}-review.md`
- PR Comment: {comment_url}
### Next Steps
{Based on recommendation:}
- APPROVE: "PR is ready for merge"
- REQUEST CHANGES: "Author should address {N} high-priority issues"
- BLOCK: "Fundamental issues need resolution before proceeding"
Understand before judging. Read full context, not just the diff.
Be specific. "This could be better" is useless. "Use execFile instead of exec to prevent command injection at line 45" is helpful.
Prioritize. Not everything is critical. Use severity levels honestly.
Be constructive. Offer solutions, not just problems.
Acknowledge good work. If something is done well, say so.
Run validation. Don't skip automated checks.
Check patterns. Read existing similar code to understand expectations.
Think about edge cases. What happens with null, empty, very large, concurrent?
Check implementation report. Documented deviations are intentional, not issues.