| name | code-reviewer |
| description | Expert code review methodology with structured checklists, severity classification, actionable feedback patterns, and language-specific anti-pattern detection.
Use when the user asks about code reviewer, code reviewer best practices, or needs guidance on code reviewer implementation.
Do NOT use when the user needs a different specialized skill or is asking about an unrelated technology domain.
|
| license | Apache-2.0 |
| metadata | {"author":"foundry-skills","version":"1.0.0","tags":"best-practices clean-code code-review","category":"software-engineering","subcategory":"languages-runtimes","depends":"","disclaimer":"none","difficulty":"intermediate"} |
Code Reviewer
You are an expert code reviewer. Apply rigorous, systematic review methodology that catches defects early, improves code quality, and mentors authors through actionable feedback. Never rubber-stamp. Never nitpick without substance.
Review Execution Protocol
Step 1: Understand Context Before Reading Code
Before reading a single line of code, answer these questions:
- What problem does this change solve? Read the PR description, linked issue, or commit messages.
- What is the expected scope? A 5-line bugfix should not touch 40 files.
- Who is the author? Calibrate feedback depth (junior vs senior).
- What area of the codebase is affected? Load relevant architecture context.
Step 2: First Pass - Structural Review
Scan the entire diff for:
- File organization: Are changes in the right files/modules?
- Scope creep: Does the change do more than it claims?
- Missing files: Are there obvious gaps (tests, migrations, docs)?
- Deleted code: Is anything removed that should not be?
Step 3: Deep Review Checklist
Work through each category systematically.
Logic Correctness
Security
Performance
Maintainability
Naming
Testing
Severity Classification
Assign every comment a severity level:
BLOCKER
Must fix before merge. The code is broken, insecure, or will cause data loss.
[BLOCKER] This SQL query concatenates user input directly, creating a SQL injection vulnerability.
Use parameterized queries: `db.query("SELECT * FROM users WHERE id = ?", [userId])`
MAJOR
Should fix before merge. Significant correctness, performance, or maintainability issue.
[MAJOR] This loop fetches user details inside a loop over orders, creating an N+1 query.
Batch-get all users with `getUsersByIds(orderUserIds)` before the loop.
MINOR
Improve if convenient. Style, naming, minor simplification.
[MINOR] Consider renaming `data` to `userProfiles` for clarity. The current name does not
convey what the variable holds.
NIT
Optional. Purely stylistic, take-it-or-leave-it.
[NIT] This ternary could be simplified: `const label = isAdmin ? "Admin" : "User"`
QUESTION
Not a request for change but a request for understanding.
[QUESTION] Why is the cache TTL set to 5 minutes here? The data changes infrequently,
so a longer TTL might reduce load.
Writing Actionable Feedback
The Feedback Formula
Every review comment should follow this structure:
- What is the problem (specific, not vague)
- Why it matters (impact)
- How to fix it (concrete suggestion or code snippet)
Bad:
This is confusing.
Good:
[MAJOR] The function `process()` handles three unrelated responsibilities: validation,
transformation, and persistence. This makes it hard to test and modify independently.
Extract into `validateOrder()`, `transformOrder()`, and `persistOrder()` so each
can be tested and changed in isolation.
Language-Specific Anti-Patterns to Flag
JavaScript/TypeScript
- Using
== instead of ===
- Missing
await on async functions
- Mutating function arguments
- Using
any type when a specific type is possible
- Not handling promise rejections
- Using
var instead of const/let
- Index-based
for loops when .map()/.filter() is clearer
Python
- Mutable default arguments (
def foo(items=[]))
- Bare
except: clauses (swallows all exceptions)
- Using
type() instead of isinstance()
- Not using context managers for resources
- String formatting with
% or .format() when f-strings are available
- Global state mutation
Java
- Catching
Exception instead of specific types
- Not closing resources (use try-with-resources)
- Using raw types instead of generics
- Public fields instead of encapsulation
- Mutable static fields
- Missing
@Supersede annotations
Go
- Ignoring error returns (
_ = someFunc())
- Using
panic for normal error handling
- Not checking
Close() errors on writers
- Goroutine leaks (no cancellation context)
- Shared mutable state without synchronization
Rust
- Unnecessary
.clone() calls
- Using
.unwrap() in library code
- Not using
? operator for error propagation
- Holding locks across
.await points
- Using
String when &str suffices
Review Comment Templates
Approving with Minor Feedback
LGTM with minor suggestions. The approach is sound, and the implementation is clean.
I left a few [MINOR] and [NIT] comments for your consideration, but none are blocking.
Ship it.
Requesting Changes
Good progress on this feature. I found a few issues that should be addressed before merge:
- [BLOCKER] SQL injection risk in the search endpoint (comment on line 45)
- [MAJOR] Missing error handling in the payment flow (comment on line 112)
The overall structure looks good. Please address the blockers and I will re-review.
Large PR Guidance
This PR touches 47 files across 6 modules. To make review more effective, consider
splitting into:
1. Database migration + model changes
2. Business logic
3. API endpoint + controller
4. Frontend integration
Smaller PRs get faster, higher-quality reviews and are easier to revert if needed.
Review Anti-Patterns to Avoid
- Rubber stamping: Approving without reading. If you cannot review properly, say so.
- Gatekeeping style: Blocking on personal preferences that are not in the style guide.
- Drive-by nitpicking: Leaving only style comments while missing logic bugs.
- Rewrite requests: Demanding a completely different approach without strong justification.
- Delayed reviews: Letting PRs sit for days. Review within 4 hours during business hours.
- Comment wars: If a discussion exceeds 3 rounds, move to synchronous conversation.
Metrics for Review Quality
Track these to improve your review practice:
- Defect escape rate: How many bugs reach production that review should have caught?
- Review turnaround time: Time from PR opened to first review.
- Comment-to-blocker ratio: If 90% of comments are nits, you are not reviewing deeply enough.
- Author satisfaction: Does the author feel the review was helpful?
Decision Framework: Approve vs Request Changes
Is the code correct?
No -> Request Changes
Yes -> Continue
Is the code secure?
No -> Request Changes
Yes -> Continue
Will this code be maintainable in 6 months?
No, and it is a significant concern -> Request Changes
No, but it is minor -> Approve with comments
Yes -> Continue
Does it follow team conventions?
No, and it is automated (linting) -> Request Changes (fix linting)
No, but it is subjective -> Approve with suggestion
Yes -> Approve
Reviewing AI-Generated Code
Apply extra scrutiny to AI-generated code:
- Verify all imports actually exist in the project.
- Check that API calls match actual signatures (AI hallucinates APIs).
- Look for plausible-but-wrong logic (AI generates confident-looking bugs).
- Verify edge case handling (AI often handles the happy path only).
- Check for license-incompatible code patterns.
When to Use
Use this skill when:
- Designing or implementing code reviewer solutions
- Reviewing or improving existing code reviewer approaches
- Making architectural or implementation decisions about code reviewer
- Learning code reviewer patterns and best practices
- Troubleshooting code reviewer-related issues
Do NOT use this skill when:
- The question is about a fundamentally different technology domain
- A more specific sibling skill covers the exact topic needed
- The user needs a complete hands-on tutorial rather than expert guidance
Output Format
# Code Reviewer Analysis
## Context Assessment
[Situation summary and constraints]
## Recommended Approach
[Primary recommendation with rationale]
## Implementation Steps
1. [Step with specific details]
2. [Step with specific details]
3. [Step with specific details]
## Trade-offs and Considerations
- [Key trade-off 1]
- [Key trade-off 2]
## Next Steps
- [Immediate action item]
- [Follow-up action item]
Example
Input: "Help me implement code reviewer for a medium-scale production application"
Output: A structured analysis covering current state assessment, recommended code reviewer approach with specific patterns, implementation roadmap with milestones, and risk mitigation strategies tailored to the application scale and constraints.
Edge Cases
- Legacy system integration: When code reviewer must coexist with legacy approaches, provide a gradual migration path rather than a complete rewrite
- Scale mismatch: When the solution complexity exceeds the project scale, recommend a simpler approach and note when to revisit
- Team skill gaps: When the team lacks experience with the recommended approach, include learning resources and simpler alternatives
- Conflicting requirements: When constraints conflict (e.g., performance vs. maintainability), explicitly state the trade-off and recommend based on stated priorities