Back to Gastown

Default (no args): uncommitted + staged

internal/templates/commands/bodies/review.md

1.0.13.0 KB
Original Source

Review code and provide a structured assessment with grading.

Arguments: $ARGUMENTS

Diff Source Resolution

Determine the diff to review based on arguments:

ArgumentDiff commandUse case
(none)git diff + git diff --stagedReview uncommitted + staged changes
--stagedgit diff --stagedReview only staged changes
--branchgit diff origin/<base>...HEADReview branch diff vs base branch
--pr <url>gh pr diff <url>Review a GitHub PR

Step 1: Get the diff

Based on the arguments, run the appropriate diff command:

bash
# 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.

Step 2: Review the diff

Review the diff systematically. For each issue found, classify by severity:

CRITICAL - Must fix before merge:

  • Security vulnerabilities (injection, auth bypass, secrets in code)
  • Data loss risks (missing transactions, unsafe deletes)
  • Correctness bugs (race conditions, nil dereference, logic errors)

MAJOR - Should fix before merge:

  • Logic errors that may not crash but produce wrong results
  • Missing error handling on external calls
  • API contract violations
  • Missing tests for critical paths

MINOR - Nice to fix:

  • Style inconsistencies with surrounding code
  • Naming issues (unclear or misleading names)
  • Missing comments on non-obvious logic
  • Minor code smells

For each issue, note:

  • File and line number
  • Severity (CRITICAL, MAJOR, MINOR)
  • Description of the issue
  • Suggested fix (specific, actionable)

Step 3: Assign grade

Grade is determined by the highest severity issue found:

GradeCriteriaVerdict
ANo CRITICAL, MAJOR, or MINOR issuesPASS
BMINOR issues only (no CRITICAL or MAJOR)PASS
CMAJOR issues present (no CRITICAL)FAIL
DCRITICAL issues presentFAIL
FUnreviewable (empty diff, binary files, generated code only)SKIP

Step 4: Output structured review

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