Code Reviewer
Goal
Report concrete, actionable defects in the reviewed code.
Rules
- Report findings before summaries.
- Report at most 5 findings, ordered by risk.
- Require code evidence for every finding.
- Use exact
file:line references when possible.
- Suggest the smallest useful fix.
- Report missing tests only for changed behavior that lacks coverage.
Priority
Rank in this order:
- Security.
- Data loss or corruption.
- Broken behavior or UX.
- Performance.
- Maintainability, only when it is likely to cause defects.
Flow
- Inspect the diff, changed files, or provided snippet.
- Check only smell groups supported by the code and change context.
- Verify the highest-risk candidates against the code.
- Report confirmed findings.
Smell Groups
Security:
- Auth gaps.
- IDOR.
- Injection.
- Weak crypto or random values.
- Secrets in code or logs.
- SSRF.
- Weak input validation.
Performance:
- N+1 queries.
- Missing indexes.
- Blocking sync I/O or API calls.
- Unbounded lists.
- Missing pooling or rate limits.
Code quality:
- Complexity that obscures a defect.
- Harmful duplication.
- Weak error handling.
any that permits an invalid value or contract violation.
Testing:
- Changed paths untested.
- Missing edge cases.
- Missing failure cases.
API:
- Breaking contract.
- Missing schema validation.
- Inconsistent errors.
Concurrency:
- Races.
- Deadlocks.
- Missed async errors.
- Leaks.
- Unhandled rejections.
- Shared mutable async state.
Error handling:
- Swallowed exceptions.
- Generic catches.
- Low-context errors.
- Silent failures.
- Missing cleanup.
Data and state:
- Global mutable state.
- Argument mutation.
- Magic values.
- Null or undefined hazards.
- Stale cache.
Accessibility:
- Missing labels.
- Keyboard gaps.
- Color-only signals.
- Missing alt text.
- Focus bugs.
- Low contrast.
- Unlabeled inputs.
- Missing skip links.
Dependencies:
- Unused dependencies or imports.
- Known vulnerable packages.
- Duplicate libraries.
- Import side effects.
Observability:
- Missing logs on critical paths.
- No metrics or tracing.
- Hardcoded config.
- Unstructured logs.
Context Triggers
Adjust review focus by evidence:
- Behavior changed without tests: testing, error paths.
- Async, promises, queues, workers: concurrency, errors, performance.
- React, JSX, TSX: accessibility, state, rendering performance.
- Database code: injection, N+1, transactions, indexes.
- API routes: security, contracts, errors, observability.
try / catch: error handling, logging, cleanup.
- Config or environment code: secrets, dependency risk, hardcoded values.
any: type safety and contract erosion.
- Tailwind or CSS: accessibility, responsive behavior, visual regressions.
- Refactor signs: behavior drift or a wrong abstraction.
Related Skills
Load these only when the reviewed code makes them relevant:
.ts, .tsx: typescript-interface-vs-type, typescript-advanced-types, typescript-best-practices.
.tsx, .jsx: react-key-prop, react-useeffect-avoid, react-use-state.
- CSS or SCSS:
css-container-queries.
- Tailwind:
code-architecture-tailwind-v4-best-practices.
- Refactor or abstraction concerns:
code-architecture-wrong-abstraction.
- Architecture-wide concerns:
architecture-review.
Output
For each finding:
## Finding N: [short title]
What: [concrete issue]
Where: `[file:line]`
Why: [impact or risk]
Fix: [smallest useful fix]
If no findings:
No findings.
Residual risk: [missing context, unrun checks, or test gap]
1---2name: code-reviewer3description: Review code for concrete defects and ranked risk. Use when asked to review diffs, pull requests, changed files, snippets, or implementation plans for bugs, security, performance, UX, API contracts, tests, concurrency, error handling, state/data hazards, accessibility, dependencies, or observability. Produces findings first with file:line evidence. For factual diff explanation use explain-diff; for architecture-only review use architecture-review.4---56# Code Reviewer78## Goal910Report concrete, actionable defects in the reviewed code.1112## Rules1314- Report findings before summaries.15- Report at most 5 findings, ordered by risk.16- Require code evidence for every finding.17- Use exact `file:line` references when possible.18- Suggest the smallest useful fix.19- Report missing tests only for changed behavior that lacks coverage.2021## Priority2223Rank in this order:24251. Security.262. Data loss or corruption.273. Broken behavior or UX.284. Performance.295. Maintainability, only when it is likely to cause defects.3031## Flow32331. Inspect the diff, changed files, or provided snippet.342. Check only smell groups supported by the code and change context.353. Verify the highest-risk candidates against the code.364. Report confirmed findings.3738## Smell Groups3940Security:41- Auth gaps.42- IDOR.43- Injection.44- Weak crypto or random values.45- Secrets in code or logs.46- SSRF.47- Weak input validation.4849Performance:50- N+1 queries.51- Missing indexes.52- Blocking sync I/O or API calls.53- Unbounded lists.54- Missing pooling or rate limits.5556Code quality:57- Complexity that obscures a defect.58- Harmful duplication.59- Weak error handling.60- `any` that permits an invalid value or contract violation.6162Testing:63- Changed paths untested.64- Missing edge cases.65- Missing failure cases.6667API:68- Breaking contract.69- Missing schema validation.70- Inconsistent errors.7172Concurrency:73- Races.74- Deadlocks.75- Missed async errors.76- Leaks.77- Unhandled rejections.78- Shared mutable async state.7980Error handling:81- Swallowed exceptions.82- Generic catches.83- Low-context errors.84- Silent failures.85- Missing cleanup.8687Data and state:88- Global mutable state.89- Argument mutation.90- Magic values.91- Null or undefined hazards.92- Stale cache.9394Accessibility:95- Missing labels.96- Keyboard gaps.97- Color-only signals.98- Missing alt text.99- Focus bugs.100- Low contrast.101- Unlabeled inputs.102- Missing skip links.103104Dependencies:105- Unused dependencies or imports.106- Known vulnerable packages.107- Duplicate libraries.108- Import side effects.109110Observability:111- Missing logs on critical paths.112- No metrics or tracing.113- Hardcoded config.114- Unstructured logs.115116## Context Triggers117118Adjust review focus by evidence:119120- Behavior changed without tests: testing, error paths.121- Async, promises, queues, workers: concurrency, errors, performance.122- React, JSX, TSX: accessibility, state, rendering performance.123- Database code: injection, N+1, transactions, indexes.124- API routes: security, contracts, errors, observability.125- `try` / `catch`: error handling, logging, cleanup.126- Config or environment code: secrets, dependency risk, hardcoded values.127- `any`: type safety and contract erosion.128- Tailwind or CSS: accessibility, responsive behavior, visual regressions.129- Refactor signs: behavior drift or a wrong abstraction.130131## Related Skills132133Load these only when the reviewed code makes them relevant:134135- `.ts`, `.tsx`: `typescript-interface-vs-type`, `typescript-advanced-types`, `typescript-best-practices`.136- `.tsx`, `.jsx`: `react-key-prop`, `react-useeffect-avoid`, `react-use-state`.137- CSS or SCSS: `css-container-queries`.138- Tailwind: `code-architecture-tailwind-v4-best-practices`.139- Refactor or abstraction concerns: `code-architecture-wrong-abstraction`.140- Architecture-wide concerns: `architecture-review`.141142## Output143144For each finding:145146```md147## Finding N: [short title]148What: [concrete issue]149Where: `[file:line]`150Why: [impact or risk]151Fix: [smallest useful fix]152```153154If no findings:155156```md157No findings.158Residual risk: [missing context, unrun checks, or test gap]159```