Skip to content

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.

  • 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.

Local surfaces share ~/.codex/config.toml, AGENTS.md, skills and MCP servers; Codex cloud has its own environments.

SurfaceStart it withReach for it when
CLI (TUI)codex in the repository rootYou want plan mode, worktrees and every flag
Non-interactive CLIcodex exec "…"Scripts and CI need JSONL events (--json) or schema-shaped output (--output-schema)
Desktop appcodex app (macOS and Windows)Parallel threads, each in its own worktree
IDE extensionVS Code, Cursor and Windsurf (now Devin Desktop), per OpenAI’s READMEYou want the agent beside the file you are editing
Codex cloudchatgpt.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.

  1. Install Codex, sign in and check the installation (terminal):

    Terminal window
    npm install -g @openai/codex
    codex login
    codex doctor
  2. Start codex in the repository root, accept the trust prompt, and run /init to generate AGENTS.md. Edit it until it names the exact typecheck, lint and test commands.

  3. Paste the planning prompt below (it starts with /plan) before the agent starts a turn, and approve the plan. Copy the approved plan into docs/plans/login-rate-limit.md yourself (plan mode edits no file), then commit it with AGENTS.md.

  4. Start a session in a managed Git worktree with codex --worktree and paste the build prompt.

  5. Check the reported commands and exit statuses, then review the diff from inside the worktree:

    Terminal window
    codex review --uncommitted

    Open 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).

SessionSettingWatch out for
Planning and review/plan; or profile :read-only (-c default_permissions=":read-only"), or legacy --sandbox read-onlyEnter /plan before a turn, not mid-run
Interactive build in a worktreeProfile :workspace (-c default_permissions=":workspace"), or legacy --sandbox workspace-write, with on-request approvalsApproving without reading
Long unattended local run--approve-for-me (a reviewer model approves inside workspace-write)Judges sandbox escapes, not correctness
CI jobcodex exec -c default_permissions=":read-only" (or legacy --sandbox read-only) for review; :workspace or workspace-write for fixescodex exec already runs with approval never and has no -a
Full access--dangerously-bypass-approvals-and-sandboxDisposable, 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.md names the gates but enforces nothing (AGENTS.md for Codex).

  • Hooks and rules enforce. Trusted hooks in .codex/hooks.json run whatever the prompt says; .rules files decide which commands may leave the sandbox.

  • codex review re-reads the diff (--uncommitted, --base or --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).

  • “unexpected argument”. 0.157.1 rejects codex exec -a never …. Drop the flag: codex exec already runs with approval never, and a codex -a … exec prefix 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-me or --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 --worktree isolates files, not ports or databases (worktrees).