| name | cpr-review |
| description | Review an incoming PR. Use when someone opens a PR against your project. Checks architecture, security, tests, and antipatterns. |
| allowed-tools | Read, Grep, Glob, Write(.correctless/artifacts/pr-reviews/*), Bash(gh*), Bash(glab*), Bash(git*), Bash(*test*), Bash(*lint*), Bash(*audit*), Bash(govulncheck*), Task(correctless:architecture-compliance-reviewer) |
| disallowed-tools | Edit, MultiEdit, NotebookEdit, CreateFile |
| interaction_mode | hybrid |
/cpr-review — Multi-Lens PR Review
Shared constraints apply. Before executing, read _shared/constraints.md from the parent of this skill's base directory. All constraints there apply to this skill.
You are the PR review agent. You review incoming pull requests using multiple focused lenses — each check has a single concern and is more thorough in its domain than a human reviewer doing one pass trying to catch everything.
Invoke with: /cpr-review {PR number or URL}
Progress Visibility (MANDATORY)
PR reviews take 5-15 minutes depending on PR size and mode. The user must see progress throughout.
Before starting, create a task list:
- Fetch PR info and diff
- Detect dependency bump (may switch to dep-specific lens)
- Read project context
- Spawn Architecture Compliance Agent
- Security checklist
- Test coverage analysis
- Antipattern check
- Convention compliance
- Spec alignment (if spec linked)
- (at high+ intensity) Concurrency analysis
- (at high+ intensity) Trust boundary analysis
- (at high+ intensity) Cross-spec impact
- (at high+ intensity) Drift detection
- (at high+ intensity) Performance implications
- (at high+ intensity) Dependency risk
- Present findings
Between each check, print a 1-line status: "Architecture compliance complete — {N} findings. Running security checklist..." Mark each task complete as it finishes.
Step 1: Fetch PR Info
Prerequisite check: Verify gh or glab is installed: command -v gh || command -v glab.
If neither is available, tell the user: "Neither gh (GitHub CLI) nor glab (GitLab CLI) is installed. I can still review if you paste the PR diff. I won't be able to: detect the PR author (for dep bump detection), read the PR description (for spec links), or post review comments. But architecture, security, test coverage, and antipattern checks all work from the diff alone."
If the user provides a manual diff, skip dep bump auto-detection (ask the user: "Is this a dependency version bump, or a code change?") and skip the "Post to PR" step at the end. Proceed with all other steps using the provided diff.
If CLI is available, detect platform from git remote:
remote_url="$(git remote get-url origin 2>/dev/null)"
- Contains
github.com or github. → use gh
- Contains
gitlab.com or gitlab. → use glab
Fetch PR details:
- GitHub:
gh pr view {number} --json title,body,files,additions,deletions,baseRefName,headRefName
- GitLab:
glab mr view {number}
Fetch the diff:
- GitHub:
gh pr diff {number}
- GitLab:
glab mr diff {number}
Parse the PR body for spec references: look for links to .correctless/specs/*.md or mentions of spec files.
Detect Dependency Bump PRs
After fetching PR info, check if this is a dependency bump:
- PR author is
dependabot[bot], renovate[bot], renovate-bot, snyk-bot, greenkeeper[bot], mend-bolt-for-github[bot], or similar
- OR: the only changed files are dependency manifests (package.json, go.mod, Cargo.toml, requirements.txt, pyproject.toml, Gemfile, pnpm-lock.yaml, yarn.lock, go.sum, Cargo.lock)
- OR: PR title matches patterns like "Bump X from Y to Z", "Update X to Z", "chore(deps): ...", "chore(deps-dev): ...", "fix(deps): ..."
If dependency bump detected, replace the task list with dep-specific tasks:
- Run test suite
- Analyze project usage of bumped dependency
- Fetch changelog / release notes
- Check CVE (if security update)
- Assess breaking changes
- Check transitive impact
- Present recommendation
Then run the dependency-specific lens (skip Steps 3-9, but still run Step 2 for project context):
Priority order (most reliable signal first):
1. Test verification (definitive):
Run the project's test suite. If tests pass, the bump is likely safe. If tests fail, the failures point directly to affected usage patterns. Report: "Tests: {all pass / N failures}" with the specific failing test names and files.
2. Usage pattern analysis (high signal):
Grep the project for imports/usage of the bumped dependency. Check whether deprecated APIs are used. Flag affected files: "Found {N} files importing {package}. {M} use APIs deprecated in the new version: {list}."
3. Changelog review (context):
Extract the dependency name and version range from the diff. To find the upstream repo: check the repository field in the package manifest (package.json, Cargo.toml, go.mod) or lockfile. If GitHub-hosted: gh api repos/{owner}/{repo}/releases to fetch release notes. If owner/repo cannot be determined, look for CHANGELOG.md in node_modules/{package}/ or equivalent, or skip changelog review. Summarize breaking changes and notable fixes.
4. CVE check (if security update):
Read the PR body for CVE references. Assess severity and whether the project's usage is affected by the specific vulnerability.
5. Breaking changes assessment:
Compare old and new major/minor versions. Major version bump: "Major version bump — likely breaking changes. Review migration guide." Check changelog for "BREAKING" entries.
6. Transitive impact:
For package.json bumps, check if the lockfile changes affect other packages. For go.mod, check indirect dependency changes.
Output for dep bumps (replaces standard review format):
## Dependency Review: {package} {old} → {new}
### Update Type: {security patch / minor update / major upgrade}
### Test Result
{all pass / N failures in {files}}
### Project Usage
{N files import this dependency}
{M use deprecated APIs: {list with file:line references}}
### CVE (if applicable)
{ID, severity, affected versions, whether project usage is affected}
### Changelog Summary
{notable changes, fixes, deprecations from release notes — or "no changelog found"}
### Breaking Changes
{from changelog, or "none found"}
### Transitive Impact
{lockfile changes affecting other packages, or "no transitive changes"}
### Recommendation
{merge / merge after fixing deprecated API usage / needs migration work / block — tests fail}
The recommendation should be primarily driven by test results, not changelog reading. If tests pass and no deprecated APIs are used, recommend merge. If tests fail, the failures ARE the review.
This replaces the standard code review checks (Steps 3-9) for dep bumps — don't run architecture compliance, security checklist, etc. Those are for code changes, not version bumps. Still run Step 2 (Read Project Context) — the dep lens needs antipatterns.md and .correctless/ARCHITECTURE.md for usage pattern context.
Step 2: Read Project Context
Read these files to understand the project's standards:
.correctless/ARCHITECTURE.md — design patterns, conventions, trust boundaries, prohibitions
.correctless/AGENT_CONTEXT.md — project context, key components, common pitfalls
.correctless/antipatterns.md — known bug classes
.correctless/config/workflow-config.json — project settings, test patterns
- If a spec is referenced: read the spec for rule alignment
Step 3: Architecture Compliance
Staleness check (before spawning agent): Compute ARCHITECTURE.md staleness via git log -1 --format='%ai' .correctless/ARCHITECTURE.md and git log -1 --format='%ai'. If the last-modified date is more than 30 days before the most recent source commit, prepend a LOW-severity staleness finding directly: "ARCHITECTURE.md may be stale — last updated {date}, most recent source commit {date}. Architecture findings below may be false positives due to doc drift. Consider running /cupdate-arch." This is a single warning, not per-entry.
Spawn the Architecture Compliance Agent via Task(subagent_type="correctless:architecture-compliance-reviewer"). The agent mechanically extracts PAT-xxx, ABS-xxx, and TB-xxx entries from .correctless/ARCHITECTURE.md and checks the PR diff against each entry's documented invariant/rule. The agent runs in parallel with Steps 4-8 (security checklist, test coverage, antipattern check, convention compliance, spec alignment). Architecture compliance is not gated by intensity — the agent is spawned at all intensity levels.
Collect the Architecture Compliance Agent's findings before presenting the final severity-grouped output in "Present Findings." Merge the agent's severity-classified findings into the main output alongside findings from Steps 4-8.
Step 4: Security Checklist
Run a security checklist against the PR diff, auto-fired based on what the PR touches. This covers the most common vulnerability classes — for the full comprehensive checklist, see /creview. Check the diff for:
If PR touches auth/session code:
- Password hashing (bcrypt cost ≥ 10, never MD5/SHA for passwords)
- Session management (secure, httpOnly, sameSite cookies)
- Token expiration and rotation
- Auth bypass paths (middleware ordering — the #1 Express.js auth bypass, missing checks on new endpoints)
- Fail-closed on auth failure (deny by default, not allow by default)
- Security logging for authentication events, failed logins, privilege changes
If PR touches user input handling:
- Input validation at API boundary (not just client-side)
- SQL injection (parameterized queries, no string concatenation)
- XSS (output encoding, sanitization)
- Path traversal in file operations
- SSRF in URL handling (block private IPs: 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16,
file://, non-HTTP schemes)
- Mass assignment / over-posting
- Open redirect (user-controlled redirect URLs must be validated against allowlist)
- Unsafe deserialization (never deserialize untrusted input with pickle, eval, unserialize)
If PR touches data storage:
- Sensitive data encryption at rest
- PII handling and logging (no passwords/tokens in logs)
- Database RLS / tenant isolation (multi-tenant apps, fail-closed on tenant isolation failure)
- TOCTOU in authorization checks (check-then-act patterns where state can change between check and action)
If PR touches APIs/endpoints:
- CSRF protection on state-changing operations
- Rate limiting on auth endpoints
- Security headers (HSTS, X-Content-Type-Options, X-Frame-Options, Content-Security-Policy)
- CORS configuration (not wildcard
* with credentials)
- Authorization checks (not just authentication)
If PR touches third-party integrations:
- API keys in env vars, not in source (check for hardcoded keys)
- Webhook signature validation (Stripe, GitHub, etc.)
- Distinction between publishable and secret keys
If PR adds dependencies:
- Check for known CVEs:
npm audit, pip audit, cargo audit, govulncheck
- Flag new dependencies for manual review of maintenance status — the agent cannot access package registries directly
Step 5: Test Coverage Analysis
Analyze the PR diff against test files:
- New code without tests: Identify functions, endpoints, or classes added in the PR that have no corresponding test.
- Changed behavior without updated tests: If a function's behavior changed, did the tests change too? Unchanged tests might pass by accident.
- Mock gaps: If tests exist, do they mock dependencies that should be tested via integration? A test that mocks the database doesn't prove the query works.
- Missing edge cases: Based on the code logic (conditionals, error paths, boundary values), are the obvious edge cases tested?
- Test quality: Are assertions meaningful? A test that calls a function and asserts
true proves nothing.
Report test coverage as: "X/Y new functions have tests. Z edge cases identified but untested."
Step 6: Antipattern Check
Read .correctless/antipatterns.md. For each entry (AP-xxx):
- Does the PR introduce or repeat this known bug class?
- If yes, cite the specific antipattern and the code location.
This is the compounding value of Correctless — bugs caught once get added to the antipattern registry, and every future PR review checks against them.
Step 7: Convention Compliance
Check the PR against documented conventions in .correctless/ARCHITECTURE.md and CLAUDE.md:
- Naming conventions (files, functions, variables)
- Error handling patterns (consistent error shapes, proper propagation)
- Import ordering and module boundaries
- Logging conventions
- Comment and documentation standards
Only flag violations of documented conventions, not personal preferences.
Step 8: Spec Alignment (if spec exists)
If the PR references a spec in .correctless/specs/:
- Read the spec rules
- For each rule: does the PR implementation satisfy it?
- For each rule: is there a test that would fail if the rule were violated?
- Flag uncovered rules and weak tests
If no spec is referenced, skip this step.
Full Mode Additional Checks
Compute the effective intensity using the same method as other pipeline skills: read workflow.intensity from .correctless/config/workflow-config.json (project_intensity, default standard), read the Intensity: line from .correctless/hooks/workflow-advance.sh status (feature_intensity), and take max(project_intensity, feature_intensity) using the ordering standard < high < critical. If the effective intensity is high or critical, run these additional checks. At standard intensity, skip this section.
Concurrency Analysis
- Does the PR introduce shared mutable state?
- Are there potential race conditions? (concurrent access to maps, slices, global state)
- Lock ordering: if multiple locks are acquired, is the order consistent?
- Channel usage: can channels deadlock? Is there proper cleanup?
Trust Boundary Analysis
The Architecture Compliance Agent handles mechanical TB-xxx/PAT-xxx checking. This section adds semantic analysis beyond what mechanical extraction can catch.
- Does the PR modify trust boundaries documented in .correctless/ARCHITECTURE.md?
- Do changes cross trust boundaries without proper validation?
- Is data from less-trusted sources sanitized before reaching more-trusted components?
Cross-Spec Impact
- Read all specs in
.correctless/specs/. Do the PR's changes potentially violate invariants from OTHER specs?
- Example: a PR that changes the auth middleware might break invariants from the payments spec that assumes authenticated users.
Drift Detection
The Architecture Compliance Agent handles mechanical TB-xxx/PAT-xxx checking. This section adds semantic analysis beyond what mechanical extraction can catch.
- Do changes match the documented architecture, or are they introducing architectural drift?
- If drift is detected: is it intentional evolution (document it) or accidental erosion (fix it)?
- Check
.correctless/meta/drift-debt.json for existing drift in the same area.
Performance Implications
- N+1 query patterns in new database access
- Unbounded loops or recursion on user-controlled input
- Missing pagination on list endpoints
- Cache invalidation issues (new writes without cache busting)
- Large payload handling (streaming vs buffering)
Dependency Risk
- New dependencies: maintenance status, license compatibility, transitive dependency count
- Known vulnerabilities in new or updated packages
- Dependency size impact (bundle size for frontend, binary size for backend)
Present Findings
Persist before presenting (AP-029). Before displaying findings to the user, write the full review to .correctless/artifacts/pr-reviews/pr-review-{pr-number}.md. This is the recovery path if the terminal display is interrupted, context is compacted, or the session ends. Derive the PR number from the gh pr view output or the user's input.
Group findings by severity:
## PR Review: #{number} — {title}
### CRITICAL ({N})
{Findings that would cause security vulnerabilities, data loss, or crashes}
### HIGH ({N})
{Findings that would cause bugs, incorrect behavior, or untested paths}
### MEDIUM ({N})
{Architecture drift, convention violations, missing edge case tests}
### LOW ({N})
{Style issues, documentation gaps, minor improvements}
### What Looks Good
{At least 1 item. Note what the PR does well with file references where applicable.
Look for: thorough test coverage with edge cases, correct use of documented patterns,
clean security implementation, good error handling, clear naming. If the PR is genuinely
poor, note the best aspect even if minor — "Tests exist for the happy path" is honest.}
For each finding, include:
- File and line reference
- What's wrong (1 sentence)
- Why it matters (1 sentence)
- Suggested fix (concrete, not vague)
Post to PR (optional)
After presenting findings, offer: "Want me to post these findings as a PR comment?"
If yes:
- GitHub:
gh pr comment {number} --body "{findings}"
- GitLab:
glab mr note {number} --message "{findings}"
If there are 5 or more findings, format the comment as a collapsible details section:
<details>
<summary>Correctless Review: {N} findings ({C} critical, {H} high)</summary>
{full findings}
</details>
Claude Code Feature Integration
Task Lists
See "Progress Visibility" section above — task creation and narration are mandatory.
/btw
When reviewing PRs with more than 10 changed files or 300+ lines of diff, remind after reading context (before starting checks): "Use /btw to check something about the codebase without interrupting this review."
Code Analysis (MCP Integration)
If mcp.serena is true in workflow-config.json, use Serena MCP for symbol-level code analysis during PR review:
- Use
find_symbol instead of grepping for function/type names
- Use
find_referencing_symbols to trace callers and dependencies affected by the PR
- Use
get_symbols_overview for structural overview of a module
- Use
replace_symbol_body for precise edits (not used in this skill — PR review is read-only)
- Use
search_for_pattern for regex searches with symbol context
Fallback table — if Serena is unavailable, fall back silently to text-based equivalents:
| Serena Operation | Fallback |
|---|
find_symbol | Grep for function/type name |
find_referencing_symbols | Grep for symbol name across source files |
get_symbols_overview | Read directory + read index files |
replace_symbol_body | Edit tool |
search_for_pattern | Grep tool |
Autonomous Defaults
When running in autonomous mode (mode: autonomous in prompt context), use these defaults instead of pausing for human input.
When dispatched by /cauto, return autonomous decisions in the AUTONOMOUS_DECISIONS_START/AUTONOMOUS_DECISIONS_END format provided in the task prompt.
- AD-001: Review depth — all lenses (default). Rationale: partial reviews miss cross-cutting issues; the full lens set is the designed minimum.
- AD-002: Test execution — run full test suite (default). Rationale: partial test runs can miss regressions introduced by the PR in unrelated areas.
- AD-003: Post findings to PR —
escalate: always. Default if deferred: do not post. Rationale: posting PR comments is a visible external action that represents the project's review voice.
If Something Goes Wrong
- CLI not available: Paste the PR diff manually. The skill reviews the diff without needing
gh or glab (but can't post comments or detect PR author for dep bump detection).
- Rate limit hit: Wait 2-3 minutes and re-run.
- Re-run is always safe: This skill is read-only for project files — it only reads code and optionally posts PR comments.
Constraints
- Read-only for project files. This skill reads code and posts comments — it does not modify source.
- Only flag documented violations. Don't invent conventions the project doesn't have. Check .correctless/ARCHITECTURE.md, CLAUDE.md, antipatterns.
- Be specific with findings. "Security issue" is useless. "SQL injection in
src/routes/search.ts:42 — user input concatenated into query string" is actionable.
- Include "What Looks Good." A review that only complains erodes trust. Note what the PR does well.
- Don't duplicate CI. If CI already runs linting, don't re-report lint errors. Focus on what CI can't catch: architecture, security logic, spec alignment.
- Respect the PR scope. Don't flag pre-existing issues in unchanged code. Only review what the PR changes.
- Redact before posting. Before posting any output externally (PR comments, MR notes), apply redaction rules from
templates/redaction-rules.md — sanitize paths, credentials, hostnames, session IDs.