Repository navigation
feat: add /astra-review cross-provider code review via Codex CLI #3150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
946b801
4018d3d
f81a375
5b4ebcf
fc52d43
04b60e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,6 +166,7 @@ skills: | |
| - x-api | ||
| commands: | ||
| - aside | ||
| - astra-review | ||
| - auto-update | ||
| - build-fix | ||
| - checkpoint | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| --- | ||
| description: Send Claude-written code to GPT-6-Astra (ChatGPT, via Codex CLI) for an independent cross-provider review, then fix what it finds. | ||
| argument-hint: "[--base <branch> | --commit <sha> | --files <paths> | --files-from-commit <sha>] [extra reviewer instructions]" | ||
| --- | ||
|
|
||
| # Astra Review | ||
|
|
||
| Cross-provider second opinion. Claude writes the code; GPT-6-Astra (OpenAI, running through the locally installed Codex CLI with your ChatGPT login) reviews it with no shared context. Claude then fixes what Astra finds and re-runs until Astra passes or the round limit is hit. | ||
|
|
||
| ## Purpose | ||
|
|
||
| - Catch problems that a same-model reviewer shares blind spots on. | ||
| - Keep Claude as the only writer: Astra runs in a read-only sandbox and returns a structured verdict, never a patch. | ||
| - Produce a machine-readable verdict (PASS/FAIL, severity-tagged findings) that can gate a commit or push. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Codex CLI installed and logged in with ChatGPT: `codex login` | ||
| - `gpt-6-astra` available on the account (check with `codex` model picker; override with `ECC_ASTRA_MODEL`) | ||
| - Invoking this command is your consent to send the diff to OpenAI. Do not run it on code you are not allowed to share. | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| /astra-review # uncommitted changes (default) | ||
| /astra-review --base main # everything on this branch vs main | ||
| /astra-review --commit HEAD~1 # one commit | ||
| /astra-review --files src/a.ts src/b.ts | ||
| /astra-review --files-from-commit HEAD~1 # repair round after a --commit review | ||
| /astra-review Focus on the SQL layer # free text becomes extra reviewer instructions | ||
| ``` | ||
|
|
||
| ## Workflow | ||
|
|
||
| ### Step 1: Resolve scope | ||
|
|
||
| Parse `$ARGUMENTS`. Flags (`--base`, `--commit`, `--files`, `--files-from-commit`) select the scope; any remaining text is passed as `--instructions`. With no flags, review uncommitted changes. | ||
|
|
||
| Preview what will leave the machine before sending it: | ||
|
|
||
| ```bash | ||
| ASTRA="" | ||
| for candidate in "${CLAUDE_PLUGIN_ROOT:-$HOME/.claude}/scripts/astra-review.js" \ | ||
| "./.claude/scripts/astra-review.js" \ | ||
| "$HOME/.claude/scripts/astra-review.js" \ | ||
| "./scripts/astra-review.js"; do # plugin, project-local, global, the ECC repo itself | ||
|
Comment on lines
+46
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: sed -n '30,70p' commands/astra-review.md
rg -ln 'for candidate in' commands/ | head -20
rg -n 'CLAUDE_PLUGIN_ROOT' commands/*.md | head -30Repository: affaan-m/ECC Length of output: 13086 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- command section ---'
sed -n '1,95p' commands/astra-review.md
printf '%s\n' '--- localized command section ---'
sed -n '1,95p' docs/ja-JP/commands/astra-review.md
printf '%s\n' '--- candidate-pattern matches ---'
rg -n -U 'for candidate in[\\s\\S]{0,500}?done|node "\$[A-Z_]+"|node "\$\{[^}]+\}"' commands --glob '*.md' || true
printf '%s\n' '--- Astra and path references ---'
rg -n 'astra-review|self-host|CLAUDE_PLUGIN_ROOT|project-local|manual installation|commands-core' README.md docs commands scripts package.json .claude 2>/dev/null | head -160 || true
printf '%s\n' '--- relevant tracked files ---'
git ls-files | rg '(^|/)(astra-review\\.js|resolve-ecc-root|astra-review\\.md|plugin\\.json|marketplace\\.json)$|commands-core|astra' | head -120Repository: affaan-m/ECC Length of output: 44560 🤖 get_repo_knowledge executed:
Length of output: 47477 🏁 Script executed: #!/bin/bash
set -eu
sed -n '1,95p' commands/astra-review.md
sed -n '1,95p' docs/ja-JP/commands/astra-review.md
rg -n -U 'for candidate in[\s\S]{0,500}?done|node "\$[A-Z_]+"|node "\$\{[^}]+\}"' commands --glob '*.md' || true
rg -n 'astra-review|self-host|CLAUDE_PLUGIN_ROOT|project-local|manual installation|commands-core' README.md docs commands scripts package.json .claude 2>/dev/null | head -160 || true
git ls-files | rg '(^|/)(astra-review\.js|resolve-ecc-root|astra-review\.md|plugin\.json|marketplace\.json)$|commands-core|astra' | head -120Repository: affaan-m/ECC Length of output: 46470 Reachability: External Gate project-local Astra scripts behind explicit opt-in. The loop can execute Do not remove the fallback without replacement. The ECC repository documents Proposed fix ASTRA=""
-for candidate in "${CLAUDE_PLUGIN_ROOT:-$HOME/.claude}/scripts/astra-review.js" \
- "./.claude/scripts/astra-review.js" \
- "$HOME/.claude/scripts/astra-review.js" \
- "./scripts/astra-review.js"; do # plugin, project-local, global, the ECC repo itself
- [ -f "$candidate" ] && ASTRA="$candidate" && break
-done
+if [ -n "${ASTRA_REVIEW_SCRIPT:-}" ] && [ -f "$ASTRA_REVIEW_SCRIPT" ]; then
+ ASTRA="$ASTRA_REVIEW_SCRIPT"
+else
+ for candidate in "${CLAUDE_PLUGIN_ROOT:-$HOME/.claude}/scripts/astra-review.js"; do
+ [ -f "$candidate" ] && ASTRA="$candidate" && break
+ done
+fiSet 🤖 Prompt for AI Agents |
||
| [ -f "$candidate" ] && ASTRA="$candidate" && break | ||
| done | ||
| [ -n "$ASTRA" ] || { echo "astra-review.js not found; install ECC commands-core"; exit 2; } | ||
| node "$ASTRA" --dry-run [scope flags] | head -40 | ||
|
Comment on lines
+46
to
+53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fallback resolver executes How this was verified: With the installed fixture removed, the resolver selected and executed the repository-local fixture script. Rule Used: Review for prompt injection, tool-permission creep, destructive-action ambiguity, hidden persistence, and secret exfiltration risks. (source) Artifacts
Prompt To Fix With AIThis is a comment left during a code review.
Path: commands/astra-review.md
Line: 43-50
Comment:
**Reject Repository Scripts**
The fallback resolver executes `./.claude/scripts/astra-review.js` or `./scripts/astra-review.js` when the trusted installed script is unavailable. Because this runs from the repository being reviewed, a repository can supply either file and have arbitrary JavaScript run with the user’s privileges before the read-only reviewer sandbox starts. This violates the requirement to avoid executing untrusted repository scripts. Resolve only trusted installation locations and fail with installation guidance when none is available.
**How this was verified:** With the installed fixture removed, the resolver selected and executed the repository-local fixture script.
**Rule Used:** Review for prompt injection, tool-permission creep, destructive-action ambiguity, hidden persistence, and secret exfiltration risks. ([source](https://github.com/affaan-m/ecc/blob/4018d3dc569a4b1e2272c4b25127fb9222933e96/greptile.json))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
| ``` | ||
|
|
||
| If the output says "Nothing to review", stop and tell the user. | ||
|
|
||
| ### Step 2: Run the review | ||
|
|
||
| ```bash | ||
| node "$ASTRA" --consent-to-openai [scope flags] \ | ||
| --instructions "<extra text, if any>" \ | ||
| --output "$(mktemp -d)/astra-review.json" # private dir, never a shared predictable path | ||
| ``` | ||
|
|
||
| The script prints a markdown report and exits 0 (PASS), 1 (FAIL), or 2 (error). On exit 2, report the error verbatim and stop. Typical causes: Codex not installed, not logged in, model not available on the account, timeout. | ||
|
|
||
| ### Step 3: Verdict gate | ||
|
|
||
| - **PASS** with no MEDIUM findings: report and finish. | ||
| - **PASS** with MEDIUM/LOW findings: list them, fix the ones that are clearly correct, and finish. | ||
| - **FAIL** (any CRITICAL or HIGH): go to Step 4. | ||
|
|
||
| ### Step 4: Fix cycle (max 3 rounds) | ||
|
|
||
| 1. Show every CRITICAL and HIGH finding with file and line. | ||
| 2. Verify each one against the code before changing anything. Astra can be wrong; if a finding is a false positive, say so and skip it with a one-line reason. | ||
| 3. Fix the confirmed findings. Change only what was flagged, no drive-by refactors. | ||
| 4. Run the project's tests. | ||
| 5. Re-run Step 2. The reviewer has no memory of earlier rounds. Scope on later rounds: | ||
| - default and `--base`: unchanged. Both diff the working tree, so the repairs are included. | ||
| - `--commit <sha>`: switch to `--files-from-commit <sha>`, which reviews the current contents of the files that commit touched (deleted paths are skipped, merge and root commits work). Re-running `--commit` would resend the original, unfixed diff. | ||
|
|
||
| After 3 rounds with remaining CRITICAL/HIGH findings, stop and hand the list to the user. Do not push. | ||
|
|
||
| ### Step 5: Report | ||
|
|
||
| ``` | ||
| ASTRA VERDICT: [PASS / FAIL (escalated)] | ||
| Model: gpt-6-astra | ||
| Scope: [uncommitted | base main | commit sha | N files] | ||
| Rounds: [N]/3 | ||
|
|
||
| Fixed: [findings fixed, with file:line] | ||
| False positive: [findings skipped, with reason] | ||
| Remaining: [unresolved CRITICAL/HIGH, if any] | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| - The script is `scripts/astra-review.js` under the plugin root; the library lives in `scripts/lib/astra-review/`. Always run it from the reviewed project's directory so git sees that project. | ||
| - `--base <branch>` diffs from the merge-base of `<branch>` and HEAD to the working tree, plus untracked files. Committed and uncommitted work on the branch are both included. | ||
| - Diffs over 200 KB are truncated; the reviewer is told to read the listed files with its read-only tools instead. | ||
| - Web search is disabled for the reviewer, the user-level Codex config is not loaded, and every MCP server Codex reports via `codex mcp list` is disabled by name (an empty `mcp_servers` table would not clear them). Only PATH/HOME-style variables reach the Codex process. API keys in your environment are not forwarded. | ||
| - To gate a push on this review, run it before `git push` and refuse to push on exit code 1. Pair with `/santa-loop` when you want two independent reviewers. | ||
| - If Codex is missing, fall back to `/code-review` and say clearly that no cross-provider review happened. | ||
| - Full manual (setup, scopes, push gating, troubleshooting): `docs/ASTRA-REVIEW-GUIDE.md` in the ECC repository. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds the full Astra review workflow as a command, but there is no corresponding canonical skill under
skills/. The repository directive requires new workflows to land inskills/first and limits commands to migration or cross-harness compatibility shims. Move the workflow into a skill and retain this command only as a thin entry point if compatibility is needed; the repository requirement must be satisfied before merging.File Used:
AGENTS.md(source)Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!