Review code changes by delegating to specialist agents and synthesizing a unified report. Works with PRs, staged changes, or specific files.
Step 1: Determine Scope
Parse $ARGUMENTS to determine what to review:
- PR number (e.g.,
123 or #123): fetch with gh pr view $ARGUMENTS. This is the full PR review path (includes PR quality checks in Step 2).
- No argument: try
gh pr view to detect a PR for the current branch. If a PR exists, use it. If not, fall back to git diff --cached (staged), then git diff (unstaged).
staged: review git diff --cached. If nothing staged, fall back to git diff.
- File path: review that specific file's current state.
If there are no changes to review, say so and stop.
Step 2: PR Quality Check (PR path only)
Skip this step if reviewing staged changes or a file — jump to Step 3.
When reviewing a PR, fetch and check:
- PR title, description/body, author, base branch, head branch
gh pr diff $NUMBER for the full diff
gh pr checks $NUMBER for CI status
gh api repos/{owner}/{repo}/pulls/$NUMBER/comments for review comments
Review the PR itself before the code:
- Title: descriptive and under 72 chars?
- Description: explains the why? Includes a test plan? Flag if empty or template-only.
- Size: count changed files and lines. Flag if >500 lines changed (suggest splitting).
- Base branch: targeting the right branch?
- CI status: passing, failing, or pending? If failing, note which checks — fix CI first.
- Unresolved comments: list open review threads with file:line and comment text.
Step 3: Code Review (delegate to agents)
- Always: delegate the diff to
@code-reviewer
- If security-sensitive code changed — auth, input handling, queries, tokens, session management, file path construction: delegate to
@security-reviewer
- If performance-sensitive code changed — endpoints, DB queries, loops over collections, caching, connection management: delegate to
@performance-reviewer. Skip if changes are only docs, config, tests, or static assets.
- If documentation changed — .md files, significant docstring/JSDoc changes, API docs: delegate to
@doc-reviewer
Determine relevance by reading the diff content, not just file paths.
Step 4: Synthesize Report
For PR reviews:
## PR Review: #[number] — [title]
**Author**: [author] | **Base**: [base] → **Head**: [head] | **Changed**: [N files, +X/-Y lines]
### PR Quality
- Title: [ok / needs improvement]
- Description: [ok / missing test plan / empty]
- Size: [ok / large — consider splitting]
- CI: [passing / failing — list failures]
- Unresolved comments: [none / list]
### Code Review
#### Critical / High
- [Agent] File:Line — issue
#### Medium
- [Agent] File:Line — issue
#### Low
- [Agent] File:Line — issue
### Verdict
[Ready to merge / Needs changes — summarize blockers]
For non-PR reviews (staged/file):
## Review Summary
**Scope**: [staged changes / file path]
**Agents run**: [list]
### Critical / High
- [Agent] File:Line — issue
### Medium / Low
- [Agent] File:Line — issue
### Passed
- [areas with no issues]
Deduplicate findings that overlap between agents. Attribute each finding to the agent that found it.
1---2name: pr-review3description: Review code changes or a pull request — delegates to specialist agents for code quality, security, performance, and documentation.4---56Review code changes by delegating to specialist agents and synthesizing a unified report. Works with PRs, staged changes, or specific files.78## Step 1: Determine Scope910Parse `$ARGUMENTS` to determine what to review:1112- **PR number** (e.g., `123` or `#123`): fetch with `gh pr view $ARGUMENTS`. This is the full PR review path (includes PR quality checks in Step 2).13- **No argument**: try `gh pr view` to detect a PR for the current branch. If a PR exists, use it. If not, fall back to `git diff --cached` (staged), then `git diff` (unstaged).14- **`staged`**: review `git diff --cached`. If nothing staged, fall back to `git diff`.15- **File path**: review that specific file's current state.1617If there are no changes to review, say so and stop.1819## Step 2: PR Quality Check (PR path only)2021Skip this step if reviewing staged changes or a file — jump to Step 3.2223When reviewing a PR, fetch and check:24- PR title, description/body, author, base branch, head branch25- `gh pr diff $NUMBER` for the full diff26- `gh pr checks $NUMBER` for CI status27- `gh api repos/{owner}/{repo}/pulls/$NUMBER/comments` for review comments2829Review the PR itself before the code:30- **Title**: descriptive and under 72 chars?31- **Description**: explains the *why*? Includes a test plan? Flag if empty or template-only.32- **Size**: count changed files and lines. Flag if >500 lines changed (suggest splitting).33- **Base branch**: targeting the right branch?34- **CI status**: passing, failing, or pending? If failing, note which checks — fix CI first.35- **Unresolved comments**: list open review threads with file:line and comment text.3637## Step 3: Code Review (delegate to agents)38391. **Always**: delegate the diff to `@code-reviewer`402. **If security-sensitive code changed** — auth, input handling, queries, tokens, session management, file path construction: delegate to `@security-reviewer`413. **If performance-sensitive code changed** — endpoints, DB queries, loops over collections, caching, connection management: delegate to `@performance-reviewer`. Skip if changes are only docs, config, tests, or static assets.424. **If documentation changed** — .md files, significant docstring/JSDoc changes, API docs: delegate to `@doc-reviewer`4344Determine relevance by reading the diff content, not just file paths.4546## Step 4: Synthesize Report4748For PR reviews:49```50## PR Review: #[number] — [title]5152**Author**: [author] | **Base**: [base] → **Head**: [head] | **Changed**: [N files, +X/-Y lines]5354### PR Quality55- Title: [ok / needs improvement]56- Description: [ok / missing test plan / empty]57- Size: [ok / large — consider splitting]58- CI: [passing / failing — list failures]59- Unresolved comments: [none / list]6061### Code Review62#### Critical / High63- [Agent] File:Line — issue6465#### Medium66- [Agent] File:Line — issue6768#### Low69- [Agent] File:Line — issue7071### Verdict72[Ready to merge / Needs changes — summarize blockers]73```7475For non-PR reviews (staged/file):76```77## Review Summary7879**Scope**: [staged changes / file path]80**Agents run**: [list]8182### Critical / High83- [Agent] File:Line — issue8485### Medium / Low86- [Agent] File:Line — issue8788### Passed89- [areas with no issues]90```9192Deduplicate findings that overlap between agents. Attribute each finding to the agent that found it.