# Codex CLI Sub-Agent

Runs Codex CLI as a non-interactive coding sub-agent for delegated tasks and reviews.

- Repository: https://github.com/kortix-ai/suna (20345 stars)
- Category: AI and agents
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add kortix-ai/suna --skill codex-cli -g -a claude-code -y`
Codex: `npx skills add kortix-ai/suna --skill codex-cli -g -a codex -y`
Cursor: `npx skills add kortix-ai/suna --skill codex-cli -g -a cursor -y`
Gemini CLI: `npx skills add kortix-ai/suna --skill codex-cli -g -a gemini-cli -y`

## Description

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 a long mechanical job while you stay the planner. Covers the exact `codex exec` flags, sandbox tiers, output capture, JSON/schema modes, session resume, parallel fan-out, and the mandatory "delegate → capture → independently verify, never trust the self-report" supervision loop.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

<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:

```bash
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
```

- Prompt as the final arg, OR pipe via stdin: `echo "$PROMPT" | codex exec -`
  (good for long/generated prompts). If both are given, stdin is appended.
- `-o, --output-last-message <file>`, writes ONLY Codex's final message to a
  file. This is your clean capture; read it back, don't scrape the TUI stream.
- `2>>/tmp/...log`, Codex streams progress/reasoning to **stderr**; the final
  message goes to **stdout**. Redirect stderr to a log so it doesn't bloat your
  context. Generate the suffix with `openssl rand -hex 4`.
- `--cd <dir>`, Codex's working root. Scope it to the relevant subdir
  (e.g. `apps/api`), not the whole monorepo, so it stays focused.
- `--skip-git-repo-check`, only needed when running outside a git repo.
</the-core-command>

<sandbox-tiers>
Pick the **least** privilege that lets the task succeed:

The rest: https://github.com/kortix-ai/suna/blob/HEAD/.agents/skills/codex-cli/SKILL.md
