ai-code-reviewer
Use this skill when reviewing AI-generated code. Activate when the user has code generated by an AI assistant and wants to review it, validate AI output, check for common AI mistakes, ensure code quality of generated code, or verify that AI-generated code follows best practices before merging.
What this skill does
# AI Code Reviewer
Systematically review AI-generated code to catch common mistakes before they hit production.
## When to Use
- After AI generates code you plan to use
- Before committing AI-assisted changes
- When AI code "looks right" but you want verification
- Reviewing PRs with significant AI-generated content
## The AI Code Review Checklist
### 1. Correctness Issues (Most Common)
AI often generates code that looks correct but has subtle bugs.
**Check for:**
- [ ] **Hallucinated APIs** - Methods/functions that don't exist
```javascript
// AI might generate:
array.findLast(x => x.id === id) // Verify this exists in your target
```
- [ ] **Wrong library versions** - API changes between versions
```javascript
// React 18 vs 19 differences
// Node.js API differences
```
- [ ] **Off-by-one errors** - Loop bounds, array indices
```javascript
for (let i = 0; i <= arr.length; i++) // Should be <
```
- [ ] **Incorrect null/undefined handling**
```javascript
user.profile.name // What if profile is undefined?
```
### 2. Security Issues
AI doesn't prioritize security unless explicitly asked.
**Check for:**
- [ ] **SQL Injection**
```javascript
// BAD: AI might generate
db.query(`SELECT * FROM users WHERE id = ${userId}`)
// GOOD: Parameterized
db.query('SELECT * FROM users WHERE id = $1', [userId])
```
- [ ] **XSS Vulnerabilities**
```javascript
// BAD: Direct HTML insertion
element.innerHTML = userInput
// GOOD: Escaped or use framework
element.textContent = userInput
```
- [ ] **Exposed Secrets**
```javascript
// AI might hardcode values from context
const API_KEY = 'sk-abc123...' // Should be env var
```
- [ ] **Missing Input Validation**
```javascript
// AI often skips validation
function processData(data) {
return data.items.map(...) // What if data is null?
}
```
### 3. Performance Issues
AI optimizes for "looks correct" not "performs well."
**Check for:**
- [ ] **N+1 Queries**
```javascript
// BAD: AI loves this pattern
users.forEach(async user => {
const posts = await getPosts(user.id) // N queries!
})
// GOOD: Batch
const posts = await getPostsForUsers(userIds)
```
- [ ] **Unnecessary Re-renders (React)**
```javascript
// BAD: New object every render
<Component style={{ margin: 10 }} />
// GOOD: Stable reference
const style = useMemo(() => ({ margin: 10 }), [])
```
- [ ] **Memory Leaks**
```javascript
// BAD: Missing cleanup
useEffect(() => {
const interval = setInterval(fetch, 1000)
// No cleanup!
}, [])
// GOOD: Cleanup
useEffect(() => {
const interval = setInterval(fetch, 1000)
return () => clearInterval(interval)
}, [])
```
- [ ] **Blocking Operations**
```javascript
// BAD: Sync file operations
const data = fs.readFileSync(path)
// GOOD: Async
const data = await fs.promises.readFile(path)
```
### 4. Maintainability Issues
AI generates "works now" code, not "maintainable" code.
**Check for:**
- [ ] **Magic Numbers/Strings**
```javascript
// BAD
if (status === 3) { ... }
// GOOD
if (status === OrderStatus.SHIPPED) { ... }
```
- [ ] **Inconsistent Patterns**
```javascript
// AI might mix patterns
const getUser = async () => {} // Arrow function
async function getPost() {} // Function declaration
```
- [ ] **Missing Types (TypeScript)**
```typescript
// BAD: AI uses 'any' when uncertain
function process(data: any) { ... }
// GOOD: Proper types
function process(data: ProcessInput) { ... }
```
- [ ] **Dead Code**
```javascript
// AI sometimes includes unused variables/imports
import { unused } from './utils'
const temp = calculate() // Never used
```
### 5. Integration Issues
AI doesn't know your codebase deeply.
**Check for:**
- [ ] **Duplicate Logic** - Does similar code already exist?
- [ ] **Wrong Imports** - Using the right internal modules?
- [ ] **Naming Mismatches** - Following your conventions?
- [ ] **Missing Error Handling** - Using your error patterns?
## Review Workflow
### Step 1: Quick Scan (30 seconds)
```
- Does it compile/run?
- Any obvious red flags?
- Right general approach?
```
### Step 2: Security Review (1 minute)
```
- User input handling?
- Database queries?
- Authentication/authorization?
- Sensitive data exposure?
```
### Step 3: Logic Review (2-3 minutes)
```
- Edge cases handled?
- Null/undefined checks?
- Error scenarios?
- Loop bounds correct?
```
### Step 4: Integration Review (1-2 minutes)
```
- Follows project patterns?
- Uses existing utilities?
- Correct imports?
- Consistent naming?
```
### Step 5: Performance Review (1 minute)
```
- Obvious inefficiencies?
- Unnecessary operations?
- Memory management?
- Async patterns?
```
## Common AI Mistakes by Language
### JavaScript/TypeScript
- Missing `await` on async functions
- Wrong `this` context in callbacks
- Type assertions hiding real issues (`as any`)
- Mixing CommonJS and ESM imports
### Python
- Mutable default arguments
- Not closing file handles
- Missing `__init__.py` awareness
- Wrong exception handling scope
### React
- Missing dependency arrays in hooks
- Incorrect key props in lists
- State updates in render
- Missing cleanup in effects
### SQL
- Missing indexes awareness
- Cartesian products from bad joins
- Not using transactions
- Inefficient subqueries
## Quick Validation Commands
```bash
# TypeScript: Compile check
npx tsc --noEmit
# ESLint: Style and common errors
npx eslint src/new-file.ts
# Tests: Run affected tests
npm test -- --findRelatedTests src/new-file.ts
# Security: Quick scan
npx audit-ci --moderate
```
## When to Regenerate vs Fix
**Regenerate if:**
- Fundamental approach is wrong
- Would require 50%+ rewrite
- Security issue is systemic
**Fix manually if:**
- Small corrections needed
- Logic is sound, details wrong
- Integration issues only
## Documentation Template
When the review passes:
```markdown
## AI Code Review
**Generated by:** [Claude/GPT/etc]
**Reviewed by:** [Your name]
**Date:** [Date]
### Changes Made After Review
- Fixed null check on line 45
- Added input validation
- Replaced magic number with constant
### Verified
- [x] Security review passed
- [x] Tests added/passing
- [x] Follows project conventions
```
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.