Codex cli

From kortix-ai/suna · View interactive version

Codex cli is an AI agent skill from the GitHub repository kortix-ai/suna. Drive OpenAI's Codex CLI (`codex exec`) as a non-interactive coding sub-agent from inside Claude Code. Load WHENEVER you want to delegate a coding/analysis/refactor task to Codex, get a second opinion / adversarial review from another model, fan out parallel agents across files or worktrees, or run

How to use this skill

Skill file

<skill name="codex-cli">

<overview>

Codex CLI is OpenAI's terminal coding agent (Rust). Its non-interactive mode,

codex exec, makes it a perfect disposable sub-agent: you write the metaprompt,

Codex explores/edits/runs commands on its own, and returns a final message you

capture and verify. You stay the long-context planner; Codex is the implementer.

The golden rule: Codex's self-report is a claim, not the truth. Always

capture its output, then independently verify the artifacts yourself (read the

files, re-run the tests) before treating the task as done.

Verified available on this machine: codex-cli 0.137.0, logged in via ChatGPT

(no API key needed). Confirm with codex login status.

</overview>

<the-core-command>

The one shape you'll use most:

codex exec \
  --cd <workdir> \
  --sandbox <read-only|workspace-write|danger-full-access> \
  -o /tmp/codex_<rand>.txt \
  "your metaprompt here"  2>>/tmp/codex_<rand>.log

(good for long/generated prompts). If both are given, stdin is appended.

file. This is your clean capture; read it back, don't scrape the TUI stream.

message goes to stdout. Redirect stderr to a log so it doesn't bloat your

context. Generate the suffix with openssl rand -hex 4.

(e.g. apps/api), not the whole monorepo, so it stays focused.

</the-core-command>

<sandbox-tiers>

Pick the least privilege that lets the task succeed:

edit files or hit the network. Use for review, analysis, planning, "find the

bug", second opinions.

commands, but no network by default. Use for real implementation/refactors.

dirs you fully control.

Approvals: in exec mode Codex does not prompt for approvals. For a fully

autonomous run with no gating at all, add

--dangerously-bypass-approvals-and-sandbox. This is powerful — only use it when

the user has explicitly authorized autonomous edits AND the --cd is scoped, or

when running in an already-sandboxed/throwaway dir. When unsure, ask the user

which sandbox tier before running with write access.

</sandbox-tiers>

<output-modes>

messages). Use when you want to parse what Codex actually did, not just its

prose summary.

JSON Schema. Use for reliable structured hand-back (e.g. a list of findings).

--add-dir <dir> — extra writable roots. --ephemeral — don't persist the

session to disk.

</output-modes>

<session-resume>

Codex sessions are stateful. To continue a prior run with its context intact:

codex exec resume --last "now also update the tests"   # most recent session
codex exec resume <session-id> "..."                   # a specific one

The session id is printed at the start of each exec run. Use resume for

multi-turn delegation (draft → refine → fix) instead of re-sending all context.

</session-resume>

<delegation-patterns>

or critique your diff. Different model, different blind spots.

the tests (or vice-versa). Cross-checking catches more.

runs, each with its own -o/log file. To avoid edit collisions when multiple

WRITE runs touch the repo at once, give each its own git worktree

(git worktree add) and point --cd there.

long-context work → keep it yourself.

</delegation-patterns>

<the-supervision-loop>

Never skip this. After every delegated run:

  1. Delegate — codex exec ... -o <out> 2>><log>.
  2. Capture — read <out> (and <log>/--json if you need detail).
  3. Verify INDEPENDENTLY — do not trust Codex's "tests pass" / "done":
  1. Iterate — if wrong, codex exec resume --last "<correction>" and repeat.
  2. Report — tell the user what changed, what you verified, and how. State

plainly when something failed or was skipped.

Cleanup: remove /tmp/codex_* capture/log files (and any throwaway worktrees)

when done.

</the-supervision-loop>

<repo-specifics>

In this repo, respect the existing skills: prefer the worktree skill

(pnpm worktree) for isolated parallel Codex runs, and the testing and

migration skills' rules still apply to anything Codex produces — verify against

them. A Codex run is not a license to bypass repo conventions; you own the result.

</repo-specifics>

</skill>

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.