mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-06 05:35:46 +02:00
d85233017b
* feat: /codex skill — multi-AI second opinion (review, challenge, consult) Three modes: code review with pass/fail gate, adversarial challenge mode, and conversational consult with session continuity. First multi-AI skill in gstack, wrapping OpenAI's Codex CLI. * feat: integrate /codex into /review, /ship, /plan-eng-review + dashboard /review offers Codex second opinion after completing its own review. /ship offers Codex review as optional gate before pushing. /plan-eng-review offers Codex plan critique after scope challenge. Review Readiness Dashboard shows Codex Review as optional row. * chore: bump version and changelog (v0.8.0) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: codex skill validation (12 stub tests) + E2E eval test Stub tests (free tier): verify template content — three modes, gate verdict, session continuity, cost tracking, cross-model comparison, binary discovery, error handling, mktemp usage, and integrations into /review, /ship, /plan-eng-review. E2E test (paid tier): runs /codex review on vulnerable fixture repo via session-runner, verifies output contains findings and GATE verdict. * fix: codex auth error message — use codex login, not OPENAI_API_KEY Codex authenticates via ChatGPT OAuth (codex login), not an env var. * feat: codex uses high reasoning effort by default gpt-5.2-codex is the only model available with ChatGPT login. All commands now use model_reasoning_effort="high" for maximum depth — the whole point is a thorough second opinion. * feat: crank codex reasoning to xhigh (maximum) * feat: per-mode reasoning (high for review/consult, xhigh for challenge) + web search Review and consult use high reasoning — thorough but not slow. Challenge (adversarial) uses xhigh — maximum depth for breaking code. All modes enable web_search_cached so Codex can look up docs/APIs. * refactor: don't hardcode model — use codex default (always latest) * feat: JSONL output for codex challenge + consult modes Use --json flag to parse codex's JSONL events, extracting reasoning traces ([codex thinking]), tool calls ([codex ran]), and token counts. This gives richer output than the -o flag alone — you can see what codex thought through before its answer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: only persist codex-review log when code review actually ran Don't write a codex-review entry to reviews.jsonl when only the adversarial challenge (option B) was selected — there's no gate verdict to record, and a false entry misleads the Review Readiness Dashboard into thinking a code review happened. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add codex plan review option to /plan-eng-review After scope challenge (Step 0), offer to have Codex independently review the plan with a brutally honest tech reviewer persona. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: update e2e test for codex skill Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: codex integration bugs — plan content, review persistence, quoting, stderr - plan-eng-review: Codex now reads the plan file itself instead of inlining content as a CLI arg (avoids ARG_MAX for large plans) - review: add missing echo to persist codex-review results to reviews.jsonl - codex: consult mode uses $TMPERR (mktemp) instead of hardcoded stderr path - codex + review: quote $SLUG/$BRANCH_SLUG in review log paths - codex: scope plan lookup to current project, warn on cross-project fallback Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: add .context/ to .gitignore to prevent session ID leaks Codex consult mode stores session IDs in .context/codex-session-id. Without this ignore rule, session IDs could leak into commits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: proactive skill suggestions + opt-out + trigger phrase tests - Preamble reads proactive config via gstack-config - Root SKILL.md.tmpl has lifecycle map (stage → skill suggestion) - Users can opt out ("stop suggesting") / opt in ("be proactive again") - Restored trigger phrase validation tests (16 skills × "Use when" check) - Added missing "Use when" trigger phrases to /debug and /office-hours Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: update changelog for v0.8.0 — add proactive suggestions note Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
293 lines
12 KiB
Cheetah
293 lines
12 KiB
Cheetah
---
|
|
name: review
|
|
version: 1.0.0
|
|
description: |
|
|
Pre-landing PR review. Analyzes diff against the base branch for SQL safety, LLM trust
|
|
boundary violations, conditional side effects, and other structural issues. Use when
|
|
asked to "review this PR", "code review", "pre-landing review", or "check my diff".
|
|
Proactively suggest when the user is about to merge or land code changes.
|
|
allowed-tools:
|
|
- Bash
|
|
- Read
|
|
- Edit
|
|
- Write
|
|
- Grep
|
|
- Glob
|
|
- AskUserQuestion
|
|
---
|
|
|
|
{{PREAMBLE}}
|
|
|
|
{{BASE_BRANCH_DETECT}}
|
|
|
|
# Pre-Landing PR Review
|
|
|
|
You are running the `/review` workflow. Analyze the current branch's diff against the base branch 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 the base branch, output: **"Nothing to review — you're on the base branch or have no changes against it."** and stop.
|
|
3. Run `git fetch origin <base> --quiet && git diff origin/<base> --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/<base>..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/<base> --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 base branch to avoid false positives from stale local state:
|
|
|
|
```bash
|
|
git fetch origin <base> --quiet
|
|
```
|
|
|
|
Run `git diff origin/<base>` to get the full diff. This includes both committed and uncommitted changes against the latest base branch.
|
|
|
|
---
|
|
|
|
## 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 4.5: Design Review (conditional)
|
|
|
|
{{DESIGN_REVIEW_LITE}}
|
|
|
|
Include any design findings alongside the findings from Step 4. They follow the same Fix-First flow in Step 5 — AUTO-FIX for mechanical CSS fixes, ASK for everything else.
|
|
|
|
---
|
|
|
|
## Step 5: Fix-First Review
|
|
|
|
**Every finding gets action — not just critical ones.**
|
|
|
|
Output a summary header: `Pre-Landing Review: N issues (X critical, Y informational)`
|
|
|
|
### Step 5a: Classify each finding
|
|
|
|
For each finding, classify as AUTO-FIX or ASK per the Fix-First Heuristic in
|
|
checklist.md. Critical findings lean toward ASK; informational findings lean
|
|
toward AUTO-FIX.
|
|
|
|
### Step 5b: Auto-fix all AUTO-FIX items
|
|
|
|
Apply each fix directly. For each one, output a one-line summary:
|
|
`[AUTO-FIXED] [file:line] Problem → what you did`
|
|
|
|
### Step 5c: Batch-ask about ASK items
|
|
|
|
If there are ASK items remaining, present them in ONE AskUserQuestion:
|
|
|
|
- List each item with a number, the severity label, the problem, and a recommended fix
|
|
- For each item, provide options: A) Fix as recommended, B) Skip
|
|
- Include an overall RECOMMENDATION
|
|
|
|
Example format:
|
|
```
|
|
I auto-fixed 5 issues. 2 need your input:
|
|
|
|
1. [CRITICAL] app/models/post.rb:42 — Race condition in status transition
|
|
Fix: Add `WHERE status = 'draft'` to the UPDATE
|
|
→ A) Fix B) Skip
|
|
|
|
2. [INFORMATIONAL] app/services/generator.rb:88 — LLM output not type-checked before DB write
|
|
Fix: Add JSON schema validation
|
|
→ A) Fix B) Skip
|
|
|
|
RECOMMENDATION: Fix both — #1 is a real race condition, #2 prevents silent data corruption.
|
|
```
|
|
|
|
If 3 or fewer ASK items, you may use individual AskUserQuestion calls instead of batching.
|
|
|
|
### Step 5d: Apply user-approved fixes
|
|
|
|
Apply fixes for items where the user chose "Fix." Output what was fixed.
|
|
|
|
If no ASK items exist (everything was AUTO-FIX), skip the question entirely.
|
|
|
|
### 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 included in your findings — they follow the Fix-First flow (auto-fixed if mechanical, batched into ASK if not) (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.
|
|
|
|
---
|
|
|
|
## Step 5.6: Documentation staleness check
|
|
|
|
Cross-reference the diff against documentation files. For each `.md` file in the repo root (README.md, ARCHITECTURE.md, CONTRIBUTING.md, CLAUDE.md, etc.):
|
|
|
|
1. Check if code changes in the diff affect features, components, or workflows described in that doc file.
|
|
2. If the doc file was NOT updated in this branch but the code it describes WAS changed, flag it as an INFORMATIONAL finding:
|
|
"Documentation may be stale: [file] describes [feature/component] but code changed in this branch. Consider running `/document-release`."
|
|
|
|
This is informational only — never critical. The fix action is `/document-release`.
|
|
|
|
If no documentation files exist, skip this step silently.
|
|
|
|
---
|
|
|
|
## Step 5.7: Codex second opinion (optional)
|
|
|
|
After completing the review, check if the Codex CLI is available:
|
|
|
|
```bash
|
|
which codex 2>/dev/null && echo "CODEX_AVAILABLE" || echo "CODEX_NOT_AVAILABLE"
|
|
```
|
|
|
|
If Codex is available, use AskUserQuestion:
|
|
|
|
```
|
|
Review complete. Want an independent second opinion from Codex (OpenAI)?
|
|
|
|
A) Run Codex code review — independent diff review with pass/fail gate
|
|
B) Run Codex adversarial challenge — try to find ways this code will fail in production
|
|
C) Both — review first, then adversarial challenge
|
|
D) Skip — no Codex review needed
|
|
```
|
|
|
|
If the user chooses A, B, or C:
|
|
|
|
**For code review (A or C):** Run `codex review --base <base>` with a 5-minute timeout.
|
|
Present the full output verbatim under a `CODEX SAYS (code review):` header.
|
|
Check the output for `[P1]` markers — if found, note `GATE: FAIL`, otherwise `GATE: PASS`.
|
|
After presenting, compare Codex's findings with your own review findings from Steps 4-5
|
|
and output a CROSS-MODEL ANALYSIS showing what both found, what only Codex found,
|
|
and what only Claude found.
|
|
|
|
**For adversarial challenge (B or C):** Run:
|
|
```bash
|
|
codex exec "Review the changes on this branch against the base branch. Run git diff origin/<base> to see the diff. Your job is to find ways this code will fail in production. Think like an attacker and a chaos engineer. Find edge cases, race conditions, security holes, failure modes. Be adversarial." -s read-only
|
|
```
|
|
Present the full output verbatim under a `CODEX SAYS (adversarial challenge):` header.
|
|
|
|
**Only if a code review ran (user chose A or C):** Persist the Codex review result to the review log:
|
|
```bash
|
|
eval $(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null)
|
|
BRANCH_SLUG=$(git rev-parse --abbrev-ref HEAD 2>/dev/null | tr '/' '-')
|
|
mkdir -p ~/.gstack/projects/"$SLUG"
|
|
echo '{"skill":"codex-review","timestamp":"'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'","status":"STATUS","gate":"GATE"}' >> ~/.gstack/projects/"$SLUG"/"$BRANCH_SLUG"-reviews.jsonl
|
|
```
|
|
|
|
Substitute: STATUS ("clean" if PASS, "issues_found" if FAIL), GATE ("pass" or "fail").
|
|
|
|
**Do NOT persist a codex-review entry when only the adversarial challenge (B) ran** —
|
|
there is no gate verdict to record, and a false entry would make the Review Readiness
|
|
Dashboard believe a code review happened when it didn't.
|
|
|
|
If Codex is not available, skip this step silently.
|
|
|
|
---
|
|
|
|
## Important Rules
|
|
|
|
- **Read the FULL diff before commenting.** Do not flag issues already addressed in the diff.
|
|
- **Fix-first, not read-only.** AUTO-FIX items are applied directly. ASK items are only applied after user approval. Never commit, push, or create PRs — that's /ship's job.
|
|
- **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.
|