| name | code-review |
| description | Code review practices and pull request quality standards. Use when: reviewing a pull request, preparing code for review, writing review comments, checking for common issues, establishing review guidelines, auditing an existing project's review practices, or improving PR quality standards. Integrates linting, testing, security, and CI/CD checks into a cohesive review workflow. |
| tags | ["developer"] |
Code Review Standards
When to Use
- Reviewing a pull request or diff
- Preparing your own code for review
- Writing constructive review comments
- Establishing team review conventions
- Checking code against project standards before merge
Review Priorities
Review in this order — stop at the first category with issues before nitpicking lower ones:
| Priority | Category | Questions to ask |
|---|
| 1 | Correctness | Does it do what it claims? Are edge cases handled? |
| 2 | Security | Input validation? Secret exposure? Injection? Access control? |
| 3 | Design | Right abstraction level? Follows existing patterns? Over-engineered? |
| 4 | Reliability | Error handling? Logging? Graceful degradation? |
| 5 | Performance | Obvious N+1 queries, unbounded loops, or missing indexes? |
| 6 | Readability | Clear names? Minimal complexity? Would a new team member understand? |
| 7 | Style | Formatting, naming conventions, import order (should be caught by linters) |
Don't review style manually — that's what linters and formatters enforce in CI. If CI passes lint, style is not a review concern.
What CI Should Catch (Not Reviewers)
These should fail the build automatically — don't waste review time on them:
| Check | CI tool | Reference |
|---|
| Code formatting | Ruff format / Prettier | linting skills |
| Lint violations | Ruff / ESLint | linting skills |
| Type errors | mypy / TypeScript strict | python / typescript skills |
| Test failures | pytest / vitest | testing skill |
| Coverage regression | pytest-cov --cov-fail-under | cicd skill |
| Known vulnerabilities | pip audit / npm audit | security skill |
Reviewer Checklist
Use as a mental model during review. Not every point applies to every PR.
Logic & Correctness
Security
Design
Testing
Operations
Writing Review Comments
Be Specific
# Bad
"This doesn't look right."
# Good
"This will throw a KeyError if `user_data` doesn't contain 'email'.
Consider using `user_data.get('email')` or validating the field upstream."
Categorize Comments
Prefix comments to signal intent:
| Prefix | Meaning |
|---|
| blocker: | Must fix before merge. Correctness, security, or data loss risk. |
| suggestion: | Improvement idea. Take it or leave it. |
| question: | Genuine question — I don't understand the intent. |
| nit: | Minor style preference. Not worth blocking on. |
| praise: | Something done well. Positive reinforcement matters. |
Rules for Reviewers
- Approve when it's good enough, not when it's perfect. Perfect is the enemy of shipped.
- Limit to one round of blocker feedback — if you keep finding new blockers, the PR is too large.
- Don't rewrite their code — describe the problem and trust the author to solve it.
- Respond within one business day — stale PRs are costly.
- Prefer questions over commands — "Have you considered X?" is better than "Do X."
Rules for Authors
- Keep PRs small — under 400 lines of meaningful diff. Split large changes into stacked PRs.
- Write a clear PR description — what changed, why, and how to test it.
- Self-review before requesting — read your own diff. Catch the obvious stuff yourself.
- Don't force-push after review — reviewers lose context. Use fixup commits, squash at merge.
PR Size Guidelines
| Lines changed | Assessment | Action |
|---|
| < 100 | Ideal | Fast to review, easy to understand |
| 100 – 400 | Acceptable | Should have a clear description |
| 400 – 800 | Too large | Split if possible |
| > 800 | Unacceptable | Must be split. No reviewer can effectively review this. |
Exceptions: auto-generated code, migrations, dependency lockfile updates.
PR Description Template
## What
Brief description of the change.
## Why
Link to issue or explain the motivation.
## How
Key design decisions and approach taken.
## Testing
How to verify the change works:
- [ ] Unit tests pass
- [ ] Manual testing steps (if applicable)
## Checklist
- [ ] Lint / format passes
- [ ] Tests added for new behavior
- [ ] No secrets in code
- [ ] Documentation updated (if user-facing)