Codex
Codex is OpenAI’s coding agent: it reads a repository, runs commands inside a sandbox, edits files and reviews diffs from the CLI, a desktop app, IDE extensions and Codex cloud. Its bundled default model is GPT-6 Astra. The sandbox, the approval policy and the repository’s own gates, not the model, decide whether its output can be trusted.
This hub serves developers adopting Codex and tech leads standardising it. A common starting point: Codex finishes the task, but a script still passes the removed --full-auto flag, AGENTS.md does not name the test command, and you read every diff to find out whether anything broke.
What this Codex guide gives you
Section titled “What this Codex guide gives you”- A first change taken from a read-only plan to a reviewed diff.
- A permission setting for each kind of session, from planning to CI.
- A verification stack, so you sign off on evidence, not lines of code.
Which Codex surface should you start on?
Section titled “Which Codex surface should you start on?”Local surfaces share ~/.codex/config.toml, AGENTS.md, skills and MCP servers; Codex cloud has its own environments.
| Surface | Start it with | Reach for it when |
|---|---|---|
| CLI (TUI) | codex in the repository root | You want plan mode, worktrees and every flag |
| Non-interactive CLI | codex exec "…" | Scripts and CI need JSONL events (--json) or schema-shaped output (--output-schema) |
| Desktop app | codex app (macOS and Windows) | Parallel threads, each in its own worktree |
| IDE extension | VS Code, Cursor and Windsurf (now Devin Desktop), per OpenAI’s README | You want the agent beside the file you are editing |
| Codex cloud | chatgpt.com/codex, or codex cloud (experimental) | Long background tasks, or @codex review on a pull request |
Installation covers every surface, including JetBrains and Xcode. For model choice and prices, see the models hub.
How do you ship a first verified change with Codex?
Section titled “How do you ship a first verified change with Codex?”You need a Git repository with a clean working tree and a short spec committed at docs/specs/login-rate-limit.md.
-
Install Codex, sign in and check the installation (terminal):
Terminal window npm install -g @openai/codexcodex logincodex doctor -
Start
codexin the repository root, accept the trust prompt, and run/initto generateAGENTS.md. Edit it until it names the exact typecheck, lint and test commands. -
Paste the planning prompt below (it starts with
/plan) before the agent starts a turn, and approve the plan. Copy the approved plan intodocs/plans/login-rate-limit.mdyourself (plan mode edits no file), then commit it withAGENTS.md. -
Start a session in a managed Git worktree with
codex --worktreeand paste the build prompt. -
Check the reported commands and exit statuses, then review the diff from inside the worktree:
Terminal window codex review --uncommittedOpen a pull request; required checks and a named reviewer gate it.
Which sandbox and approval policy should a Codex session use?
Section titled “Which sandbox and approval policy should a Codex session use?”Codex separates what a command may touch (the sandbox) from when it asks you first (the approval policy). In 0.157.1, -a accepts only on-request (the default) and never.
OpenAI prefers permission profiles (beta, CLI 0.138.0 or later), selected with -c default_permissions="<profile>" or in config.toml. The legacy --sandbox flag still works, but the two do not compose, so pick one per session (configuration guide).
| Session | Setting | Watch out for |
|---|---|---|
| Planning and review | /plan; or profile :read-only (-c default_permissions=":read-only"), or legacy --sandbox read-only | Enter /plan before a turn, not mid-run |
| Interactive build in a worktree | Profile :workspace (-c default_permissions=":workspace"), or legacy --sandbox workspace-write, with on-request approvals | Approving without reading |
| Long unattended local run | --approve-for-me (a reviewer model approves inside workspace-write) | Judges sandbox escapes, not correctness |
| CI job | codex exec -c default_permissions=":read-only" (or legacy --sandbox read-only) for review; :workspace or workspace-write for fixes | codex exec already runs with approval never and has no -a |
| Full access | --dangerously-bypass-approvals-and-sandbox | Disposable, network-restricted runners only |
How do you know Codex’s output is right without reading every line?
Section titled “How do you know Codex’s output is right without reading every line?”Each layer enforces what the one above asks for:
-
AGENTS.mdnames the gates but enforces nothing (AGENTS.md for Codex). -
Hooks and rules enforce. Trusted hooks in
.codex/hooks.jsonrun whatever the prompt says;.rulesfiles decide which commands may leave the sandbox. -
codex reviewre-reads the diff (--uncommitted,--baseor--commit). -
CI re-runs the gates, and a read-only review adds a machine-readable second opinion:
Terminal window codex exec -c default_permissions=":read-only" \--output-schema .github/codex/schemas/findings.json \"Review the diff between origin/main and HEAD against docs/specs/login-rate-limit.md. Report only blocking findings, each with file, line, and the behaviour that fails."The findings schema is in Codex in CI/CD.
-
A human signs off on the evidence bundle, not every line (why evidence beats diffs).
What breaks first when you adopt Codex?
Section titled “What breaks first when you adopt Codex?”- “unexpected argument”. 0.157.1 rejects
codex exec -a never …. Drop the flag:codex execalready runs with approvalnever, and acodex -a … execprefix does not change that. - Scripts pass
--full-auto. It is absent from 0.157.1. Use a permission profile (-c default_permissions=":workspace"),--approve-for-meor--sandbox workspace-write. - Codex ignores
AGENTS.md. Untrusted projects do not supply it (since CLI 0.150.0); trust the project, but only a checkout you or your team wrote, never a contributor’s branch in CI. - Parallel sessions collide.
codex --worktreeisolates files, not ports or databases (worktrees).
Where to go next with Codex
Section titled “Where to go next with Codex”- Developers: installation, the desktop app guide and cost management.
- Tech leads: team workflows, enterprise governance and the tech lead track.
- Lifecycle and other tools: the AI-native SDLC, the tool map, Codex vs Cursor and Claude Code.