Code Review
When to Use
- The user shares code (file, snippet, or diff) and asks for feedback
- They paste a pull request or want to know if code is production-ready
- Pre-merge quality gate or bug hunting
- Reviewing architectural decisions in a PR
Context Required
From startup-context: tech stack, product stage, team size. Also need from the user:
- The code or diff to review
- What the code is supposed to do (PR purpose or feature context)
- Any specific concerns (performance, security, correctness)
- Language and framework if not obvious from the code
Workflow
Follow a structured five-step methodology. Each step must be completed before moving to the next.
- Context — Understand and summarize the PR's purpose before any analysis. Recap the intent back to the user in 1-2 sentences. If unclear, ask before proceeding. Never start reviewing without understanding what the code is trying to accomplish.
- Structure — Evaluate architectural decisions and design patterns:
- Does the code belong in the right module/layer?
- Are abstractions appropriate (not too many, not too few)?
- Does this change align with the existing codebase patterns?
- For non-obvious design choices, acknowledge the author's reasoning before proposing alternatives.
- Details — Assess code quality across multiple dimensions:
- Correctness: Logic errors, off-by-one bugs, null/undefined handling, race conditions, edge cases
- Security: OWASP Top 10 baseline — injection, broken auth, data exposure, XSS, access control, misconfig, insecure deserialization, vulnerable components
- Performance: N+1 queries, unnecessary re-renders, O(n^2) on large datasets, missing caching, memory leaks
- Naming and clarity: Do names communicate intent? Are functions focused on a single responsibility?
- Tests — Validate test coverage with equal rigor as code review:
- Are behavioral assertions present (not just implementation testing)?
- Are edge cases and error paths covered?
- Are tests brittle or resilient to refactoring?
- What test cases are missing?
- Feedback — Generate a prioritized, categorized report with specific code examples and concrete improvements. Recognize strong patterns and good decisions explicitly.
Output Format
# Code Review: [Feature/File Name]
## Summary
One-paragraph assessment: what the PR does, whether it is ready to merge, needs minor fixes, or needs rework.
## Findings
### Critical (must fix before merge)
- **[CRT-1] Title** — file:line — description, why it matters, suggested fix with code example
### Major (should fix before merge)
- **[MAJ-1] Title** — file:line — description, why it matters, suggested fix
### Minor (fix when convenient)
- **[MIN-1] Title** — file:line — description, suggestion
### Positive (things done well)
- **[POS-1] Title** — file:line — what was done well and why it matters
## Questions
Clarifying questions about non-obvious design choices before blocking on them.
## Suggested Tests
- Test case 1
- Test case 2
Frameworks & Best Practices
Severity Definitions
| Severity |
Definition |
Action |
| Critical |
Security vulnerability, data loss risk, crash in production, broken core functionality |
Block merge |
| Major |
Significant bug, performance regression, missing error handling on critical path, architectural violation |
Should fix before merge |
| Minor |
Style issue, naming improvement, minor optimization, documentation gap |
Fix when convenient |
| Positive |
Well-written code, good pattern usage, thoughtful error handling |
Acknowledge and reinforce |
Review Principles
- Always ground feedback in specifics. Every finding must reference a file, line, and include a concrete improvement — not just "this could be better."
- Recognize good work explicitly. Call out strong patterns, clean abstractions, and thoughtful error handling. Reviews that only flag problems are demoralizing and incomplete.
- Acknowledge author reasoning. For non-obvious choices, assume the author had a reason. Ask before overriding. Phrase as "I see you chose X — was that because of Y? If so, consider Z as an alternative."
- Do not block on style when automated tooling handles it. Linting and formatting are the job of CI, not reviewers. Focus on logic, architecture, and correctness.
- Treat test review with equal weight. Tests are not an afterthought. Missing tests for critical paths is a major finding, not a minor one.
OWASP Top 10 Quick Checks
- Injection — Are user inputs parameterized? Check SQL, NoSQL, OS command, LDAP
- Broken Auth — Sessions secure? Tokens rotated? Passwords hashed (bcrypt/argon2)?
- Sensitive Data Exposure — Secrets in env vars (not code)? PII encrypted at rest?
- XXE — XML parsing disabled or configured to reject external entities?
- Broken Access Control — Every endpoint checks authorization, not just authentication?
- Misconfiguration — Debug modes off? CORS restrictive? Security headers set?
- XSS — Outputs encoded? No
dangerouslySetInnerHTML / v-html with user data?
- Insecure Deserialization — Serialized objects from untrusted sources validated?
- Vulnerable Components — Dependencies up to date? Any known CVEs?
- Insufficient Logging — Auth failures, access violations, and errors logged?
N+1 Query Detection
- Looping over a collection and making a DB call per item
- ORM lazy loading inside a loop (e.g.,
user.posts in a for user in users loop)
- GraphQL resolvers fetching related data per parent without DataLoader
- Fix: Eager loading, batch queries, or DataLoader pattern
Language-Agnostic Red Flags
- Functions longer than 40 lines or more than 3 levels of nesting
- Boolean params that change behavior (use separate functions)
- Catch blocks that swallow exceptions silently
- Hardcoded values that should be configuration
- Missing input validation on public API boundaries
Related Skills
security-review — chain for a deep-dive security audit when critical security findings surface
architecture-design — chain when code review reveals structural problems that need architectural rethinking
Examples
Example prompt: "Review this Express route handler for creating users."
Good output snippet:
# Code Review: POST /api/users Handler
## Summary
The handler creates users but has a critical SQL injection vulnerability and missing
input validation. Needs fixes before merge. Clean async/await usage is a positive.
## Findings
### Critical
- **[CRT-1] SQL Injection** — routes/users.js:14 — Email interpolated
directly into SQL string. Use parameterized queries:
`db.query('INSERT INTO users (email) VALUES ($1)', [email])`
### Major
- **[MAJ-1] No input validation** — routes/users.js:12 — Email from
`req.body` used with no validation. Add zod/joi schema validation.
- **[MAJ-2] Missing error handling** — routes/users.js:18 — DB errors
propagate as 500 with stack trace. Wrap in try/catch, return generic error.
### Positive
- **[POS-1] Clean async/await** — routes/users.js:11 — Easy to follow,
no callback nesting.
## Questions
- Is there a validation middleware already in the project that should be reused here?
1---
2name: code-review
3description: When the user asks for a code review, shares code for feedback, or says "review this", "check my code", "what's wrong with this". Also activate when reviewing a pull request or diff.
4related: [security-review, architecture-design]
5reads: [startup-context]
6origin: "startup"
7metadata:
8 source: https://skillmd.com/skills/yanacuti1121/code-review
9---
10
11# Code Review
12
13## When to Use
14- The user shares code (file, snippet, or diff) and asks for feedback
15- They paste a pull request or want to know if code is production-ready
16- Pre-merge quality gate or bug hunting
17- Reviewing architectural decisions in a PR
18
19## Context Required
20From `startup-context`: tech stack, product stage, team size. Also need from the user:
21- The code or diff to review
22- What the code is supposed to do (PR purpose or feature context)
23- Any specific concerns (performance, security, correctness)
24- Language and framework if not obvious from the code
25
26## Workflow
27Follow a structured five-step methodology. Each step must be completed before moving to the next.
28
291. **Context** — Understand and summarize the PR's purpose before any analysis. Recap the intent back to the user in 1-2 sentences. If unclear, ask before proceeding. Never start reviewing without understanding what the code is trying to accomplish.
302. **Structure** — Evaluate architectural decisions and design patterns:
31 - Does the code belong in the right module/layer?
32 - Are abstractions appropriate (not too many, not too few)?
33 - Does this change align with the existing codebase patterns?
34 - For non-obvious design choices, acknowledge the author's reasoning before proposing alternatives.
353. **Details** — Assess code quality across multiple dimensions:
36 - **Correctness:** Logic errors, off-by-one bugs, null/undefined handling, race conditions, edge cases
37 - **Security:** OWASP Top 10 baseline — injection, broken auth, data exposure, XSS, access control, misconfig, insecure deserialization, vulnerable components
38 - **Performance:** N+1 queries, unnecessary re-renders, O(n^2) on large datasets, missing caching, memory leaks
39 - **Naming and clarity:** Do names communicate intent? Are functions focused on a single responsibility?
404. **Tests** — Validate test coverage with equal rigor as code review:
41 - Are behavioral assertions present (not just implementation testing)?
42 - Are edge cases and error paths covered?
43 - Are tests brittle or resilient to refactoring?
44 - What test cases are missing?
455. **Feedback** — Generate a prioritized, categorized report with specific code examples and concrete improvements. Recognize strong patterns and good decisions explicitly.
46
47## Output Format
48
49```markdown
50# Code Review: [Feature/File Name]
51
52## Summary
53One-paragraph assessment: what the PR does, whether it is ready to merge, needs minor fixes, or needs rework.
54
55## Findings
56
57### Critical (must fix before merge)
58- **[CRT-1] Title** — file:line — description, why it matters, suggested fix with code example
59
60### Major (should fix before merge)
61- **[MAJ-1] Title** — file:line — description, why it matters, suggested fix
62
63### Minor (fix when convenient)
64- **[MIN-1] Title** — file:line — description, suggestion
65
66### Positive (things done well)
67- **[POS-1] Title** — file:line — what was done well and why it matters
68
69## Questions
70Clarifying questions about non-obvious design choices before blocking on them.
71
72## Suggested Tests
73- Test case 1
74- Test case 2
75```
76
77## Frameworks & Best Practices
78
79### Severity Definitions
80| Severity | Definition | Action |
81|----------|-----------|--------|
82| **Critical** | Security vulnerability, data loss risk, crash in production, broken core functionality | Block merge |
83| **Major** | Significant bug, performance regression, missing error handling on critical path, architectural violation | Should fix before merge |
84| **Minor** | Style issue, naming improvement, minor optimization, documentation gap | Fix when convenient |
85| **Positive** | Well-written code, good pattern usage, thoughtful error handling | Acknowledge and reinforce |
86
87### Review Principles
88- **Always ground feedback in specifics.** Every finding must reference a file, line, and include a concrete improvement — not just "this could be better."
89- **Recognize good work explicitly.** Call out strong patterns, clean abstractions, and thoughtful error handling. Reviews that only flag problems are demoralizing and incomplete.
90- **Acknowledge author reasoning.** For non-obvious choices, assume the author had a reason. Ask before overriding. Phrase as "I see you chose X — was that because of Y? If so, consider Z as an alternative."
91- **Do not block on style when automated tooling handles it.** Linting and formatting are the job of CI, not reviewers. Focus on logic, architecture, and correctness.
92- **Treat test review with equal weight.** Tests are not an afterthought. Missing tests for critical paths is a major finding, not a minor one.
93
94### OWASP Top 10 Quick Checks
951. **Injection** — Are user inputs parameterized? Check SQL, NoSQL, OS command, LDAP
962. **Broken Auth** — Sessions secure? Tokens rotated? Passwords hashed (bcrypt/argon2)?
973. **Sensitive Data Exposure** — Secrets in env vars (not code)? PII encrypted at rest?
984. **XXE** — XML parsing disabled or configured to reject external entities?
995. **Broken Access Control** — Every endpoint checks authorization, not just authentication?
1006. **Misconfiguration** — Debug modes off? CORS restrictive? Security headers set?
1017. **XSS** — Outputs encoded? No `dangerouslySetInnerHTML` / `v-html` with user data?
1028. **Insecure Deserialization** — Serialized objects from untrusted sources validated?
1039. **Vulnerable Components** — Dependencies up to date? Any known CVEs?
10410. **Insufficient Logging** — Auth failures, access violations, and errors logged?
105
106### N+1 Query Detection
107- Looping over a collection and making a DB call per item
108- ORM lazy loading inside a loop (e.g., `user.posts` in a `for user in users` loop)
109- GraphQL resolvers fetching related data per parent without DataLoader
110- **Fix:** Eager loading, batch queries, or DataLoader pattern
111
112### Language-Agnostic Red Flags
113- Functions longer than 40 lines or more than 3 levels of nesting
114- Boolean params that change behavior (use separate functions)
115- Catch blocks that swallow exceptions silently
116- Hardcoded values that should be configuration
117- Missing input validation on public API boundaries
118
119## Related Skills
120- `security-review` — chain for a deep-dive security audit when critical security findings surface
121- `architecture-design` — chain when code review reveals structural problems that need architectural rethinking
122
123## Examples
124
125**Example prompt:** "Review this Express route handler for creating users."
126
127**Good output snippet:**
128```
129# Code Review: POST /api/users Handler
130
131## Summary
132The handler creates users but has a critical SQL injection vulnerability and missing
133input validation. Needs fixes before merge. Clean async/await usage is a positive.
134
135## Findings
136### Critical
137- **[CRT-1] SQL Injection** — routes/users.js:14 — Email interpolated
138 directly into SQL string. Use parameterized queries:
139 `db.query('INSERT INTO users (email) VALUES ($1)', [email])`
140
141### Major
142- **[MAJ-1] No input validation** — routes/users.js:12 — Email from
143 `req.body` used with no validation. Add zod/joi schema validation.
144- **[MAJ-2] Missing error handling** — routes/users.js:18 — DB errors
145 propagate as 500 with stack trace. Wrap in try/catch, return generic error.
146
147### Positive
148- **[POS-1] Clean async/await** — routes/users.js:11 — Easy to follow,
149 no callback nesting.
150
151## Questions
152- Is there a validation middleware already in the project that should be reused here?
153```