Code Review Skill
Overview
A structured, language-agnostic code review process that identifies bugs, security issues, performance problems, and style violations. Always produces actionable output with severity ratings.
Review Process
Step 1: Read Before Commenting
Read the entire code block before writing any feedback. Understanding the full context prevents false positives and surface-level comments.
Step 2: Identify the Language and Context
Note the language, framework, and apparent purpose. Calibrate expectations accordingly (e.g., prototype vs. production, CLI script vs. library).
Step 3: Check for Correctness
- Logic errors and off-by-one bugs
- Unhandled edge cases (null/None, empty collections, negative numbers)
- Incorrect operator precedence or type coercion
- Missing error handling at I/O boundaries
- Race conditions in concurrent code
Step 4: Check for Security Issues
Scan specifically for:
- Injection: SQL injection, shell injection, SSTI, XSS
- Hardcoded secrets: API keys, passwords, tokens in source
- Insecure deserialization:
pickle.loads, eval, exec on user input
- Path traversal: user-controlled file paths without sanitization
- Weak cryptography: MD5/SHA1 for passwords, ECB mode, short keys
- IDOR: direct object references without authorization checks
- SSRF: user-controlled URLs in outbound HTTP requests
Step 5: Check for Performance Issues
- N+1 query patterns (database calls inside loops)
- Unnecessary copying of large data structures
- Missing indexes on frequently-queried fields
- Blocking I/O on async event loops
- Redundant computations that could be cached
Step 6: Check for Maintainability
- Unclear variable or function names
- Functions longer than ~50 lines (flag, don't mandate splitting)
- Missing or incorrect type annotations (for typed languages)
- Magic numbers without named constants
- Dead code or unused imports
Step 7: Write Structured Findings
Use this format for each finding:
[SEVERITY] Category: Title
File: path/to/file.py, Line: N
Issue: One sentence describing the problem.
Impact: What could go wrong.
Fix:
<corrected code snippet>
Severity levels:
- CRITICAL: Data loss, RCE, auth bypass, secret exposure
- HIGH: Security vulnerability, data corruption, crash in production
- MEDIUM: Logic bug, incorrect behavior in edge cases
- LOW: Style, naming, missing docs, minor inefficiency
- INFO: Suggestion or alternative approach
Step 8: Provide a Summary
End with:
- Overall assessment (1-2 sentences)
- Count of findings by severity
- Top 3 priority fixes
Rules
- Only flag real issues - don't rewrite working code to apply style preferences
- Cite exact line numbers when possible
- Explain WHY each issue matters, not just what it is
- For security findings, show the attack scenario
- Provide corrected code for CRITICAL/HIGH findings; optional for LOW/INFO
1---2name: code-review3description: Review code for correctness, bugs, security vulnerabilities, performance issues, and best practices. Produces structured findings with severity ratings and concrete fixes. Use when the user asks to review code, check for bugs, find security issues, audit code quality, or get a second opinion on an implementation.4license: Apache-2.05---67# Code Review Skill89## Overview10A structured, language-agnostic code review process that identifies bugs, security issues, performance problems, and style violations. Always produces actionable output with severity ratings.1112## Review Process1314### Step 1: Read Before Commenting15Read the entire code block before writing any feedback. Understanding the full context prevents false positives and surface-level comments.1617### Step 2: Identify the Language and Context18Note the language, framework, and apparent purpose. Calibrate expectations accordingly (e.g., prototype vs. production, CLI script vs. library).1920### Step 3: Check for Correctness21- Logic errors and off-by-one bugs22- Unhandled edge cases (null/None, empty collections, negative numbers)23- Incorrect operator precedence or type coercion24- Missing error handling at I/O boundaries25- Race conditions in concurrent code2627### Step 4: Check for Security Issues28Scan specifically for:29- **Injection**: SQL injection, shell injection, SSTI, XSS30- **Hardcoded secrets**: API keys, passwords, tokens in source31- **Insecure deserialization**: `pickle.loads`, `eval`, `exec` on user input32- **Path traversal**: user-controlled file paths without sanitization33- **Weak cryptography**: MD5/SHA1 for passwords, ECB mode, short keys34- **IDOR**: direct object references without authorization checks35- **SSRF**: user-controlled URLs in outbound HTTP requests3637### Step 5: Check for Performance Issues38- N+1 query patterns (database calls inside loops)39- Unnecessary copying of large data structures40- Missing indexes on frequently-queried fields41- Blocking I/O on async event loops42- Redundant computations that could be cached4344### Step 6: Check for Maintainability45- Unclear variable or function names46- Functions longer than ~50 lines (flag, don't mandate splitting)47- Missing or incorrect type annotations (for typed languages)48- Magic numbers without named constants49- Dead code or unused imports5051### Step 7: Write Structured Findings5253Use this format for each finding:54```55[SEVERITY] Category: Title56File: path/to/file.py, Line: N57Issue: One sentence describing the problem.58Impact: What could go wrong.59Fix:60 <corrected code snippet>61```6263Severity levels:64- **CRITICAL**: Data loss, RCE, auth bypass, secret exposure65- **HIGH**: Security vulnerability, data corruption, crash in production66- **MEDIUM**: Logic bug, incorrect behavior in edge cases67- **LOW**: Style, naming, missing docs, minor inefficiency68- **INFO**: Suggestion or alternative approach6970### Step 8: Provide a Summary7172End with:73- Overall assessment (1-2 sentences)74- Count of findings by severity75- Top 3 priority fixes7677## Rules78- Only flag real issues - don't rewrite working code to apply style preferences79- Cite exact line numbers when possible80- Explain WHY each issue matters, not just what it is81- For security findings, show the attack scenario82- Provide corrected code for CRITICAL/HIGH findings; optional for LOW/INFO