Skill: Code Review Agent
Review Checklist (priority order)
P0 — Security (block PR)
P1 — Correctness (block PR)
P2 — Performance (flag, don't block)
P3 — Maintainability (suggest)
Language-Specific Patterns
Rust
// ❌ Unwrap in production code
let value = option.unwrap(); // panics on None
// ✅ Propagate errors properly
let value = option.context("value was None")?;
// ❌ String format for SQL
let query = format!("SELECT * FROM users WHERE id = {}", id);
// ✅ Parameterized (sqlx example)
let user = sqlx::query_as!(User, "SELECT * FROM users WHERE id = $1", id)
.fetch_one(&pool).await?;
Python
# ❌ Shell injection
os.system(f"grep {user_input} file.txt")
# ✅ Safe subprocess
subprocess.run(["grep", user_input, "file.txt"], capture_output=True, text=True)
# ❌ Pickle with untrusted data
data = pickle.loads(untrusted_bytes) # RCE vector
# ✅ Use json for untrusted data
data = json.loads(untrusted_string)
TypeScript/JavaScript
// ❌ XSS
element.innerHTML = userInput;
// ✅ Safe
element.textContent = userInput;
// or DOMPurify.sanitize(userInput) for rich HTML
// ❌ Prototype pollution
const merged = { ...defaultConfig, ...userInput }; // dangerous if userInput has __proto__
// ✅ Safe merge
const merged = Object.assign(Object.create(null), defaultConfig, userInput);
Review Prompt Template
Review this [language] code for:
1. Security vulnerabilities (OWASP Top 10)
2. Logic errors and edge cases
3. Performance issues
4. Maintainability concerns
For each finding, provide:
- Severity: CRITICAL / HIGH / MEDIUM / LOW
- Location: file:line
- Issue: what's wrong
- Fix: specific corrected code
Code to review:
<code>
{code}
</code>
PR Review Summary Format
## Code Review Summary
**Risk Level**: 🔴 CRITICAL / 🟠 HIGH / 🟡 MEDIUM / 🟢 LOW
### 🔴 Security Issues (must fix before merge)
- [file.rs:42] Hardcoded API key — move to env var
- [auth.py:15] Missing authorization check
### 🟠 Correctness Issues
- [handler.ts:78] Off-by-one in pagination (use < not <=)
### 🟡 Performance Suggestions
- [db.rs:34] N+1 query pattern — use JOIN or batch fetch
### 🟢 Style/Maintainability
- [utils.py:12] Function too long (89 lines), split by responsibility
**Verdict**: ❌ Changes Required / ✅ Approved with suggestions / ✅ Approved
1---2name: code-review-agent3description: Systematic AI-powered code review. USE when: reviewing PRs, auditing code quality, checking for security vulnerabilities, validating architecture, analyzing Rust/Python/JS/TS code, reviewing config files, or when the user says "review this code", "check this PR", "find bugs", "is this code safe". Covers: security (OWASP), performance, maintainability, correctness. Optimized for fast review with Haiku 4.5.4---56# Skill: Code Review Agent78## Review Checklist (priority order)910### P0 — Security (block PR)11- [ ] No hardcoded secrets, API keys, passwords, tokens12- [ ] No SQL injection: use parameterized queries, not string concatenation13- [ ] No command injection: no `os.system(user_input)`, shell=True with untrusted data14- [ ] No XSS: output is escaped for HTML contexts15- [ ] No path traversal: `../` in user-controlled paths16- [ ] No SSRF: user-controlled URLs fetched without allowlist17- [ ] No insecure deserialization of untrusted data18- [ ] Authentication/authorization checks present for sensitive operations19- [ ] No prompt injection vectors (for AI-integrated code)2021### P1 — Correctness (block PR)22- [ ] Logic matches the stated intent23- [ ] Edge cases handled: empty inputs, None/null, overflow, concurrent access24- [ ] Error handling: errors don't swallow failures silently25- [ ] Tests cover the happy path + at least 2 edge cases26- [ ] No off-by-one errors in loops/slices2728### P2 — Performance (flag, don't block)29- [ ] No N+1 queries (check loops with DB calls inside)30- [ ] No unnecessary allocations in hot paths31- [ ] Async/await used correctly (no blocking calls in async context)32- [ ] Indexes exist for queried columns3334### P3 — Maintainability (suggest)35- [ ] Functions < 50 lines, single responsibility36- [ ] No magic numbers (use named constants)37- [ ] Meaningful names: `user_email` not `ue`, `calculate_tax` not `proc`38- [ ] Public APIs have docstrings/comments39- [ ] No dead code, no TODO without ticket reference4041## Language-Specific Patterns4243### Rust44```rust45// ❌ Unwrap in production code46let value = option.unwrap(); // panics on None4748// ✅ Propagate errors properly49let value = option.context("value was None")?;5051// ❌ String format for SQL52let query = format!("SELECT * FROM users WHERE id = {}", id);5354// ✅ Parameterized (sqlx example)55let user = sqlx::query_as!(User, "SELECT * FROM users WHERE id = $1", id)56 .fetch_one(&pool).await?;57```5859### Python60```python61# ❌ Shell injection62os.system(f"grep {user_input} file.txt")6364# ✅ Safe subprocess65subprocess.run(["grep", user_input, "file.txt"], capture_output=True, text=True)6667# ❌ Pickle with untrusted data68data = pickle.loads(untrusted_bytes) # RCE vector6970# ✅ Use json for untrusted data71data = json.loads(untrusted_string)72```7374### TypeScript/JavaScript75```typescript76// ❌ XSS77element.innerHTML = userInput;7879// ✅ Safe80element.textContent = userInput;81// or DOMPurify.sanitize(userInput) for rich HTML8283// ❌ Prototype pollution84const merged = { ...defaultConfig, ...userInput }; // dangerous if userInput has __proto__8586// ✅ Safe merge87const merged = Object.assign(Object.create(null), defaultConfig, userInput);88```8990## Review Prompt Template9192```93Review this [language] code for:941. Security vulnerabilities (OWASP Top 10)952. Logic errors and edge cases963. Performance issues974. Maintainability concerns9899For each finding, provide:100- Severity: CRITICAL / HIGH / MEDIUM / LOW101- Location: file:line102- Issue: what's wrong103- Fix: specific corrected code104105Code to review:106<code>107{code}108</code>109```110111## PR Review Summary Format112113```markdown114## Code Review Summary115116**Risk Level**: 🔴 CRITICAL / 🟠 HIGH / 🟡 MEDIUM / 🟢 LOW117118### 🔴 Security Issues (must fix before merge)119- [file.rs:42] Hardcoded API key — move to env var120- [auth.py:15] Missing authorization check121122### 🟠 Correctness Issues123- [handler.ts:78] Off-by-one in pagination (use < not <=)124125### 🟡 Performance Suggestions126- [db.rs:34] N+1 query pattern — use JOIN or batch fetch127128### 🟢 Style/Maintainability129- [utils.py:12] Function too long (89 lines), split by responsibility130131**Verdict**: ❌ Changes Required / ✅ Approved with suggestions / ✅ Approved132```