/codex-build:codex-buildfrom codex-build
Orchestrates a plan-driven build where Claude sequences tasks, briefs OpenAI Codex to write all product code, reviews diffs, runs tests before each commit, and opens one PR.
Ships in codex-build. 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; scripts run unread.
You (the agent running this skill) are the orchestrator. A separate model,
OpenAI Codex (codex exec), is the coder. You never write product code;
Codex does. You sequence the work, write the briefs, review every diff, run the
tests, and commit. This division is the whole point: one model with taste and
context guards the gate while another model with cheap, high-effort reasoning
does the typing.
codex exec. Model and effort are pinned per invocation (see Config) — never
rely on config defaults silently, or a codex upgrade will change your
builds out from under you.| Variable | How to resolve | Default |
|---|---|---|
MODEL | --model arg, else $CODEX_BUILD_MODEL, else your Codex config default | pin one you have access to (see below) |
EFFORT | second positional arg, else $CODEX_BUILD_EFFORT | high (opt into xhigh/max for hard/architectural work) |
TRACKER | detect: bd on PATH → beads, else markdown | markdown |
Pin a model. List what your account exposes from the CLI's model cache:
python3 -c 'import json,os;d=json.load(open(os.path.expanduser("~/.codex/models_cache.json")));print([m["slug"] for m in d["models"]])'
Then check ~/.codex/config.toml for the configured default. Current slugs
(Codex CLI 0.165, Oct 2026; re-list them, the catalog moves):
| Slug | Tier | Efforts accepted | Use for |
|---|---|---|---|
gpt-6-astra | most capable | low…max (+ultra, see below) | hard/architectural tasks, gnarly refactors |
gpt-6.1-sol | latest workhorse | low…max (+ultra) | default coder for most plans |
gpt-6.1-terra | balanced | low…max (+ultra) | everyday tasks when Sol quota is tight |
gpt-6-luna | fast/cheap | low…max | trivial-mechanical tasks only |
gpt-6-sol and gpt-5.6-sol/terra/luna are still listed as older generations.
Retired: gpt-5-codex, gpt-5.4, gpt-5.5 (Codex rejects them on ChatGPT
accounts). Announce the resolved
MODEL/EFFORT to the user before starting so the run is reproducible. If the
CLI rejects max, fall back to xhigh; if it rejects xhigh, fall back to
high — and tell the user. Never use ultra: it enables automatic task
delegation (Codex spawning its own sub-agents), which breaks the one-task,
one-scope-check, one-commit contract this skill depends on.
codex-build <plan-file> [effort] [--model <name>]
<plan-file> — a Markdown plan with an ordered task list (T1..Tn), each
task naming its files, constraints, and test commands. See
references/plan-example.md for the shape. If the
plan has prose but no task list, extract one and show it to the user before
coding.[effort] — high (default) | xhigh | max. (ultra is rejected; see Config.)codex --version. If Codex isn't authed, codex exec "reply OK" -s read-only
fails — stop and tell the user to run codex login.codex exec "Reply with the single word READY" \
-m "$MODEL" -c model_reasoning_effort="$EFFORT" -s read-only --ephemeral < /dev/null
If max is rejected, fall back to xhigh; if xhigh is rejected, fall back
to high — and tell the user.
Always redirect < /dev/null on every codex exec (see Rails) — without
it, a non-interactive run hangs forever on "Reading additional input from
stdin…" instead of doing the work.REPO_ROOT = git rev-parse --show-toplevel.GIT_DIR = git rev-parse --absolute-git-dir (this is worktree-specific).SKILL_DIR = the directory containing this SKILL.md.$GIT_DIR/codex-build/. This keeps orchestration state off the
product diff while making it survive context compaction and process restarts.current points to an active run for this branch, read its run.md,
tasks.md, interfaces.md, and active allowlist before doing anything else.
Confirm its last recorded commit still matches HEAD; stop on a mismatch
instead of guessing. An in-flight task may legitimately have a dirty
worktree: immediately run its saved scope check before any new Codex call.
If current describes another branch or an inconsistent run, stop rather
than overwriting it.git status --porcelain. The task loop starts
clean so its scope check can attribute every changed path to the active task.
If the checkout is dirty, preserve it and create an isolated worktree from
the intended base (or stop and ask); never discard or absorb pre-existing
work.REPO_ROOT and GIT_DIR.runs/<run-id>/, write the run id to current, and
create run.md, tasks.md, interfaces.md, and allowlists/. run.md
records the plan path and content hash, branch/base, model, effort, tracker,
and run status. Set STATE_DIR to that run directory. Never put secrets in
run state. For a resumed run, set STATE_DIR from current instead.The durable layout is:
$GIT_DIR/codex-build/
current
runs/<run-id>/
run.md
tasks.md
interfaces.md
allowlists/T1.txt
The loop is identical regardless of tracker; only the bookkeeping commands differ.
markdown (default, zero install): keep the - [ ] / - [x] checklist in
the run's durable tasks.md. "Claim" = note the task in-flight; "close" =
check the box with the commit hash and test evidence.beads (optional, if bd is on PATH): richer dependency tracking.
bd prime for context; one bead per task (bd create, title = task title,
description = plan excerpt + file paths, dependencies per the plan); claim with
bd update <id> --claim; close with bd close <id>. Mirror task status and
commit/test evidence to durable tasks.md so a resumed run has one local
recovery record. Install:
https://github.com/steveyegge/beads.Turn the plan's task list into tracker units in dependency order. Each unit records: goal, the plan excerpt (verbatim constraints, file paths, schema/copy blocks), and its declared file scope (the files it is allowed to touch). The file scope is enforced by an executable check — everything else is out of bounds.
For every task, write its scope to allowlists/<task-id>.txt: one exact,
repo-relative file path per non-empty line. Use / separators; no absolute
paths, directories, ./.., comments, or globs. A rename declares both old and
new paths. If the plan genuinely needs another file, amend the allowlist before
Codex touches it and record the reason in tasks.md; never expand scope merely
because an unexpected path appeared in the diff.
Initialize interfaces.md as the canonical cross-task contract. It starts with
"greenfield — no prior interfaces" and is updated only from committed source in
step 6 below.
For each task, in dependency order:
Claim it in the tracker.
For a newly claimed task, confirm the product worktree is clean before invoking Codex. Durable state is under the Git directory, so it does not make the worktree dirty. When resuming an already in-flight task, the worktree may contain its changes; run the saved allowlist check immediately instead.
Brief Codex. Compose a self-contained prompt — Codex sees only what you
give it. Use references/codex-brief.md as the
skeleton. It must carry:
exec is stateless across invocations; if you don't pass the contract, it
guesses and drifts.codex exec "<brief>" -C "$(git rev-parse --show-toplevel)" -s workspace-write \
-m "$MODEL" -c model_reasoning_effort="$EFFORT" < /dev/null
Never use --dangerously-bypass-approvals-and-sandbox. The < /dev/null is
mandatory (see Rails).
Enforce scope, then review the diff yourself. This is your job, not Codex's.
python3 "$SKILL_DIR/scripts/check_scope.py" \
--repo "$REPO_ROOT" \
--allowlist "$STATE_DIR/allowlists/<task-id>.txt"
The checker compares tracked, staged, deleted, renamed, and non-ignored
untracked paths against the on-disk allowlist. A non-zero exit is a hard
stop: correct the drift or deliberately amend the allowlist with a reason.
Do not rely on visual review to enforce scope.git diff --stat and the diff itself. For a small diff, every
line. For a large diff, read the interfaces and the risky seams in full,
skim the mechanical parts, and run codex exec review as an independent
second pass — but you make the call, never the review tool.codex exec resume --last "<specific corrections>" < /dev/null
(same -m/-c flags). Be concrete about what's wrong; vague corrections
waste a round-trip.Test gate — BEFORE any commit. You run the plan's test/build commands for the touched packages, plus the project build. A task is committable only when the gate is green. Red → back to step 3 with the failure output in the resume brief. Never commit red. Never skip the gate because "it's small." The gate is the reason this skill exists.
Commit — one task = one commit.
check_scope.py immediately before staging. Tests and build tools can
create files too; this final check must still be green.git add <paths>. Never git add -A — it
sweeps up stray files Codex or a tool left behind.<type>: <imperative summary> (+ tracker id if using beads) with a
short body: what changed, why, and a one-line test-evidence note.Update the durable interfaces ledger. After the green commit, inspect the
committed source and append the public surface this task created — exact
function signatures, exported types, routes/endpoints, config keys, and file
paths — to interfaces.md. Tag the entry with task id and commit hash. If a
later task changes a contract, append a superseding entry; do not silently
leave stale guidance. Record "No public interface changes" when applicable.
The relevant ledger slice feeds step 2 of the next task and is reloaded after
compaction, keeping Codex from re-inventing or mismatching contracts.
Close the task in the tracker with a one-line note. Persist the status,
tests, and commit hash to tasks.md before giving the user a brief progress
line and moving on.
git pull --rebase then git push. git status must show up-to-date with
origin. On rebase conflicts, resolve minimally and re-run the gate — never
force-push over shared history.gh pr create. GitLab: glab mr create. No forge CLI: push the
branch and give the user the compare URL to open the PR themselves.run.md complete and record the final commit, gate evidence, and PR URL.run.md, tasks.md,
task allowlists, and interfaces.md, never the only copy of run state.codex exec gets < /dev/null. With a prompt passed as an argument
and an open stdin, codex exec blocks indefinitely on "Reading additional
input from stdin…" and never runs. Redirecting stdin from /dev/null gives it
immediate EOF so it proceeds. This is the single most common way to make the
whole run silently hang.high/xhigh/max. A trivial-mechanical task may drop to high
(never lower, never ultra); note it.Codex will run git commit AND git push unbidden. Observed mid-run: a
correction round ended "complete and pushed" with nothing in the brief asking
for it — one round after the same session reported .git was read-only.
Capability varies between rounds; never infer from one round that git is
unavailable to it. Put this block, verbatim, at the top of every brief:
## ABSOLUTE PROHIBITION — NO GIT WRITES, NO bd, NO xcodegen
Do NOT run git commit, push, add, stash, checkout, reset, or any writing git command.
Do NOT run `bd` (it writes to git). Leave your work as uncommitted changes.
Read-only git (status, diff, log) is fine.
Verify rather than trust: capture git rev-parse HEAD before each Codex call
and compare after. A moved HEAD is a hard stop.
The bd ban holds even on beads repos. Codex will obey the repo's own
AGENTS.md and run bd prime, which internally attempts git add and rewrites
.beads/issues.jsonl. Tracker writes belong to the orchestrator only.
codex exec resume rejects -C and -s (error: unexpected argument '-C' found). It inherits cwd — and filters recorded sessions by it — and
inherits the resumed session's sandbox. Working shape:
cd "$REPO_ROOT" && codex exec resume --last "<corrections>" \
-m "$MODEL" -c model_reasoning_effort="$EFFORT" < /dev/null
The < /dev/null is still mandatory on resume.
xcodebuild is impossible inside Codex's sandbox. Xcode's SwiftPM
local-package resolution spawns a nested sandbox-exec the outer sandbox
refuses (sandbox_apply: Operation not permitted); swift test works. Treat
every Codex build claim as unverified — the orchestrator runs the build gate.
Say so in the brief so Codex doesn't waste rounds retrying with cache
redirection.
Exit 144 means resume, don't restart. A codex exec run killed mid-stream
(e.g. a usage-limit kill; log ends mid-diff with no error banner) exits 144
with the working tree intact. Grep the log head for session id: and
codex exec resume <session-id> from the repo cwd — no -C/-s,
< /dev/null still required.
Codex's sandbox denies Go module cache writes. go test fails with
open ~/go/pkg/mod/cache/download/....lock: operation not permitted — an
environment failure that reads like a code failure and triggers identical
patch retries. Brief Codex to set a workspace-local
GOMODCACHE=$PWD/.gomodcache, or run the test gate yourself outside the
sandbox.
scripts/check_scope.py — executable file-scope gate.references/codex-brief.md — the Codex brief skeleton (the highest-leverage part).references/plan-example.md — the shape of an input plan.references/walkthrough.md — a full trace of one task, start to finish.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
codex, orchestration, plan-driven, code-generation, pr-workflow
npx claudepluginhub cathrynlavery/codex-build --plugin codex-buildOther plugins' skills for the same job