Codex Delegation
codex is an installed CLI agent backed by GPT-6 astra — cheap, strong, and
independent of this session's blind spots. Prefer it for: adversarial review of
a design or plan, pre-PR code review, root-causing a bug, adding tests to probe
behavior, and implementing well-scoped tasks. The independence is the value: it
was not part of writing the thing it reviews.
Invocation
codex exec -m gpt-6-astra -c model_reasoning_effort=xhigh \
--dangerously-bypass-approvals-and-sandbox \
-o /tmp/codex-<topic>.md \
"<prompt>"
- Always pass
-o — it writes the final reply to a file; stdout mixes it into
the transcript and truncates easily. -o holds only the last assistant
message: never point it at a file the prompt asks codex to write its report
to (or one it might guess) — the message overwrites the report. When the
prompt names a report file, give -o a clearly different name
(*-final-message.md).
- The full bypass is deliberate: the sandbox breaks builds and tooling. Codex
therefore runs with your permissions — scope the prompt accordingly.
- xhigh runs take minutes to tens of minutes: run in the background and keep
working, no sleep polling. A background
codex exec must get < /dev/null:
with a non-TTY stdin it reads the pipe for extra input and blocks forever
(the prompt argument does not help). The same applies to Node — spawn it
with stdio: ["ignore", ...]. Right after launch, head the log and
confirm the session id header appeared; a live process alone proves
nothing.
- The startup header prints
session id: <uuid> — capture it whenever a
follow-up round is plausible.
- If
gpt-6-astra is rejected (plan/auth), drop -m to use the account
default, and say so when reporting results.
-c service_tier=fast switches the run to the fast service tier; use it
when the maintainer asks for speed (long migrations, translation passes).
- Prompt shape: the task, the exact files/commands in scope, and the answer
format you want (e.g. "numbered findings, each with a minimal
counterexample"). Codex reads files itself — point at paths instead of
pasting content.
- Codex does not auto-load
.claude/ docs — it discovers only AGENTS.md,
which this repo does not have. Any run that should follow project rules
(review, test writing, implementation) must be told in the prompt which
rule files to read first, e.g. .claude/CLAUDE.md and the cpp-style skill.
The canonical code-review invocation is the standard form with a prompt that
loads the repo rules and reviews the branch diff:
codex exec -m gpt-6-astra -c model_reasoning_effort=xhigh \
--dangerously-bypass-approvals-and-sandbox -o /tmp/codex-review-<topic>.md \
"Read .claude/CLAUDE.md and .claude/skills/cpp-style/SKILL.md and apply
their rules. Review the changes in 'git diff origin/main...HEAD' for
correctness, style, and test coverage. Report ranked findings, each with
file:line and a concrete failure scenario."
The built-in codex exec review --base origin/main collects the diff itself,
but --base is mutually exclusive with the prompt argument, so it can never
see the repo rules — use it only as a quick rules-blind supplementary pass
(also --uncommitted, --commit <sha>).
Multi-round sessions
codex exec resume <session-id> "<follow-up>" continues with full context
(--last picks the newest session). Use it for successive adversarial rounds,
"now fix what you found", or clarifying questions — never restate context in a
fresh session. Execution-scoped flags are NOT inherited from the resumed
session: repeat -m gpt-6-astra, -c model_reasoning_effort=xhigh,
--dangerously-bypass-approvals-and-sandbox, and a fresh -o path on every
resume, or the follow-up silently runs on the default model at default
effort, sandboxed, and without an output file. codex exec fork <session-id> branches one history
into independent continuations.
Wording
Prompts and everything codex reads go through OpenAI's cybersecurity
filter, which judges phrasing, not intent, and kills the session mid-run
(the content stays in that session's history, so resume trips it again —
only a fresh session recovers). Rules:
- Use QA vocabulary: "review", "latent correctness defects", "regression
check". Never "attack surface", "hunt/dig for bugs", "fabricate the
conditions for the bug"; a negative control is "a control variant expected
to fail". Open with the fact that this is routine quality work on our own
open-source project (the repo's git config and LICENSE back it up).
- Do not feed codex internal notes written in hunting slang — extract the
scope into a neutral file and keep the ledger edits on this side. Ask for
terse, report-only output: long analytical prose triggers the filter too.
- Successive rounds
resume the same session (or list the prior findings
as exclusions), or the round re-reports what is already known.
Discipline
- Codex output is hypothesis, not verdict. Every concrete claim ("this
input breaks it") gets an empirical probe before you act on it; "looks fine"
carries no weight. Experience runs both ways — codex has correctly refuted
arguments this side was sure of, and confidently asserted things a probe then
disproved. The probe decides, never authority.
- Adversarial loop (plans/designs): write the doc → codex attacks it
(demand concrete counterexamples, not general commentary) → probe each
counterexample → revise the doc, recording adopted and refuted findings →
resume the session for the next round. Stop when a round yields no new
confirmed finding.
- When codex edits code (implementation, debug fixes, new tests): review
its diff as you would a PR — you own what gets committed. Verification
(build + suites) happens in the main session, and the hard rules (never
weaken tests, never push unverified) apply unchanged to codex-authored code.
Any run that may modify files gets its own git worktree — the main checkout
is for analysis-only runs, or edits will race with this session's.
- Never let codex run the integration or snap suites while this session
might also run them — concurrent runs in one checkout clobber each other's
workspace
.clice. Either codex runs them and you don't, or codex analyzes
and you verify.
- Keep codex's raw output out of the main context. Progress checks on a
background run (log tail, new commits, report landed?) and the review of a
codex-authored diff go through a cheaper subagent that returns a digest or
ranked findings; the main session spot-checks and decides.
Recipes
- Plan review: point it at the doc path; ask for attacks ranked by
severity, each with a minimal counterexample. Fold confirmed findings back
into the doc.
- Code review: the canonical review command above — the primary
self-review pass of the pr skill.
- Debug: give the failing test, the repro command, and the suspect area;
ask for a root-cause hypothesis plus the experiment that would confirm it.
Let it run the repro itself.
- Test writing: point it at the write-tests skill and 2-3 neighboring
fixtures as the template; ask it to add cases probing a specific behavior
and report which outputs look wrong versus expected. Suspicious snapshot
diffs are findings — never
UPDATE_SNAPSHOTS over them.
- Implementation: a well-scoped task with acceptance criteria and pointers
to the 2-3 existing features whose structure it should copy. Then review and
verify as above.
Recovery
To stop a hung run, kill the PID you recorded at launch ($! for a shell
background job, the task's PID otherwise) and its subtree — other codex
runs may be live in parallel. When the PID is lost, pgrep -af 'codex exe[c]' lists the candidates to pick from; never pkill -f 'codex exec',
which matches your own shell's command line and kills it.
If a run dies before writing -o, the transcript is at
~/.codex/sessions/YYYY/MM/DD/*.jsonl; the final reply is the last record
with payload type == "message" and role == "assistant". These transcripts
persist indefinitely and record full prompts, file contents, and command
output — treat ~/.codex/sessions/ as sensitive local data.
1---2name: codex3description: Drive the codex CLI (GPT-6 astra) as a delegate — adversarial plan review, code review, debugging, test writing, scoped implementation. Read BEFORE invoking codex.4---56# Codex Delegation78`codex` is an installed CLI agent backed by GPT-6 astra — cheap, strong, and9independent of this session's blind spots. Prefer it for: adversarial review of10a design or plan, pre-PR code review, root-causing a bug, adding tests to probe11behavior, and implementing well-scoped tasks. The independence is the value: it12was not part of writing the thing it reviews.1314## Invocation1516```bash17codex exec -m gpt-6-astra -c model_reasoning_effort=xhigh \18 --dangerously-bypass-approvals-and-sandbox \19 -o /tmp/codex-<topic>.md \20 "<prompt>"21```2223- Always pass `-o` — it writes the final reply to a file; stdout mixes it into24 the transcript and truncates easily. `-o` holds only the last assistant25 message: never point it at a file the prompt asks codex to write its report26 to (or one it might guess) — the message overwrites the report. When the27 prompt names a report file, give `-o` a clearly different name28 (`*-final-message.md`).29- The full bypass is deliberate: the sandbox breaks builds and tooling. Codex30 therefore runs with your permissions — scope the prompt accordingly.31- xhigh runs take minutes to tens of minutes: run in the background and keep32 working, no sleep polling. A background `codex exec` must get `< /dev/null`:33 with a non-TTY stdin it reads the pipe for extra input and blocks forever34 (the prompt argument does not help). The same applies to Node — spawn it35 with `stdio: ["ignore", ...]`. Right after launch, `head` the log and36 confirm the `session id` header appeared; a live process alone proves37 nothing.38- The startup header prints `session id: <uuid>` — capture it whenever a39 follow-up round is plausible.40- If `gpt-6-astra` is rejected (plan/auth), drop `-m` to use the account41 default, and say so when reporting results.42- `-c service_tier=fast` switches the run to the fast service tier; use it43 when the maintainer asks for speed (long migrations, translation passes).44- Prompt shape: the task, the exact files/commands in scope, and the answer45 format you want (e.g. "numbered findings, each with a minimal46 counterexample"). Codex reads files itself — point at paths instead of47 pasting content.48- Codex does not auto-load `.claude/` docs — it discovers only `AGENTS.md`,49 which this repo does not have. Any run that should follow project rules50 (review, test writing, implementation) must be told in the prompt which51 rule files to read first, e.g. `.claude/CLAUDE.md` and the cpp-style skill.5253The canonical code-review invocation is the standard form with a prompt that54loads the repo rules and reviews the branch diff:5556```bash57codex exec -m gpt-6-astra -c model_reasoning_effort=xhigh \58 --dangerously-bypass-approvals-and-sandbox -o /tmp/codex-review-<topic>.md \59 "Read .claude/CLAUDE.md and .claude/skills/cpp-style/SKILL.md and apply60their rules. Review the changes in 'git diff origin/main...HEAD' for61correctness, style, and test coverage. Report ranked findings, each with62file:line and a concrete failure scenario."63```6465The built-in `codex exec review --base origin/main` collects the diff itself,66but `--base` is mutually exclusive with the prompt argument, so it can never67see the repo rules — use it only as a quick rules-blind supplementary pass68(also `--uncommitted`, `--commit <sha>`).6970## Multi-round sessions7172`codex exec resume <session-id> "<follow-up>"` continues with full context73(`--last` picks the newest session). Use it for successive adversarial rounds,74"now fix what you found", or clarifying questions — never restate context in a75fresh session. Execution-scoped flags are NOT inherited from the resumed76session: repeat `-m gpt-6-astra`, `-c model_reasoning_effort=xhigh`,77`--dangerously-bypass-approvals-and-sandbox`, and a fresh `-o` path on every78resume, or the follow-up silently runs on the default model at default79effort, sandboxed, and without an output file. `codex exec fork <session-id>` branches one history80into independent continuations.8182## Wording8384Prompts and everything codex reads go through OpenAI's cybersecurity85filter, which judges phrasing, not intent, and kills the session mid-run86(the content stays in that session's history, so `resume` trips it again —87only a fresh session recovers). Rules:8889- Use QA vocabulary: "review", "latent correctness defects", "regression90 check". Never "attack surface", "hunt/dig for bugs", "fabricate the91 conditions for the bug"; a negative control is "a control variant expected92 to fail". Open with the fact that this is routine quality work on our own93 open-source project (the repo's git config and LICENSE back it up).94- Do not feed codex internal notes written in hunting slang — extract the95 scope into a neutral file and keep the ledger edits on this side. Ask for96 terse, report-only output: long analytical prose triggers the filter too.97- Successive rounds `resume` the same session (or list the prior findings98 as exclusions), or the round re-reports what is already known.99100## Discipline101102- **Codex output is hypothesis, not verdict.** Every concrete claim ("this103 input breaks it") gets an empirical probe before you act on it; "looks fine"104 carries no weight. Experience runs both ways — codex has correctly refuted105 arguments this side was sure of, and confidently asserted things a probe then106 disproved. The probe decides, never authority.107- **Adversarial loop** (plans/designs): write the doc → codex attacks it108 (demand concrete counterexamples, not general commentary) → probe each109 counterexample → revise the doc, recording adopted and refuted findings →110 `resume` the session for the next round. Stop when a round yields no new111 confirmed finding.112- **When codex edits code** (implementation, debug fixes, new tests): review113 its diff as you would a PR — you own what gets committed. Verification114 (build + suites) happens in the main session, and the hard rules (never115 weaken tests, never push unverified) apply unchanged to codex-authored code.116 Any run that may modify files gets its own git worktree — the main checkout117 is for analysis-only runs, or edits will race with this session's.118- **Never let codex run the integration or snap suites while this session119 might also run them** — concurrent runs in one checkout clobber each other's120 workspace `.clice`. Either codex runs them and you don't, or codex analyzes121 and you verify.122- **Keep codex's raw output out of the main context.** Progress checks on a123 background run (log tail, new commits, report landed?) and the review of a124 codex-authored diff go through a cheaper subagent that returns a digest or125 ranked findings; the main session spot-checks and decides.126127## Recipes128129- **Plan review**: point it at the doc path; ask for attacks ranked by130 severity, each with a minimal counterexample. Fold confirmed findings back131 into the doc.132- **Code review**: the canonical review command above — the primary133 self-review pass of the pr skill.134- **Debug**: give the failing test, the repro command, and the suspect area;135 ask for a root-cause hypothesis plus the experiment that would confirm it.136 Let it run the repro itself.137- **Test writing**: point it at the write-tests skill and 2-3 neighboring138 fixtures as the template; ask it to add cases probing a specific behavior139 and report which outputs look wrong versus expected. Suspicious snapshot140 diffs are findings — never `UPDATE_SNAPSHOTS` over them.141- **Implementation**: a well-scoped task with acceptance criteria and pointers142 to the 2-3 existing features whose structure it should copy. Then review and143 verify as above.144145## Recovery146147To stop a hung run, kill the PID you recorded at launch (`$!` for a shell148background job, the task's PID otherwise) and its subtree — other codex149runs may be live in parallel. When the PID is lost, `pgrep -af 'codex150exe[c]'` lists the candidates to pick from; never `pkill -f 'codex exec'`,151which matches your own shell's command line and kills it.152153If a run dies before writing `-o`, the transcript is at154`~/.codex/sessions/YYYY/MM/DD/*.jsonl`; the final reply is the last record155with payload `type == "message"` and `role == "assistant"`. These transcripts156persist indefinitely and record full prompts, file contents, and command157output — treat `~/.codex/sessions/` as sensitive local data.