/claudex-loop:claudex-loopfrom claudex-loop
Hardens plans through recon, interrogation, cross-model review with Codex, and optional build. For high-stakes decisions like auth, schema, migrations.
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.
Read when SKILL.md points to them.
(Renamed from Crucible 2026-08-16. Old trigger phrases still work.)
Four phases, four failure modes killed:
You enter at four points only: confirming the assumptions ledger, answering the fire, signing off the converged plan, and approving the final diff if you build. Codex is read-only throughout recon, interrogation, and review — no code is written until you sign off the converged plan.
Before asking the user a single question, determine the terrain and gather what can be gathered without them.
CONTEXT.md (or CONTEXT-MAP.md for multi-context repos) and docs/adr/. If they exist, load them — the project has a ubiquitous language and prior decisions the plan must respect, and Phase 1 runs docs-aware (see below).No code to read, so research carries the phase. Open the research gate, then cover:
Don't silently pick a research depth — offer the tiers with a recommendation based on stakes, and let the user choose:
none — Claude's knowledge + codebase only. Right for medium tasks on familiar ground.web — a handful of targeted WebSearch passes (docs, gotchas, prior art). Minutes, not a project. The default recommendation for most greenfield work.deep — launch a deep-research dynamic workflow via the Workflow tool: a multi-agent research orchestration (parallel finder agents each searching a different way — prior art, stack landscape, pitfalls/postmortems, docs — then deep-read agents on the best sources, then one synthesis agent producing the brief). Heavy and token-expensive — recommend only for high-stakes greenfield, unfamiliar tech, or when the landscape itself is the question. The user choosing this tier IS the explicit opt-in the Workflow tool requires. Model pin: every agent() call in the research workflow MUST pass model: 'opus' (finders, deep-readers, and the synthesizer alike) — if the main session is on Fable, letting a dozen research agents inherit it annihilates token usage for what is mostly search-and-summarize work. Leave effort at the default — don't pass an effort override. Args gotcha (found in smoke test 2026-08-13): the workflow runtime may deliver args as a JSON-encoded STRING instead of an object — always open the script with const A = typeof args === 'string' ? JSON.parse(args) : args and reference A.*, or pipeline(args.questions, ...) dies instantly with "expects an array".If invoked with research=none|web|deep, skip the question and use that tier.
If deep is chosen: draft the research prompt and get sign-off before launching. Show the user the topic framing + the 3-5 specific questions the assumptions ledger needs answered (not a generic "research X" — questions shaped like "what do teams building X get wrong about auth?" / "what's the current standard stack for Y and why?"). The user edits or approves, THEN author the workflow script with the approved questions as its args and run it. Save the synthesized brief to docs/research/YYYY-MM-DD-<slug>-claudex-research.md (or your notes location of choice, with ## Key Takeaways) — link it from the ledger entries it sourced and from PLAN.md.
Both benches carry installed skill packs. Enumerate and match against the task's domain:
~/.claude/skills/ (folder names + frontmatter description first lines are enough — don't read full SKILL.mds during recon).~/.agents/skills/ (the skills CLI's Codex install target).Filter to skills whose descriptions match the project's domain (e.g. a three.js game matches the threejs-* pack; an email feature matches resend skills). Record hits in the Assumptions Ledger as proposed toolchain entries, never auto-loads:
"threejs-game-skills pack installed on BOTH agents (9 skills incl. aaa-graphics-builder, gameplay-systems, 3d/image/audio generators) — proposing the build phase load graphics-builder + gameplay-systems, and the asset track use the generator skills. — source: skill inventory scan"
If a matched skill exists on only one bench, say which. If a Codex-side skill's loading behavior under headless codex exec is unverified, ledger that as an assumption to smoke-test before the build phase counts on it. Discovery informs the plan; nothing loads unless PLAN.md's ## Toolchain section names it and survives review.
End Phase 0 by presenting a single batch — NOT one-at-a-time — of everything Claude resolved on its own:
## Assumptions Ledger
_Confirm or correct in one pass. Anything unmarked I treat as confirmed._
1. <assumption> — source: <code path / doc / research finding / convention>
2. ...
Each entry cites its source. The user confirms/corrects in one reply. Corrections that open real questions get promoted into the Phase 1 decision map. This is the single biggest time-save over a naive grill: the interview never wastes questions on things the repo or the research already answered.
The interview. Rebuilt around one principle: every question must justify its own existence.
Lay out the tree of genuinely open decisions, tiered:
## Decision Map
### Load-bearing (asked one at a time)
- [ ] <decision> — irreversible / expensive-if-wrong (schema, auth, data model, concurrency, money, public API)
### Cosmetic (batched with defaults)
- [ ] <decision> — cheap to change later
Load-bearing = wrong answer costs a migration, a rewrite, a security hole, or user trust. Cosmetic = renameable, refactorable, swappable. Update the map as questions resolve (check items off, add branches corrections open) so the user can see convergence instead of wondering how many questions are left.
Every question ships in this format:
Q: Why it matters: Recommendation: <Claude's answer, committed — not a menu> If we guess wrong: <the concrete failure — migration, rewrite, breach, churn>
Wait for the answer before the next question. If drafting a question and the "if we guess wrong" line comes out weak — the question is cosmetic; demote it to the batch. If mid-interrogation a question turns out answerable from the code or the research, answer it yourself and log it to the ledger instead of asking.
Present the whole cosmetic tier as recommendations with a one-line rationale each. The user vetoes by exception; silence = accepted.
At any point the user can say "accept all remaining recommendations" — Claude locks every open decision at its recommended answer, logs them as such in the plan, and proceeds. Offer it explicitly if the load-bearing tier exceeds ~8 questions.
CONTEXT.md definition, stop and resolve it on the spot: quote the glossary's meaning, state the apparent meaning, make them pick.CONTEXT.md as terms settle (format: CONTEXT-FORMAT.md). Glossary ONLY — never implementation details. Created lazily on the first settled term.docs/adr/ created lazily.When the decision map is fully checked and you're aligned, write PLAN.md:
# Plan: <task>
_Locked via claudex-loop — by Claude + <user>_
## Goal
<one paragraph — reflects what the interrogation actually settled>
## Approach
<numbered, concrete steps>
## Key decisions & tradeoffs
<the contestable choices the interrogation resolved — name them so Codex has something to bite; link any ADRs; mark any locked via the escape hatch>
## Toolchain
<only when the skill inventory scan matched something — which installed skills each build track MUST load and follow, per agent (Claude / Codex), plus any generator skills or MCP capabilities the build depends on. Omit the section entirely on no matches. Reviewable like everything else: Codex should attack unused relevant skills and unjustified inclusions alike>
## Assumptions
<the confirmed ledger — with sources>
## Risks / open questions
<anything still genuinely open>
## Out of scope
<bounds the interrogation established>
Initialize PLAN-REVIEW-LOG.md:
# Plan Review Log: <task>
Phases 0-1 (recon + interrogation) complete — plan locked with the user. MAX_ROUNDS=<n>.
Hand the locked plan to Codex for adversarial review. Mechanics verified end-to-end (2026-06-04) — do not "improve" the invocations below.
codex --version ≥ 0.130 (older CLIs error on the default gpt-5.5 model).codex login; ChatGPT account is fine). On auth/model error, surface it — don't silently retry.-m. Use the config default. Pinning gpt-5.x-codex variants 400s on ChatGPT-account auth.model line from ~/.codex/config.toml (if absent, report "CLI default"). State it alongside the resolved tunables, e.g. Reviewer model: CLI default (config unpinned) — codex-cli 0.137.0. If the user objects, stop and let them adjust config before burning a review round.| Var | Default | Meaning |
|---|---|---|
MAX_ROUNDS | 5 | Hard cap on review rounds. The loop ALWAYS terminates here. |
PLAN_FILE | PLAN.md | The plan Phase 1 produced. |
LOG_FILE | PLAN-REVIEW-LOG.md | Append-only argument transcript. The artifact. |
research | ask | none / web / deep — pre-answers the Phase 0 research gate. deep = the deep-research dynamic workflow (prompt still shown for sign-off first). |
inspect | on | Post-build cross-inspection of Claude-built code by a fresh read-only Codex session. off = skip (logged as an explicit opt-out, never silently). |
MAX_INSPECTION_ROUNDS | 2 | Initial post-build review + one reinspection after accepted fixes. |
If invoked with e.g. rounds=3, use that for MAX_ROUNDS. Echo resolved values before starting.
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(andCONTEXT.md/ADRs for domain language, if present) 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.
(On greenfield there are no repo files — Codex reviews PLAN.md and its ## Assumptions section on their own merits; the assumption sources give it something concrete to attack.)
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's THREAD_ID. The critique is in /tmp/codex-verdict.txt. Confirm success by the verdict file + a thread.started line; if neither appears, the run failed (auth/model) — stop and tell the user. 2>/dev/null suppresses cosmetic MCP/auth stderr noise. < /dev/null is mandatory: codex exec reads 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.
# resume REJECTS -s. Force read-only via -c sandbox_mode, or Codex inherits
# config.toml (possibly danger-full-access) and could WRITE files. This is the
# single most important safety line in the skill — verified 2026-06-04.
codex exec resume "$THREAD_ID" -c sandbox_mode="read-only" --json \
-o /tmp/codex-verdict.txt \
"I revised the plan. Re-review PLAN.md — check whether your prior findings are addressed and flag anything new. End with VERDICT: APPROVED or VERDICT: REVISE." \
< /dev/null 2>/dev/null >/dev/null
Both codex exec and codex exec resume support --json and -o/--output-last-message. The < /dev/null redirect is required on the resume call too — same non-interactive stdin hang as Round 1.
Timeout guard (both rounds): run every codex exec / codex exec resume with a 10-minute ceiling so any future stall fails loud instead of hanging silently. Via Claude Code's Bash tool, pass timeout: 600000 on 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 with timeout 600 (Linux / Git Bash) or gtimeout 600 (macOS via coreutils — stock macOS has no timeout). If the ceiling trips, treat it as a failed run: stop and tell the user rather than retrying blind.
/tmp/codex-verdict.txt; append to LOG_FILE: ## Round <n> — Codex + the full critique.VERDICT: APPROVED → break to Resolution (converged).VERDICT: REVISE → Claude decides what's actually worth acting on (Claude is final arbiter — Codex advises, doesn't command). Revise PLAN_FILE. Append ### Claude's response to LOG_FILE: what changed, what was rejected, why. Increment round.MAX_ROUNDS → break to Resolution (deadlock).PLAN_FILE, a 3-bullet summary of what the loop improved, and the round count. Ask: "Interrogated + survived N rounds of Codex. Implement it now — Codex builds it (/codex-build), Claude builds it, or stop here?" Code only on a yes.If the user picks Codex: invoke the codex-build skill with SPEC_FILE=PLAN.md and the same LOG_FILE — it appends ## Act 3 — Build to the log, so one artifact tells the whole story (reconned → interrogated → reviewed → built → verified). Roles flip: Codex writes the code with full access, Claude reviews the diff and runs the proof. If the user picks Claude, implement directly as usual — then run the post-build cross-inspection (below).
The doctrine is whoever made the thing never checks the thing — that applies to Claude's code too. After Claude implements and the proof gates pass:
codex exec -s read-only, NEW thread — not the Phase 2 thread; the reviewer should see the code cold, not through its own plan critiques). Give it: PLAN.md, the base commit, and the code diff. Ask for PR-style findings — correctness, spec fidelity, edge cases, nothing outside scope — no verdict line needed; this is advisory review, not a gate loop.MAX_INSPECTION_ROUNDS=2 (initial review + one reinspection after accepted fixes).LOG_FILE under ## Post-build inspection: findings verbatim, Claude's dispositions, rounds used. Present the summary alongside the final diff at the human gate.Opt-out: inspect=off at invocation or the user declining at Resolution. Skipping silently is not allowed — the log must show either the inspection or the explicit opt-out. (Cost: one ~2-5 min Codex invocation at the end of the build; forgetting to ask for review is exactly the failure mode this default exists to prevent.)
PLAN.md until the interrogation has actually resolved the decision map with the user (or they invoked the escape hatch).-s read-only first call, -c sandbox_mode="read-only" on every resume (resume has no -s). It never writes.MAX_ROUNDS.LOG_FILE is the deliverable — keep the whole argument.CONTEXT.md stays a glossary only — never implementation details./codex:review. (Code built BY this skill does get reviewed — that's the post-build cross-inspection, and it's on by default.)-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
/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)./codex-reviewA standalone adversarial PLAN-review loop where Claude Code (builder) and OpenAI Codex (read-only critic) tag-team an implementation plan before any code is written. Use this when you ALREADY have a plan or a clear idea and just want the cross-model stress-test — no requirements interview first. Claude drafts/loads the plan into PLAN.md, Codex reviews it in a read-only sandbox and returns VERDICT:APPROVED or VERDICT:REVISE, Claude revises and re-submits to the SAME Codex session (context preserved) until APPROVED or a configurable MAX_ROUNDS cap is hit. Human approves the converged plan before code. Use when the user says "/codex-review", "codex review my plan", "have Codex review my plan", "argue this plan with Codex", "adversarial plan review", "make Claude and Codex argue/fight over the plan", or is about to build something high-stakes (auth, schema, concurrency, migrations, payments) and wants a second-model sanity check on the PLAN before implementation. For a guided requirements interview BEFORE the review, use /grill-me-codex instead. NOT for reviewing already-written CODE (that is the Codex plugin's /codex:review) and NOT for trivial changes.Other plugins' skills for the same job