/claudex-loop:codex-reviewfrom claudex-loop
Adversarial plan-review loop where Claude drafts a plan and OpenAI Codex (read-only) critiques it, iterating until approved. Use for high-stakes implementation plans before writing code.
Ships in claudex-loop. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Two models, one plan, a bounded argument. Claude is the builder and orchestrator. Codex is a read-only critic that can read the repo and the plan but cannot touch a single file. They communicate strictly through PLAN.md + a Codex session that persists across rounds. The human enters at exactly two points: kickoff and final sign-off.
This is a deliberate, high-stakes tool — reach for it on auth, data models, concurrency, migrations, payments, anything expensive to get wrong. Skip it for obvious/cheap work.
codex --version (need ≥ 0.130; the default gpt-5.5 model errors on older CLIs).codex login (ChatGPT account is fine). If a run returns an auth/model error, surface it to the user — do not silently retry.-m unless the user asks. The user's ~/.codex/config.toml default model is used. Pinning gpt-5.x-codex variants fails on ChatGPT-account auth.model line from ~/.codex/config.toml (absent = "CLI default"); state it with the resolved tunables. If the user objects, stop before burning a round.codex exec accepts -s read-only. codex exec resume does NOT — it rejects -s ("unexpected argument"). On resume you MUST force read-only via -c sandbox_mode="read-only", because config.toml may default sandbox_mode to danger-full-access (+ approval_policy="never") — which would let Codex WRITE files mid-loop. This is the single most important safety detail in this skill: verified end-to-end on 2026-06-04.| Var | Default | Meaning |
|---|---|---|
MAX_ROUNDS | 5 | Hard cap on review rounds. The loop ALWAYS terminates at this. |
PLAN_FILE | PLAN.md | Where the evolving plan lives (repo root). |
LOG_FILE | PLAN-REVIEW-LOG.md | Append-only transcript of the argument (every round's critique + what changed). The artifact. |
If the user invoked the skill with an argument like rounds=3, use that for MAX_ROUNDS. Echo the resolved values back before starting.
The invocation itself is the kickoff. Confirm scope in one line: what is being planned. If the user gave no task, ask for it (one question). Then proceed — do NOT ask for approval round-by-round; that comes at the end.
Do real planning: read the relevant code, think through the approach, surface decisions and tradeoffs. Then write the plan to PLAN_FILE in this structure:
# Plan: <task>
_Round 0 — initial draft by Claude_
## Goal
<one paragraph>
## Approach
<numbered steps, concrete>
## Key decisions & tradeoffs
<the contestable choices — name them explicitly so Codex has something to bite>
## Risks / open questions
<what you're unsure about>
## Out of scope
<bounds>
Initialize LOG_FILE:
# Plan Review Log: <task>
Started <stamp the user's local time if known, else "session start">. MAX_ROUNDS=<n>.
Show the user the plan inline and say you're sending it to Codex for adversarial review.
Maintain ROUND (start 1) and THREAD_ID (empty until round 1 returns).
The review prompt sent to Codex each round (adjust the task line):
You are an adversarial reviewer for an implementation plan. Be skeptical and specific — your job is to find what breaks, not to be agreeable. Read the plan at
PLAN.md(and any repo files you need; you are read-only). Identify concrete flaws: security holes, race conditions, missing edge cases, schema conflicts, wrong assumptions, observability gaps, simpler alternatives. For each, give a one-line fix. Do NOT modify any files. End your reply with EXACTLY one line:VERDICT: APPROVEDif the plan is sound enough to implement, orVERDICT: REVISEif it still has material problems.
Round 1 (creates the session — capture thread_id):
codex exec -s read-only --json \
-o /tmp/codex-verdict.txt \
"$(cat REVIEW_PROMPT)" \
< /dev/null 2>/dev/null | grep '"type":"thread.started"'
Parse thread_id from the {"type":"thread.started","thread_id":"..."} line → that is THREAD_ID. The critique text lands in /tmp/codex-verdict.txt (Codex's last message). Read that file.
Note: stderr carries cosmetic MCP/auth noise on some setups —
2>/dev/nullis intentional. Confirm success by the presence of the verdict file + athread.startedline. If neither appears, the run failed (auth/model) — stop and tell the user.
< /dev/nullis mandatory:codex execreads stdin in addition to the prompt arg, so under a non-interactive driver (Claude Code's Bash tool, CI, any non-TTY pipeline) it blocks forever waiting on stdin EOF — a silent ~0% CPU hang. The redirect gives it immediate EOF. Required on the resume call below too.Timeout guard: run every
codex exec/codex exec resumewith a 10-minute ceiling so any future stall fails loud instead of hanging silently. Via Claude Code's Bash tool, passtimeout: 600000on the tool call (the default 2-minute tool timeout is too short for real reviews and would kill them mid-run). In a plain shell, prefix the command withtimeout 600(Linux / Git Bash) orgtimeout 600(macOS via coreutils — stock macOS has notimeout). If the ceiling trips, treat it as a failed run: stop and tell the user rather than retrying blind. Applies to the resume call below too.
Rounds 2..MAX (resume the SAME session — Codex remembers its earlier critiques, won't re-litigate settled points):
# NOTE: resume rejects -s. Force read-only via -c sandbox_mode, or Codex
# inherits config.toml (possibly danger-full-access) and could write files.
codex exec resume "$THREAD_ID" -c sandbox_mode="read-only" --json \
-o /tmp/codex-verdict.txt \
"I revised the plan. Re-review PLAN.md. Same rules. End with VERDICT: APPROVED or VERDICT: REVISE." \
< /dev/null 2>/dev/null >/dev/null
Both codex exec and codex exec resume support --json (stream → parse thread_id first round) and -o/--output-last-message (verdict capture).
Each round, after Codex returns:
/tmp/codex-verdict.txt. Append to LOG_FILE: ## Round <n> — Codex + the full critique.VERDICT: APPROVED → break the loop, go to Step 3 (converged).VERDICT: REVISE → Claude reads the critique, decides what's actually worth acting on (Claude has final say — Codex advises, it does not command). Revise PLAN_FILE. Append to LOG_FILE: ### Claude's response + what you changed and what you rejected and why. Increment ROUND.ROUND > MAX_ROUNDS → break to Step 3 (deadlock).If APPROVED: Present to the user — the final PLAN_FILE, a 3-bullet summary of what the argument improved, and the round count. Ask: "Plan survived N rounds of Codex. Implement it now — Codex builds it (/codex-build), Claude builds it, or stop here?" Only on a yes is code written. No code is written during the loop. If the user picks Codex, invoke the codex-build skill with SPEC_FILE=PLAN.md and the same LOG_FILE — roles flip (Codex writes, Claude reviews the diff) and the build rounds append to the same log.
If MAX_ROUNDS hit without APPROVED (deadlock): Do NOT pretend it converged. Surface the unresolved disagreements explicitly: list each point Codex still flags and Claude's counter-position. Hand it to the human to break the tie. This is a legitimate, useful outcome — a flagged disagreement beats a false "approved."
-s read-only for the first call, -c sandbox_mode="read-only" for every resume (resume has no -s). It never writes. If you're tempted to give it write access, stop — that's a different skill.MAX_ROUNDS. No unbounded recursion.LOG_FILE is the deliverable — it tells the whole story of the argument. Keep it complete./codex:review.-codex model variant on ChatGPT-account auth — it 400s.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub az9713/claudex-loop-tutorial --plugin claudex-loop3 skills in this plugin
/claudex-loopFour-phase plan hardening (renamed from /crucible 2026-08-16; old triggers still work) — supersedes /grill-me-codex and /grill-with-docs-codex. PHASE 0 RECON — Claude scouts first (codebase + docs on brownfield; prior art, stack, and pitfalls research on greenfield) and drafts an assumptions ledger. PHASE 1 INTERROGATE — confirm the ledger in one batch, then question only the load-bearing decisions one at a time (each with why-it-matters, a recommendation, and what-breaks-if-we-guess-wrong), cosmetic ones batched, with a visible decision map and an accept-all-recommendations escape hatch. PHASE 2 REVIEW — the locked plan goes to PLAN.md and OpenAI Codex adversarially reviews it in a read-only sandbox (VERDICT: APPROVED/REVISE); Claude revises and re-submits to the SAME Codex session until APPROVED or MAX_ROUNDS, then you sign off before any code. PHASE 3 BUILD (optional) — you pick the builder and the models swap jobs: Codex builds via codex-build and Claude reads the full diff + runs the proof itself; Claude builds and a fresh read-only Codex session cross-inspects the diff (on by default, logged opt-out only); either way you approve the final diff. Use when the user says "/claudex-loop", "claudex this", "run the claudex loop", "/crucible" (legacy), "put this through the crucible", "crucible this plan", "grill me then have codex review", "stress-test this plan before we build", or is about to build something high-stakes (auth, schema, concurrency, migrations, payments, greenfield architecture) and wants alignment AND a cross-model sanity check first. Locked plan needing only the Codex loop → /codex-review. Reviewing already-written code → /codex:review. NOT for trivial changes./codex-buildHand a frozen spec (PLAN.md or any locked plan) to OpenAI Codex to IMPLEMENT with full write access, while Claude stays the spec-writer and reviewer — the exact role-flip of /codex-review. Codex builds from the spec in a --yolo sandbox, Claude reads the full diff like a contributor PR, runs the proof test, and iterates fixes via the SAME Codex session up to MAX_FIX_ROUNDS before taking over. Human approves the diff before any commit. Use when the user says "/codex-build", "have codex build this", "codex implement the plan", "hand the plan to codex", "delegate the build to codex", or right after a plan survives /grill-me-codex, /grill-with-docs-codex, or /codex-review and they choose Codex for implementation (Act 3). Also for standalone delegation: refactors, mechanical migrations, bug fixes with a known repro, test/coverage writing — anything that reads as a work order. NOT for tiny edits (~<20 lines — delegation overhead loses), NOT for design work (if writing the spec forces decisions, that's /grill-me-codex first), NOT for reviewing existing code (/codex:review), and NOT for anything needing Claude-session tools (MCP, secrets, browser).Other plugins' skills for the same job