Code Review
Review your own code like a senior engineer would review someone else's. Catch issues before they become PR comments.
Progress Checklist
Step 0: Get the Diff
# If reviewing staged changes
git diff --cached
# If reviewing branch changes
git diff main...HEAD
# Overview first
git diff --cached --stat
Step 1: Detect Tech Stack
Check changed files to determine which review patterns apply:
.ts, .tsx, .js, .jsx - Load TypeScript/JavaScript patterns
.cs, .csproj - Load .NET patterns
.go - Load Go patterns
.vue - Load Vue patterns
Load relevant issue references:
../pr-review/references/issues-general.md - Always
../pr-review/references/issues-typescript.md - If TS/JS files changed
../pr-review/references/issues-dotnet.md - If .NET files changed
../pr-review/references/issues-go.md - If Go files changed
Also load shared references:
../_shared/security-checklist.md
../_shared/performance-anti-patterns.md
../_shared/owasp-llm-top-10.md - If diff touches LLM integration code (imports from openai, anthropic, langchain, @ai-sdk, semantic-kernel, etc.)
Step 2: Review for Correctness
For each changed file:
- Does the logic actually do what it's supposed to?
- Edge cases: null/undefined, empty collections, boundary values, concurrent access
- Error handling: are errors caught where they should be? Are they swallowed silently?
- Type safety: any type assertions, unchecked casts,
any types?
- State management: race conditions, stale closures, missing cleanup
Step 3: Review for Security
Apply security checklist from shared references:
- Input validation at boundaries
- No SQL/command/HTML injection vectors
- Auth checks on protected operations
- Sensitive data not logged or exposed in errors
- No secrets in the diff
If the diff touches LLM integration code (check for imports from openai, anthropic, langchain, @ai-sdk, semantic-kernel):
- Prompt injection: user input separated from system instructions, not concatenated
- Output handling: LLM output sanitized before use in HTML, SQL, shell, or file paths
- Tool permissions: least privilege, no open-ended shell/SQL/URL tools
- System prompts: no secrets, API keys, or internal URLs embedded
- Rate limiting and token budgets on LLM endpoints
- Human approval on destructive LLM-triggered actions
See ../_shared/owasp-llm-top-10.md for detection patterns and code examples.
Step 4: Review for Performance
Apply performance patterns from shared references:
- N+1 queries in new data access code
- Missing pagination on list operations
- Unnecessary re-renders in frontend components
- Large objects passed where smaller projections would work
- Missing async/await on I/O operations
Step 5: Check Test Coverage
- New behavior should have tests
- Bug fixes should have regression tests
- Are tests testing real behavior or just mocking everything?
- Any tests that test the mock instead of the actual code?
Step 6: Report Findings
Categorize findings by severity:
| Severity |
Meaning |
Action |
| Critical |
Bug, security hole, data loss risk |
Must fix before commit |
| Important |
Logic issue, missing validation, test gap |
Should fix |
| Nit |
Style, naming, minor improvement |
Optional, mention briefly |
For each finding:
- Which file and what the issue is
- Why it matters
- Suggested fix
If no issues found, say so briefly. Don't invent problems.
After reporting, offer to fix the issues found.
1---2name: code-review3description: Performs self-review during development by checking changed code for bugs, security issues, performance problems, and test gaps. Runs inline before committing or creating PRs. Use when reviewing own code, self-review, check my changes, review before commit, review my code, code review, quality check, or when triggered by incremental-implementation before a PR.4---56# Code Review78Review your own code like a senior engineer would review someone else's. Catch issues before they become PR comments.910## Progress Checklist1112- [ ] Get the diff13- [ ] Detect tech stack14- [ ] Review for correctness15- [ ] Review for security16- [ ] Review for performance17- [ ] Check test coverage18- [ ] Report findings1920## Step 0: Get the Diff2122```bash23# If reviewing staged changes24git diff --cached2526# If reviewing branch changes27git diff main...HEAD2829# Overview first30git diff --cached --stat31```3233## Step 1: Detect Tech Stack3435Check changed files to determine which review patterns apply:3637- `.ts`, `.tsx`, `.js`, `.jsx` - Load TypeScript/JavaScript patterns38- `.cs`, `.csproj` - Load .NET patterns39- `.go` - Load Go patterns40- `.vue` - Load Vue patterns4142Load relevant issue references:43- `../pr-review/references/issues-general.md` - Always44- `../pr-review/references/issues-typescript.md` - If TS/JS files changed45- `../pr-review/references/issues-dotnet.md` - If .NET files changed46- `../pr-review/references/issues-go.md` - If Go files changed4748Also load shared references:49- `../_shared/security-checklist.md`50- `../_shared/performance-anti-patterns.md`51- `../_shared/owasp-llm-top-10.md` - If diff touches LLM integration code (imports from `openai`, `anthropic`, `langchain`, `@ai-sdk`, `semantic-kernel`, etc.)5253## Step 2: Review for Correctness5455For each changed file:5657- Does the logic actually do what it's supposed to?58- Edge cases: null/undefined, empty collections, boundary values, concurrent access59- Error handling: are errors caught where they should be? Are they swallowed silently?60- Type safety: any type assertions, unchecked casts, `any` types?61- State management: race conditions, stale closures, missing cleanup6263## Step 3: Review for Security6465Apply security checklist from shared references:6667- Input validation at boundaries68- No SQL/command/HTML injection vectors69- Auth checks on protected operations70- Sensitive data not logged or exposed in errors71- No secrets in the diff7273**If the diff touches LLM integration code** (check for imports from `openai`, `anthropic`, `langchain`, `@ai-sdk`, `semantic-kernel`):7475- Prompt injection: user input separated from system instructions, not concatenated76- Output handling: LLM output sanitized before use in HTML, SQL, shell, or file paths77- Tool permissions: least privilege, no open-ended shell/SQL/URL tools78- System prompts: no secrets, API keys, or internal URLs embedded79- Rate limiting and token budgets on LLM endpoints80- Human approval on destructive LLM-triggered actions8182See `../_shared/owasp-llm-top-10.md` for detection patterns and code examples.8384## Step 4: Review for Performance8586Apply performance patterns from shared references:8788- N+1 queries in new data access code89- Missing pagination on list operations90- Unnecessary re-renders in frontend components91- Large objects passed where smaller projections would work92- Missing async/await on I/O operations9394## Step 5: Check Test Coverage9596- New behavior should have tests97- Bug fixes should have regression tests98- Are tests testing real behavior or just mocking everything?99- Any tests that test the mock instead of the actual code?100101## Step 6: Report Findings102103Categorize findings by severity:104105| Severity | Meaning | Action |106|----------|---------|--------|107| **Critical** | Bug, security hole, data loss risk | Must fix before commit |108| **Important** | Logic issue, missing validation, test gap | Should fix |109| **Nit** | Style, naming, minor improvement | Optional, mention briefly |110111For each finding:1121. Which file and what the issue is1132. Why it matters1143. Suggested fix115116If no issues found, say so briefly. Don't invent problems.117118After reporting, offer to fix the issues found.