Conduct comprehensive code reviews identifying bugs, security issues, performance problems, code quality concerns, and best practice violations. Use when reviewing pull requests, examining code changes, evaluating new code, assessing code quality, or providing feedback on implementations. Analyzes code for correctness, security vulnerabilities, performance bottlenecks, maintainability issues, test coverage, documentation quality, and adherence to coding standards. Produces structured markdown reviews with categorized findings, severity ratings, specific examples, and actionable recommendations. Triggers when users ask to review code, check pull requests, evaluate implementations, find bugs, or assess code quality.
88
88%
Does it follow best practices?
Impact
83%
1.25xAverage score across 3 eval scenarios
Passed
No known issues
Perform thorough, constructive code reviews that identify issues, suggest improvements, and ensure code quality, security, and maintainability.
Examine code across these dimensions:
Gather information:
For PRs:
# View PR diff
gh pr diff <PR-NUMBER>
# View PR description
gh pr view <PR-NUMBER>
# See changed files
git diff --name-only main..HEADFirst pass - high level:
Second pass - detailed:
Categorize findings by severity:
🔴 Critical: Must fix before merge
🟡 Important: Should fix before merge
🔵 Minor: Nice to have
💡 Suggestion: Optional improvements
Structure feedback constructively:
For each issue:
Tone guidelines:
# Code Review: [PR Title / Code Description]
## Summary
- **Files Reviewed:** X files, Y lines changed
- **Overall Assessment:** [Approve/Request Changes/Comment]
- **Critical Issues:** N
- **Important Issues:** M
- **Minor Issues:** K
---
## 🔴 Critical Issues
### Issue 1: [Title]
**Location:** `path/to/file.py:42`
**Problem:**
[Clear description of the issue]
**Impact:**
[Why this is critical - security, data loss, crashes, etc.]
**Recommendation:**
[Specific fix needed]
**Example:**
```python
# Current (problematic)
user_input = request.GET['id']
query = f"SELECT * FROM users WHERE id = {user_input}"
# Suggested (fixed)
user_input = request.GET.get('id')
if user_input and user_input.isdigit():
query = "SELECT * FROM users WHERE id = %s"
cursor.execute(query, (user_input,))[Same structure as above]
[Shorter format acceptable for minor issues]
Overall: [Approve with suggestions / Request changes / Needs discussion]
## Common Issues by Language
### Python
```python
# ❌ Mutable default argument
def append_to(element, to=[]): # Bug: to persists across calls
to.append(element)
return to
# ✅ Correct
def append_to(element, to=None):
if to is None:
to = []
to.append(element)
return to
# ❌ Catching bare exceptions
try:
risky_operation()
except: # Too broad, masks errors
pass
# ✅ Specific exception handling
try:
risky_operation()
except ValueError as e:
logger.error(f"Invalid value: {e}")
raise
# ❌ String concatenation in loops
result = ""
for item in items:
result += str(item) # Creates new string each iteration
# ✅ Use join
result = "".join(str(item) for item in items)// ❌ == instead of ===
if (value == null) { // Loose equality
// ...
}
// ✅ Strict equality
if (value === null || value === undefined) {
// ...
}
// ❌ Unhandled promise rejection
fetchData().then(data => process(data));
// ✅ Error handling
fetchData()
.then(data => process(data))
.catch(error => console.error('Error:', error));
// ❌ Variable shadowing
const name = "Global";
function greet() {
const name = "Local"; // Shadows outer name
console.log(name);
}
// ✅ Distinct names
const globalName = "Global";
function greet() {
const userName = "User";
console.log(userName);
}// ❌ Resource leak
public void readFile(String path) {
FileInputStream fis = new FileInputStream(path);
// ... use fis
// Missing close(), leaks file handle
}
// ✅ Try-with-resources
public void readFile(String path) {
try (FileInputStream fis = new FileInputStream(path)) {
// ... use fis
} // Automatically closed
}
// ❌ Using == for String comparison
if (str == "value") { // Compares references
// ...
}
// ✅ Use equals()
if ("value".equals(str)) { // Compares content, null-safe
// ...
}Input Validation:
SQL Injection:
XSS Prevention:
Authentication/Authorization:
Data Protection:
Algorithm Complexity:
Database:
Caching:
Memory:
Function/Method Size:
Complexity:
DRY (Don't Repeat Yourself):
Naming:
Coverage:
Test Quality:
Test Types:
### 🔴 Critical: SQL Injection Vulnerability
**Location:** `api/users.py:45`
**Problem:**
User input is directly interpolated into SQL query without sanitization.
**Impact:**
Attacker could execute arbitrary SQL commands, leading to data breach or data loss.
**Code:**
```python
# Current (VULNERABLE)
def get_user(user_id):
query = f"SELECT * FROM users WHERE id = {user_id}"
return db.execute(query)Recommendation: Use parameterized queries to prevent SQL injection.
Fix:
def get_user(user_id):
query = "SELECT * FROM users WHERE id = %s"
return db.execute(query, (user_id,))### Example 2: Performance Issue
```markdown
### 🟡 Important: N+1 Query Problem
**Location:** `services/order_service.py:78-82`
**Problem:**
Loading users in a loop creates N+1 database queries.
**Impact:**
For 100 orders, this creates 101 queries (1 + 100), severely impacting performance.
**Code:**
```python
# Current (inefficient)
orders = Order.query.all()
for order in orders:
order.user = User.query.get(order.user_id) # N queriesRecommendation: Use eager loading or a single query with join.
Fix:
# Option 1: Eager loading
orders = Order.query.options(joinedload(Order.user)).all()
# Option 2: Separate query
orders = Order.query.all()
user_ids = [o.user_id for o in orders]
users = {u.id: u for u in User.query.filter(User.id.in_(user_ids)).all()}
for order in orders:
order.user = users[order.user_id]## Tips for Effective Reviews
**Be constructive:**
- Explain why, not just what
- Suggest solutions, don't just criticize
- Acknowledge good code
**Be specific:**
- Point to exact lines
- Provide code examples
- Quantify impact when possible
**Prioritize:**
- Fix critical issues first
- Don't nitpick minor style issues
- Focus on what matters
**Ask questions:**
- "Could you explain the reasoning behind...?"
- "Have you considered...?"
- "What happens if...?"
**Provide context:**
- Link to documentation
- Reference coding standards
- Cite security best practices
**Be timely:**
- Review promptly
- Don't block unnecessarily
- Iterate in conversations
This skill provides comprehensive code review guidance. Save it to the current path when ready to package.0f00a4f
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.