Agent skill
code-review-helper
Assists with code review tasks including checking style, finding bugs, suggesting improvements. Use when reviewing code, analyzing pull requests, or when user mentions code review, PR review, or code quality.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/code-review-helper
SKILL.md
Code Review Helper
Assists with systematic code review including style checking, bug detection, and improvement suggestions.
When to Use
- Reviewing pull requests
- Analyzing code quality
- Finding potential bugs
- Suggesting code improvements
- Checking style compliance
Prerequisites
- Access to the code files
- (Optional) Language-specific linters installed
Review Process
1. Quick Scan
Read through the code to understand:
- What it does
- Main components/functions
- Code organization
2. Style Check
Check for common style issues:
Python:
# If flake8 installed
flake8 filename.py
# Manual checks
# - Consistent indentation (4 spaces)
# - Descriptive variable names
# - Docstrings for functions
# - No lines > 88 characters (Black standard)
JavaScript:
# If eslint installed
npx eslint filename.js
# Manual checks
# - Consistent indentation (2 spaces typical)
# - Const/let instead of var
# - Semicolons consistent
# - CamelCase for variables, PascalCase for classes
3. Logic Review
Check for common issues:
-
Null/undefined checks: Are inputs validated?
javascript// ❌ Missing check function process(data) { return data.length; // What if data is null? } // ✓ With check function process(data) { if (!data) return 0; return data.length; } -
Error handling: Are exceptions caught?
python# ❌ No error handling def read_file(path): return open(path).read() # ✓ With error handling def read_file(path): try: return open(path).read() except FileNotFoundError: print(f"Error: {path} not found") return None -
Edge cases: Are boundary conditions handled?
python# Check for: # - Empty arrays/lists # - Zero values # - Negative numbers where unexpected # - Very large inputs
4. Security Check
Look for common security issues:
-
SQL injection (if using SQL):
python# ❌ Vulnerable query = f"SELECT * FROM users WHERE id = {user_id}" # ✓ Parameterized query = "SELECT * FROM users WHERE id = ?" cursor.execute(query, (user_id,)) -
Command injection:
python# ❌ Dangerous os.system(f"ls {user_input}") # ✓ Safe import subprocess subprocess.run(["ls", user_input]) -
Hardcoded secrets:
python# ❌ Exposed API_KEY = "sk-abc123..." # ✓ From environment API_KEY = os.environ.get("API_KEY")
5. Performance Review
Identify potential performance issues:
-
Unnecessary loops:
python# ❌ O(n²) for i in range(len(arr)): if arr[i] in arr: # Searches entire array each time ... # ✓ O(n) arr_set = set(arr) for item in arr: if item in arr_set: ... -
Resource leaks:
python# ❌ File not closed file = open("data.txt") data = file.read() # ✓ Properly closed with open("data.txt") as file: data = file.read()
6. Suggest Improvements
Look for opportunities to improve:
-
Simplification:
javascript// Before if (condition) { return true; } else { return false; } // After return condition; -
Reusability:
python# If similar code repeated, suggest extracting function # If hardcoded values repeated, suggest constants -
Readability:
python# Before if user.type == "A" or user.type == "B" or user.type == "C": # After ADMIN_TYPES = ["A", "B", "C"] if user.type in ADMIN_TYPES:
Review Checklist
For each file reviewed, check:
- Style is consistent
- Variable names are descriptive
- Functions are documented
- Edge cases are handled
- Errors are handled appropriately
- No security vulnerabilities
- No obvious performance issues
- Code is readable and maintainable
Example Review
File: utils.py
def calculate(x, y):
return x / y
Review findings:
- Missing docstring: Add description of what function does
- No type hints: Add parameter and return types
- Division by zero: Need to handle y=0 case
- Vague name: "calculate" doesn't indicate division
Suggested improvement:
def divide(x: float, y: float) -> float:
"""
Divide x by y.
Args:
x: Numerator
y: Denominator
Returns:
Result of x / y
Raises:
ValueError: If y is zero
"""
if y == 0:
raise ValueError("Cannot divide by zero")
return x / y
Common Issues by Language
Python
- Missing docstrings
- No type hints
- Not using
withfor files - Mutable default arguments
- Catching bare
except
JavaScript
- Using
varinstead ofconst/let - Missing
===(using==) - Not handling promises properly
- Missing error handling in async functions
- Not validating user inputs
TypeScript
- Using
anytype - Missing null checks
- Not leveraging type system
- Inconsistent interface usage
Go
- Not checking errors
- Not closing resources
- Using
panicunnecessarily - Not using goroutines safely
Tips
- Be constructive: Frame suggestions as improvements, not criticisms
- Prioritize: Focus on bugs and security first, style last
- Provide examples: Show how to fix issues
- Consider context: Understand the requirements before suggesting changes
- Check tests: Verify that tests exist and cover edge cases
Output Format
Structure your review as:
## Summary
Brief overview of the changes and overall code quality.
## Critical Issues
- [ ] Security vulnerabilities
- [ ] Bugs that would cause failures
- [ ] Data loss risks
## Important Issues
- [ ] Performance problems
- [ ] Error handling gaps
- [ ] Missing edge case handling
## Suggestions
- [ ] Style improvements
- [ ] Code simplifications
- [ ] Better naming
- [ ] Additional tests
## Positive Notes
What the code does well.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?