internal/templates/commands/bodies/review.md
Review code and provide a structured assessment with grading.
Arguments: $ARGUMENTS
Determine the diff to review based on arguments:
| Argument | Diff command | Use case |
|---|---|---|
| (none) | git diff + git diff --staged | Review uncommitted + staged changes |
--staged | git diff --staged | Review only staged changes |
--branch | git diff origin/<base>...HEAD | Review branch diff vs base branch |
--pr <url> | gh pr diff <url> | Review a GitHub PR |
Based on the arguments, run the appropriate diff command:
# Default (no args): uncommitted + staged
DIFF=$(git diff; git diff --staged)
# --staged: only staged
DIFF=$(git diff --staged)
# --branch: branch diff (detect base branch)
BASE=$(git rev-parse --abbrev-ref HEAD@{upstream} 2>/dev/null | sed 's|origin/||' || git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||' || echo "main")
DIFF=$(git diff origin/$BASE...HEAD)
# --pr <url>: PR diff
DIFF=$(gh pr diff <url>)
If the diff is empty, report "No changes to review" and stop.
Review the diff systematically. For each issue found, classify by severity:
CRITICAL - Must fix before merge:
MAJOR - Should fix before merge:
MINOR - Nice to fix:
For each issue, note:
Grade is determined by the highest severity issue found:
| Grade | Criteria | Verdict |
|---|---|---|
| A | No CRITICAL, MAJOR, or MINOR issues | PASS |
| B | MINOR issues only (no CRITICAL or MAJOR) | PASS |
| C | MAJOR issues present (no CRITICAL) | FAIL |
| D | CRITICAL issues present | FAIL |
| F | Unreviewable (empty diff, binary files, generated code only) | SKIP |
Output the review in this exact format:
Grade: <A|B|C|D|F>
CRITICAL (<count> issues)
<file>:<line> — <description>
Suggested fix: <actionable fix>
MAJOR (<count> issues)
<file>:<line> — <description>
Suggested fix: <actionable fix>
MINOR (<count> issues)
<file>:<line> — <description>
Suggested fix: <actionable fix>
Summary: <N> CRITICAL, <N> MAJOR, <N> MINOR
Verdict: <PASS|FAIL|SKIP>
Omit empty severity sections (e.g., if no CRITICAL issues, don't print the CRITICAL section).
If Grade is A, output:
Grade: A
No issues found.
Summary: 0 CRITICAL, 0 MAJOR, 0 MINOR
Verdict: PASS