mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-07 22:16:52 +02:00
b4c33261c7
Step 1.5: Before reviewing code quality, check if the diff matches stated intent. Flags scope creep and missing requirements (INFORMATIONAL). Step 5 addition: Every review claim must cite evidence — "this pattern is safe" needs a line reference, "tests cover this" needs a test name. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
176 lines
8.2 KiB
Cheetah
176 lines
8.2 KiB
Cheetah
---
|
|
name: review
|
|
version: 1.0.0
|
|
description: |
|
|
Pre-landing PR review. Analyzes diff against main for SQL safety, LLM trust
|
|
boundary violations, conditional side effects, and other structural issues.
|
|
allowed-tools:
|
|
- Bash
|
|
- Read
|
|
- Edit
|
|
- Write
|
|
- Grep
|
|
- Glob
|
|
- AskUserQuestion
|
|
---
|
|
|
|
{{PREAMBLE}}
|
|
|
|
# Pre-Landing PR Review
|
|
|
|
You are running the `/review` workflow. Analyze the current branch's diff against main for structural issues that tests don't catch.
|
|
|
|
---
|
|
|
|
## Step 1: Check branch
|
|
|
|
1. Run `git branch --show-current` to get the current branch.
|
|
2. If on `main`, output: **"Nothing to review — you're on main or have no changes against main."** and stop.
|
|
3. Run `git fetch origin main --quiet && git diff origin/main --stat` to check if there's a diff. If no diff, output the same message and stop.
|
|
|
|
---
|
|
|
|
## Step 1.5: Scope Drift Detection
|
|
|
|
Before reviewing code quality, check: **did they build what was requested — nothing more, nothing less?**
|
|
|
|
1. Read `TODOS.md` (if it exists). Read PR description (`gh pr view --json body --jq .body 2>/dev/null || true`).
|
|
Read commit messages (`git log origin/main..HEAD --oneline`).
|
|
**If no PR exists:** rely on commit messages and TODOS.md for stated intent — this is the common case since /review runs before /ship creates the PR.
|
|
2. Identify the **stated intent** — what was this branch supposed to accomplish?
|
|
3. Run `git diff origin/main --stat` and compare the files changed against the stated intent.
|
|
4. Evaluate with skepticism:
|
|
|
|
**SCOPE CREEP detection:**
|
|
- Files changed that are unrelated to the stated intent
|
|
- New features or refactors not mentioned in the plan
|
|
- "While I was in there..." changes that expand blast radius
|
|
|
|
**MISSING REQUIREMENTS detection:**
|
|
- Requirements from TODOS.md/PR description not addressed in the diff
|
|
- Test coverage gaps for stated requirements
|
|
- Partial implementations (started but not finished)
|
|
|
|
5. Output (before the main review begins):
|
|
```
|
|
Scope Check: [CLEAN / DRIFT DETECTED / REQUIREMENTS MISSING]
|
|
Intent: <1-line summary of what was requested>
|
|
Delivered: <1-line summary of what the diff actually does>
|
|
[If drift: list each out-of-scope change]
|
|
[If missing: list each unaddressed requirement]
|
|
```
|
|
|
|
6. This is **INFORMATIONAL** — does not block the review. Proceed to Step 2.
|
|
|
|
---
|
|
|
|
## Step 2: Read the checklist
|
|
|
|
Read `.claude/skills/review/checklist.md`.
|
|
|
|
**If the file cannot be read, STOP and report the error.** Do not proceed without the checklist.
|
|
|
|
---
|
|
|
|
## Step 2.5: Check for Greptile review comments
|
|
|
|
Read `.claude/skills/review/greptile-triage.md` and follow the fetch, filter, classify, and **escalation detection** steps.
|
|
|
|
**If no PR exists, `gh` fails, API returns an error, or there are zero Greptile comments:** Skip this step silently. Greptile integration is additive — the review works without it.
|
|
|
|
**If Greptile comments are found:** Store the classifications (VALID & ACTIONABLE, VALID BUT ALREADY FIXED, FALSE POSITIVE, SUPPRESSED) — you will need them in Step 5.
|
|
|
|
---
|
|
|
|
## Step 3: Get the diff
|
|
|
|
Fetch the latest main to avoid false positives from a stale local main:
|
|
|
|
```bash
|
|
git fetch origin main --quiet
|
|
```
|
|
|
|
Run `git diff origin/main` to get the full diff. This includes both committed and uncommitted changes against the latest main.
|
|
|
|
---
|
|
|
|
## Step 4: Two-pass review
|
|
|
|
Apply the checklist against the diff in two passes:
|
|
|
|
1. **Pass 1 (CRITICAL):** SQL & Data Safety, Race Conditions & Concurrency, LLM Output Trust Boundary, Enum & Value Completeness
|
|
2. **Pass 2 (INFORMATIONAL):** Conditional Side Effects, Magic Numbers & String Coupling, Dead Code & Consistency, LLM Prompt Issues, Test Gaps, View/Frontend
|
|
|
|
**Enum & Value Completeness requires reading code OUTSIDE the diff.** When the diff introduces a new enum value, status, tier, or type constant, use Grep to find all files that reference sibling values, then Read those files to check if the new value is handled. This is the one category where within-diff review is insufficient.
|
|
|
|
Follow the output format specified in the checklist. Respect the suppressions — do NOT flag items listed in the "DO NOT flag" section.
|
|
|
|
---
|
|
|
|
## Step 5: Output findings
|
|
|
|
**Always output ALL findings** — both critical and informational. The user must see every issue.
|
|
|
|
- If CRITICAL issues found: output all findings, then for EACH critical issue use a separate AskUserQuestion with the problem, then `RECOMMENDATION: Choose A because [one-line reason]`, then options (A: Fix it now, B: Acknowledge, C: False positive — skip).
|
|
After all critical questions are answered, output a summary of what the user chose for each issue. If the user chose A (fix) on any issue, apply the recommended fixes. If only B/C were chosen, no action needed.
|
|
- If only non-critical issues found: output findings. No further action needed.
|
|
- If no issues found: output `Pre-Landing Review: No issues found.`
|
|
|
|
### Verification of claims
|
|
|
|
Before producing the final review output:
|
|
- If you claim "this pattern is safe" → cite the specific line proving safety
|
|
- If you claim "this is handled elsewhere" → read and cite the handling code
|
|
- If you claim "tests cover this" → name the test file and method
|
|
- Never say "likely handled" or "probably tested" — verify or flag as unknown
|
|
|
|
**Rationalization prevention:** "This looks fine" is not a finding. Either cite evidence it IS fine, or flag it as unverified.
|
|
|
|
### Greptile comment resolution
|
|
|
|
After outputting your own findings, if Greptile comments were classified in Step 2.5:
|
|
|
|
**Include a Greptile summary in your output header:** `+ N Greptile comments (X valid, Y fixed, Z FP)`
|
|
|
|
Before replying to any comment, run the **Escalation Detection** algorithm from greptile-triage.md to determine whether to use Tier 1 (friendly) or Tier 2 (firm) reply templates.
|
|
|
|
1. **VALID & ACTIONABLE comments:** These are already included in your CRITICAL findings — they follow the same AskUserQuestion flow (A: Fix it now, B: Acknowledge, C: False positive). If the user chooses A (fix), reply using the **Fix reply template** from greptile-triage.md (include inline diff + explanation). If the user chooses C (false positive), reply using the **False Positive reply template** (include evidence + suggested re-rank), save to both per-project and global greptile-history.
|
|
|
|
2. **FALSE POSITIVE comments:** Present each one via AskUserQuestion:
|
|
- Show the Greptile comment: file:line (or [top-level]) + body summary + permalink URL
|
|
- Explain concisely why it's a false positive
|
|
- Options:
|
|
- A) Reply to Greptile explaining why this is incorrect (recommended if clearly wrong)
|
|
- B) Fix it anyway (if low-effort and harmless)
|
|
- C) Ignore — don't reply, don't fix
|
|
|
|
If the user chooses A, reply using the **False Positive reply template** from greptile-triage.md (include evidence + suggested re-rank), save to both per-project and global greptile-history.
|
|
|
|
3. **VALID BUT ALREADY FIXED comments:** Reply using the **Already Fixed reply template** from greptile-triage.md — no AskUserQuestion needed:
|
|
- Include what was done and the fixing commit SHA
|
|
- Save to both per-project and global greptile-history
|
|
|
|
4. **SUPPRESSED comments:** Skip silently — these are known false positives from previous triage.
|
|
|
|
---
|
|
|
|
## Step 5.5: TODOS cross-reference
|
|
|
|
Read `TODOS.md` in the repository root (if it exists). Cross-reference the PR against open TODOs:
|
|
|
|
- **Does this PR close any open TODOs?** If yes, note which items in your output: "This PR addresses TODO: <title>"
|
|
- **Does this PR create work that should become a TODO?** If yes, flag it as an informational finding.
|
|
- **Are there related TODOs that provide context for this review?** If yes, reference them when discussing related findings.
|
|
|
|
If TODOS.md doesn't exist, skip this step silently.
|
|
|
|
---
|
|
|
|
## Important Rules
|
|
|
|
- **Read the FULL diff before commenting.** Do not flag issues already addressed in the diff.
|
|
- **Read-only by default.** Only modify files if the user explicitly chooses "Fix it now" on a critical issue. Never commit, push, or create PRs.
|
|
- **Be terse.** One line problem, one line fix. No preamble.
|
|
- **Only flag real problems.** Skip anything that's fine.
|
|
- **Use Greptile reply templates from greptile-triage.md.** Every reply includes evidence. Never post vague replies.
|