Code Review
Provides a systematic, repeatable code-review workflow that balances thoroughness with actionability.
Purpose
Help an AI agent produce high-quality code reviews that catch defects, surface risks, and improve maintainability — without nitpicking or over-flagging. The output should be prioritized, justified, and easy for the author to act on.
When to Use
- User asks to review code, a file, a directory, or a PR diff
- User requests an audit, critique, or assessment of implementation quality
- User pastes a snippet and asks "is this good?", "any issues?", "can you review?"
- CI or pre-merge checks need a checklist-based review
- Keywords:
review, audit, critique, assess, PR review, code quality
Workflow
1. Scope and context
- Identify what is under review: commit range, PR diff, file list, or full module
- Read surrounding context (neighboring files, tests, configs) to understand intent — do not review in isolation
- Note stated goals, linked issue/ticket, and any project conventions (
CONTRIBUTING.md, linters, .editorconfig)
2. Correctness
Check that the code does what it claims:
- Logic errors, off-by-one, null/undefined handling, error paths, edge cases
- API contracts: request/response shapes, status codes, error codes
- Concurrency and async correctness (races, deadlocks, unawaited promises)
- Data invariants and state transitions
3. Security
Scan for common vulnerabilities, proportional to the code's exposure:
- Injection (SQL, XSS, command, template), auth/authz bypass, IDOR
- Secrets in code/logs, insecure randomness, weak crypto, unsafe deserialization
- Mass assignment, SSRF, path traversal, open redirects
- Dependency risks (known CVEs if a lockfile changed)
- If nothing security-relevant is in scope, explicitly say "No security-relevant changes in this scope" rather than inventing issues
4. Maintainability and clean code
- Naming clarity, single responsibility, function/module length, duplication
- Abstraction appropriateness (no premature abstraction, no leaky abstraction)
- Public API surface: is it minimal and hard to misuse?
- Comments: explain why, not what; remove stale or misleading comments
- Consistency with project style (naming, error handling, patterns)
5. Performance
- Obvious hot-path issues: N+1 queries, unbounded loops, missing pagination, large allocations
- Complexity regressions (e.g., O(n) → O(n²) on a large collection)
- I/O: redundant network calls, missing caching where appropriate, blocking I/O on event loop
- Only flag measurable concerns; avoid micro-optimizations without evidence
6. Testing
- Is the change covered by tests? Would you trust this without manual QA?
- Test quality: asserts behavior, not implementation; covers edge cases and failure paths
- Missing tests for bug fixes (should include a regression test)
- Over-mocked or flaky tests
7. Synthesize and prioritize
Produce findings grouped by severity:
- 🔴 Blocking — must fix before merge (incorrectness, security, data loss)
- 🟡 Important — should fix (maintainability debt, missing tests, performance risk)
- 🟢 Suggestion — optional/nit (style, minor naming, alternative approach)
For each finding, include:
- Location:
file_path:line_number
- Issue: one sentence
- Why it matters: impact if not fixed
- Suggested fix: concrete code or direction (diff hunk when helpful)
Close with a verdict: Approve / Approve with comments / Request changes and a 2-3 line summary.
8. Optional Jev rescore (skipped without JEV_API_KEY)
When configured, send task+diff+files+test results to jev_review; fix the
weakest important dimensions, re-run checks, rescore with
previousEvaluation. The verdict above still decides. Never send secrets.
Full protocol: contribute Jev gates.
Instructions
- Be specific and evidence-based. Every finding must cite a location and explain the risk. Never emit vague "consider improving quality" without a concrete pointer.
- Limit noise. If there are >15 findings, show the top 10 and summarize the rest as "Additional nits: ...". Respect the author's time.
- Acknowledge good code. Call out one thing done well when warranted — it reinforces patterns and balances tone.
- Follow project conventions first. House style outranks generic preference. Cite the config or doc that supports a style comment.
- Don't rewrite the PR. Suggest the smallest fix that resolves the issue; offer a larger refactor only as an optional follow-up.
- Use non-judgmental tone. "This branch does not handle..." not "You forgot to handle..."
Constraints
- Do NOT hallucinate files or lines — only reference artifacts you actually read
- Do NOT flag security issues without a plausible attack path in this codebase
- Do NOT demand tests for trivial config/doc-only changes unless they affect behavior
- Do NOT suggest adding dependencies without noting the trade-off
- Do NOT provide a review without an explicit verdict (Approve / Approve with comments / Request changes)
Examples
Example 1 — PR review
User: "Review the diff in src/auth/login.ts from this PR."
Agent:
- Reads
src/auth/login.ts:1-120, src/auth/login.test.ts, and CONTRIBUTING.md
- Produces:
Verdict: Request changes
🔴 Blocking
- src/auth/login.ts:42 — `password` logged in plaintext via `console.log`.
Risk: credential leak in logs. Fix: remove log or log `***`.
🟡 Important
- src/auth/login.ts:78 — Missing rate-limit check before `verify()`.
Risk: brute-force. Fix: call `rateLimiter.check(ip)` first.
🟢 Suggestion
- src/auth/login.ts:91 — Variable `tmp` is vague; rename `pendingSession`.
Example 2 — Security-focused audit
User: "Audit api/search.ts for security."
Agent:
- Reads
api/search.ts:1-80, checks for req.query usage
- Flags:
api/search.ts:34 — String-interpolated SQL: \SELECT ... WHERE q='${q}'`. Use parameterized query `db.query('SELECT ... WHERE q=$1', [q])`` with severity 🔴 Blocking
- Notes "No authz check needed here — endpoint is public by design" to show reasoning
Example 3 — Whole-module review
User: "Can you review internal/billing/ for maintainability?"
Agent:
- Lists files, measures per-file length, spots duplication between
invoice.ts and receipt.ts
- Recommends extracting shared
Money value object, notes function calculate() at 90 lines should be split
- Verdict:
Approve with comments — no blocking issues, but debt will compound if not addressed
References
- Complements
project-architecture (review the architecture) and documentation (note missing docs flagged during review)
1---2name: code-review3description: Use this skill when reviewing code for correctness, security, maintainability, performance, testing, and clean code. Triggers on requests to review, audit, critique, or assess code, PRs, or diffs.4---56# Code Review78Provides a systematic, repeatable code-review workflow that balances thoroughness with actionability.910## Purpose1112Help an AI agent produce high-quality code reviews that catch defects, surface risks, and improve maintainability — without nitpicking or over-flagging. The output should be prioritized, justified, and easy for the author to act on.1314## When to Use1516- User asks to review code, a file, a directory, or a PR diff17- User requests an audit, critique, or assessment of implementation quality18- User pastes a snippet and asks "is this good?", "any issues?", "can you review?"19- CI or pre-merge checks need a checklist-based review20- Keywords: `review`, `audit`, `critique`, `assess`, `PR review`, `code quality`2122## Workflow2324### 1. Scope and context2526- Identify what is under review: commit range, PR diff, file list, or full module27- Read surrounding context (neighboring files, tests, configs) to understand intent — do not review in isolation28- Note stated goals, linked issue/ticket, and any project conventions (`CONTRIBUTING.md`, linters, `.editorconfig`)2930### 2. Correctness3132Check that the code does what it claims:3334- Logic errors, off-by-one, null/undefined handling, error paths, edge cases35- API contracts: request/response shapes, status codes, error codes36- Concurrency and async correctness (races, deadlocks, unawaited promises)37- Data invariants and state transitions3839### 3. Security4041Scan for common vulnerabilities, proportional to the code's exposure:4243- Injection (SQL, XSS, command, template), auth/authz bypass, IDOR44- Secrets in code/logs, insecure randomness, weak crypto, unsafe deserialization45- Mass assignment, SSRF, path traversal, open redirects46- Dependency risks (known CVEs if a lockfile changed)47- If nothing security-relevant is in scope, explicitly say "No security-relevant changes in this scope" rather than inventing issues4849### 4. Maintainability and clean code5051- Naming clarity, single responsibility, function/module length, duplication52- Abstraction appropriateness (no premature abstraction, no leaky abstraction)53- Public API surface: is it minimal and hard to misuse?54- Comments: explain *why*, not *what*; remove stale or misleading comments55- Consistency with project style (naming, error handling, patterns)5657### 5. Performance5859- Obvious hot-path issues: N+1 queries, unbounded loops, missing pagination, large allocations60- Complexity regressions (e.g., O(n) → O(n²) on a large collection)61- I/O: redundant network calls, missing caching where appropriate, blocking I/O on event loop62- Only flag measurable concerns; avoid micro-optimizations without evidence6364### 6. Testing6566- Is the change covered by tests? Would you trust this without manual QA?67- Test quality: asserts behavior, not implementation; covers edge cases and failure paths68- Missing tests for bug fixes (should include a regression test)69- Over-mocked or flaky tests7071### 7. Synthesize and prioritize7273Produce findings grouped by severity:7475- **🔴 Blocking** — must fix before merge (incorrectness, security, data loss)76- **🟡 Important** — should fix (maintainability debt, missing tests, performance risk)77- **🟢 Suggestion** — optional/nit (style, minor naming, alternative approach)7879For each finding, include:8081- **Location**: `file_path:line_number`82- **Issue**: one sentence83- **Why it matters**: impact if not fixed84- **Suggested fix**: concrete code or direction (diff hunk when helpful)8586Close with a **verdict**: `Approve` / `Approve with comments` / `Request changes` and a 2-3 line summary.8788### 8. Optional Jev rescore (skipped without `JEV_API_KEY`)8990When configured, send task+diff+files+test results to `jev_review`; fix the91weakest important dimensions, re-run checks, rescore with92`previousEvaluation`. The verdict above still decides. Never send secrets.93Full protocol: [contribute Jev gates](../contribute/references/jev-decisions.md).9495## Instructions9697- **Be specific and evidence-based.** Every finding must cite a location and explain the risk. Never emit vague "consider improving quality" without a concrete pointer.98- **Limit noise.** If there are >15 findings, show the top 10 and summarize the rest as "Additional nits: ...". Respect the author's time.99- **Acknowledge good code.** Call out one thing done well when warranted — it reinforces patterns and balances tone.100- **Follow project conventions first.** House style outranks generic preference. Cite the config or doc that supports a style comment.101- **Don't rewrite the PR.** Suggest the smallest fix that resolves the issue; offer a larger refactor only as an optional follow-up.102- **Use non-judgmental tone.** "This branch does not handle..." not "You forgot to handle..."103104## Constraints105106- Do NOT hallucinate files or lines — only reference artifacts you actually read107- Do NOT flag security issues without a plausible attack path in this codebase108- Do NOT demand tests for trivial config/doc-only changes unless they affect behavior109- Do NOT suggest adding dependencies without noting the trade-off110- Do NOT provide a review without an explicit verdict (Approve / Approve with comments / Request changes)111112## Examples113114### Example 1 — PR review115116> **User**: "Review the diff in `src/auth/login.ts` from this PR."117118**Agent**:1191201. Reads `src/auth/login.ts:1-120`, `src/auth/login.test.ts`, and `CONTRIBUTING.md`1212. Produces:122123```124Verdict: Request changes125126🔴 Blocking127- src/auth/login.ts:42 — `password` logged in plaintext via `console.log`.128 Risk: credential leak in logs. Fix: remove log or log `***`.129130🟡 Important131- src/auth/login.ts:78 — Missing rate-limit check before `verify()`.132 Risk: brute-force. Fix: call `rateLimiter.check(ip)` first.133134🟢 Suggestion135- src/auth/login.ts:91 — Variable `tmp` is vague; rename `pendingSession`.136```137138### Example 2 — Security-focused audit139140> **User**: "Audit `api/search.ts` for security."141142**Agent**:1431441. Reads `api/search.ts:1-80`, checks for `req.query` usage1452. Flags: `api/search.ts:34 — String-interpolated SQL: \`SELECT ... WHERE q='${q}'\`. Use parameterized query \`db.query('SELECT ... WHERE q=$1', [q])\`` with severity 🔴 Blocking1463. Notes "No authz check needed here — endpoint is public by design" to show reasoning147148### Example 3 — Whole-module review149150> **User**: "Can you review `internal/billing/` for maintainability?"151152**Agent**:1531541. Lists files, measures per-file length, spots duplication between `invoice.ts` and `receipt.ts`1552. Recommends extracting shared `Money` value object, notes function `calculate()` at 90 lines should be split1563. Verdict: `Approve with comments` — no blocking issues, but debt will compound if not addressed157158## References159160- Complements `project-architecture` (review the architecture) and `documentation` (note missing docs flagged during review)