Review Agent
The ephemeral agent that analyzes pull requests — fetching diffs, classifying risk, and providing AI-powered code review with optional auto-approve.
Review Agent
The Review Agent provides automated code review for pull requests. It fetches the PR data and diff from GitHub, sends it to Claude Sonnet for analysis, classifies the risk level, and can auto-approve low-risk PRs when the project's autonomy level permits.
Characteristics
| Property | Value |
|---|---|
| Lifecycle | Ephemeral — spawned per review, terminates on completion |
| Spawned by | Project Agent, on review command or PR webhook events |
| AI Model | Claude Sonnet (configurable via REVIEW_MODEL) |
| Color | Channel Purple (#8B5CF6) |
How It Works
Step 1: Fetch PR Data
The Review Agent uses the GitHub API to fetch the pull request metadata and changed files:
Step 2: Risk Classification
The Review Agent classifies every PR into one of three risk levels based on objective metrics:
Risk Level Criteria
| Risk | File Count | Line Changes | Sensitive Patterns | Example |
|---|---|---|---|---|
| Low | 1–3 files | < 100 lines | No | Typo fix, CSS tweak, config update |
| Medium | 4–10 files | 100–500 lines | No | Feature implementation, refactor |
| High | > 10 files | > 500 lines | Yes | Architecture change, migration, security |
Sensitive File Patterns
The following patterns automatically escalate risk to high:
Step 3: Claude Analysis
The PR data and diff are sent to Claude Sonnet for a comprehensive code review:
Review Output Structure
Step 4: Auto-Approve (Conditional)
At autonomy level L3 or higher, the Review Agent can auto-approve low-risk PRs without human intervention:
Auto-Approve Matrix
| Autonomy Level | Low Risk | Medium Risk | High Risk |
|---|---|---|---|
| L0–L2 | Review only | Review only | Review only |
| L3 | Auto-approve | Review only | Review only |
| L4 | Auto-approve | Auto-approve | Review only |
| L5 | Auto-approve | Auto-approve | Review only |
High-risk PRs are never auto-approved regardless of autonomy level.
Example Interaction
Review with Issues
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
ANTHROPIC_API_KEY | Yes | — | Anthropic API key for Claude analysis |
REVIEW_MODEL | No | claude-sonnet-4-20250514 | Claude model to use for code review |
GITHUB_TOKEN | Yes | — | GitHub token for fetching PR data |
Limitations
- The Review Agent reviews the diff only, not the entire codebase. It may miss issues that require broader context.
- Auto-approve decisions are based on heuristic risk classification. The line/file thresholds are configurable but not context-aware.
- Binary files and generated code are skipped in the review.
- Very large PRs (>500 files) are truncated to fit within Claude's context window, with a note indicating the truncation.