---
name: code-review
description: Comprehensive code review for quality, security, and maintainability
---

# Code Review Skill

Conduct a thorough code review with severity-rated feedback.

## When to Use

- Before merging a pull request
- After implementing a major feature
- When assessing code quality
- To find security issues

## Review Workflow

1. Run `git diff` to see changes
2. Focus on modified files
3. Check each category below
4. Provide severity-rated feedback

## Review Checklist

### Security Checks (CRITICAL)
- [ ] No hardcoded credentials (API keys, passwords, tokens)
- [ ] No SQL injection risks (string concatenation in queries)
- [ ] No XSS vulnerabilities (unescaped user input)
- [ ] Input validation present
- [ ] No path traversal risks

### Code Quality (HIGH)
- [ ] Functions are reasonable size (<50 lines)
- [ ] Files are reasonable size (<800 lines)
- [ ] No deep nesting (>4 levels)
- [ ] Error handling present
- [ ] No debug logging left in

### Performance (MEDIUM)
- [ ] Efficient algorithms
- [ ] No N+1 query patterns
- [ ] Appropriate caching

### Best Practices (LOW)
- [ ] Clear variable naming
- [ ] No magic numbers
- [ ] Consistent formatting

## Output Format

For each issue:
```
[SEVERITY] Issue Title
File: path/to/file.ts:42
Issue: Description of the problem
Fix: How to fix it
```

## Severity Levels

| Severity | Description | Action |
|----------|-------------|--------|
| CRITICAL | Security vulnerability | Must fix before merge |
| HIGH | Bug or major code smell | Should fix before merge |
| MEDIUM | Minor issue | Fix when possible |
| LOW | Style/suggestion | Consider fixing |

## Approval Criteria

- **APPROVE**: No CRITICAL or HIGH issues
- **REQUEST CHANGES**: CRITICAL or HIGH issues found
- **COMMENT**: Only MEDIUM/LOW issues

## Summary Format

```markdown
## Code Review Summary

**Files Reviewed:** X
**Total Issues:** Y

### By Severity
- CRITICAL: X
- HIGH: Y
- MEDIUM: Z
- LOW: W

### Recommendation
APPROVE / REQUEST CHANGES / COMMENT
```
