| name | code-review |
| description | Use when: reviewing GitHub PR via gh CLI, scale-adaptive strategy |
| allowed-tools | Bash, Read, Grep, Glob |
| triggers | ["code-review","/code-review","review PR","PR review"] |
Code Review: Scale-Adaptive GitHub PR Review
Role Detection (READ THIS FIRST -- MANDATORY)
Check your initial prompt. If it contains the literal string "Use the code-review skill", then:
YOU ARE THE EXECUTOR. Follow these rules:
- SKIP the "Execution Protocol" section below -- it is for the orchestrator, not you.
- Read the pattern at
../../PATTERN.md relative to this SKILL.md, and follow it step by step.
- ABSOLUTE PROHIBITION: Do NOT run
csa run, csa review, csa debate, or ANY csa command. You must perform the work DIRECTLY. Running any csa command causes infinite recursion.
Only if you are the main agent (Claude Code / human user):
- You are the orchestrator. Follow the "Execution Protocol" steps below.
Purpose
Perform AI-powered code review on GitHub PRs with automatic scale adaptation. Small PRs (< 200 lines) are reviewed directly; large PRs (> 800 lines) are delegated to CSA. Includes authorship detection to use adversarial debate for self-authored code, and mandatory AGENTS.md compliance checking for all changed files.
Execution Protocol (ORCHESTRATOR ONLY)
Prerequisites
- PR number must be known or discoverable
Quick Start
csa run --sa-mode true --skill code-review "Review PR #<number>"
SA Mode Propagation (MANDATORY)
When operating under SA mode (e.g., dispatched by /sa or any autonomous workflow),
ALL csa invocations MUST include --sa-mode true. This includes csa run,
csa review, csa debate, and any other execution commands. Omitting --sa-mode
at root depth causes a hard error; passing false when the caller is in SA mode
breaks prompt-guard propagation.
Step-by-Step
- Fetch PR context: Use
gh pr view and gh pr diff --stat to get metadata and diff statistics.
- Assess scale: Small (< 200 lines) = direct review. Medium (200-800) = direct with progress. Large (> 800) = delegate to
csa review.
- Authorship check: If Co-Authored-By matches caller model family, use
csa debate instead of direct review.
- For large PRs: Checkout PR branch locally, run
csa review --branch <base>. Do NOT pre-read diff.
- For small/medium PRs: Fetch full diff via
gh pr diff, analyze each file for quality, security, performance, and language-specific issues.
- AGENTS.md compliance: Discover AGENTS.md chain for each changed file. Check every applicable rule. Violations are P2+; MUST/CRITICAL rules are P1.
- Generate review: Produce structured output (summary, critical issues, suggestions, nitpicks, questions, AGENTS.md checklist).
- Post review (optional): Submit as PR comment via
gh pr comment only when user explicitly requests.
Example Usage
| Command | Effect |
|---|
/code-review 42 | Review PR #42 with auto scale detection |
/code-review 42 post=true | Review and post comment to the PR |
/code-review scope=base:main | Review current branch changes vs main |
Integration
- May use:
csa-review (for large PRs), debate (for self-authored code arbitration)
- Used by:
pr-bot (as part of PR review loop)
Done Criteria
- PR metadata and diff statistics fetched successfully.
- Scale-appropriate review strategy selected and executed.
- If large PR: delegated to CSA review (not read into main agent context).
- If self-authored: adversarial debate review used instead of standard review.
- AGENTS.md compliance checklist generated with all applicable rules checked.
- Structured review output produced (summary, issues, suggestions, checklist).
- If post=true: review comment posted to PR via
gh pr comment.