name: code-review description: Structured code review for PRs and local changes with parallel agent analysis. Use when asked to review code, check changes, audit a diff, or analyze code quality author: subinium user-invocable: true disable-model-invocation: true args: PR number or branch name (optional)
Code Review
Perform a structured code review. Supports local changes and GitHub PRs.
Instructions
If $ARGUMENTS is a PR number or URL:
- Run
gh pr diff $ARGUMENTSto get the diff - Run
gh pr view $ARGUMENTSto get PR description and metadata - Run
gh pr checks $ARGUMENTSto see CI status
If no arguments (local changes):
- Run
git diff --stagedfirst. If empty,git diff. If empty,git diff HEAD~1.
Then for all cases:
- Spawn parallel agents for efficiency:
- Agent 1: Read all changed files in full for context
- Agent 2: Run
npm run lint/npm run test/npx tsc --noEmit(if applicable)
- Review against the checklist below.
- For PRs: draft GitHub review comments using
gh apiif requested.
Output Format
## Code Review: [PR title or branch name]
### CI Status
- Lint: PASS/FAIL | Tests: PASS/FAIL | Types: PASS/FAIL
### Critical (must fix before merge)
- **[file:line]** Description
**Fix**: Suggested fix or approach
### Important (should fix)
- **[file:line]** Description
**Fix**: Suggested fix or approach
### Suggestions (nice to have)
- **[file:line]** Description
### Summary
- **Files reviewed**: N
- **Issues found**: N critical, N important, N suggestions
- **Overall**: APPROVE / REQUEST CHANGES / NEEDS DISCUSSION
/code-review vs /pr-review
| Aspect | /code-review |
/pr-review |
|---|---|---|
| Scope | Local changes (staged/unstaged/last commit) | GitHub PR (remote) |
| CI Status | Runs checks locally | Reads GitHub CI status |
| Output | Inline findings | Inline findings + optional GH review comments |
| Best For | Pre-commit quality check | Reviewing someone else's PR |
| Trigger | "review my code", "check my changes" | "review PR #123", "review this PR" |
Time Limits
- Small diff (<200 lines): Complete within 2 minutes
- Medium diff (200-1000 lines): Complete within 5 minutes
- Large diff (>1000 lines): Warn user about scope, focus on Critical/Important only, skip Suggestions
Constraints
- DO NOT modify, fix, or edit any code during the review process
- DO NOT commit any changes
- Only report findings and suggest fixes — never apply them
Checklist
Critical
- Security: SQL injection, XSS, command injection, path traversal
- Security: Hardcoded secrets, API keys, passwords
- Security: Missing authentication/authorization checks
- Data loss: Destructive operations without confirmation
- Data loss: Missing database migrations or backward compatibility
- Runtime errors: Null/undefined access, unhandled exceptions
- Breaking changes: Public API or contract changes without versioning
Important
- Type safety: Proper TypeScript types, no
any - Error handling: Meaningful error messages, proper error boundaries
- Tests: New functionality has tests, edge cases covered
- Performance: N+1 queries, unnecessary re-renders, large bundle imports
- API contracts: Breaking changes documented, backward compatible
- Accessibility: Semantic HTML, ARIA labels, keyboard navigation
- UX: Loading states, error states, empty states handled
Suggestions
- Code clarity: Naming, comments, complexity reduction
- DRY: Duplicated logic that could be extracted
- Patterns: Consistency with existing codebase patterns
- Documentation: Updated README, JSDoc for public APIs