Skip to content

Codex CLI

Wrap Codex CLI with ait so each session runs in an isolated Git worktree with full provenance.

Why wrap Codex with ait

  • Codex changes are confined to an attempt worktree — your root checkout is untouched until you apply.
  • Failed sessions remain available for inspection, not silently dropped.
  • Successive Codex runs feed ait's repo-local memory, so the next session can recall what was already tried.

Setup

ait init                  # detects `codex` on PATH, auto-installs hook + wrapper
ait adapter doctor codex  # optional sanity check

ait init writes .codex/hooks.json and the bridge under .ait/adapters/codex/ automatically when codex is on $PATH. Use ait adapter setup codex to re-run the install explicitly.

Run Codex under ait

Direct invocation works after setup:

codex

Or wrap explicitly with intent:

ait run --adapter codex --intent "Implement parser edge cases" -- codex

For scripted codex exec runs, prefer closing stdin explicitly:

ait run --adapter codex --stdin none -- \
  codex exec --sandbox read-only --skip-git-repo-check -C <workspace> "<prompt>"

ait run --stdin auto is the default. It preserves stdin for interactive Codex sessions, but automatically uses /dev/null for non-interactive codex exec invocations, or when codex exec already has a prompt in argv. Pass --stdin inherit when the wrapped codex exec command must read from stdin.

Repair and refresh

If the wrapper drifts (e.g. after upgrading Codex):

ait repair codex

Review attempts

ait attempt list
ait attempt show <attempt-id>
ait memory recall "parser edge cases"

See also