Perform thorough AI-powered code reviews on pull requests or local changes. Analyzes diffs for bugs, security vulnerabilities, performance issues, maintainability concerns, and style violations. Provides actionable, specific feedback — not generic advice.
"Review the current PR"
"Review the changes on this branch vs main"
"Review these specific files for security issues"
"Do a deep review of the authentication changes"
Collect the diff and context:
# PR review
gh pr diff <number> --color=never
# Branch review
git diff main...HEAD
# Staged changes
git diff --cached
Also gather:
Each pass focuses on a different concern:
Pass 1 — Correctness:
Pass 2 — Security:
Pass 3 — Performance:
Pass 4 — Maintainability:
Pass 5 — Testing:
Each finding gets a severity:
Every comment includes:
Overall assessment with:
## Code Review Summary
**Risk Level:** 🟡 Needs Changes (2 must-fix, 4 should-fix)
**Files Reviewed:** 12 files, +342/-89 lines
### 🔴 Must Fix
1. **SQL Injection in user search** — `src/api/users.ts:47`
The search query interpolates user input directly:
```typescript
// Current (vulnerable)
db.query(`SELECT * FROM users WHERE name LIKE '%${query}%'`)
// Fix: use parameterized query
db.query('SELECT * FROM users WHERE name LIKE $1', [`%${query}%`])
```
2. **Race condition in balance update** — `src/services/wallet.ts:112-118`
Read-then-write without transaction. Two concurrent requests
can both read the same balance and overwrite each other.
Fix: wrap in a database transaction with SELECT FOR UPDATE.
### 🟡 Should Fix
3. **N+1 query in order listing** — `src/api/orders.ts:23`
Each order triggers a separate query for user details.
Use a JOIN or batch load users by ID.
4. **Missing error handling** — `src/services/payment.ts:67`
API call result is not checked for errors before accessing `.data`.
[...]
### 👍 Good Stuff
- Clean separation of concerns in the new service layer
- Comprehensive input validation on the registration endpoint
- Good use of TypeScript discriminated unions for payment status
### 📋 Follow-up (non-blocking)
- Consider adding request rate limiting to the search endpoint
- The `formatDate` utility is duplicated in 3 files — extract to shared utils
The review depth adapts to PR size:
Works with:
gh CLI)glab CLI)git diff)git apply --stat)共 1 个版本