Primary navigation

Command line options

Options and flags for the Codex terminal client

How to read this reference

This page catalogs every documented Codex CLI command and flag. Use the interactive tables to search by key or description. Each section indicates whether the option is stable or experimental and calls out risky combinations.

The CLI inherits most defaults from ~/.codex/config.toml. Any -c key=value overrides you pass at the command line take precedence for that invocation. See Config basics for more information.

Global flags

Key
--add-dir
Type / Values
path
Details
Key
--ask-for-approval, -a
Type / Values
untrusted | on-request | never
Details
Key
--cd, -C
Type / Values
path
Details
Key
--config, -c
Type / Values
key=value
Details
Key
--dangerously-bypass-approvals-and-sandbox, --yolo
Type / Values
boolean
Details
Key
--disable
Type / Values
feature
Details
Key
--enable
Type / Values
feature
Details
Key
--full-auto
Type / Values
boolean
Details
Key
--image, -i
Type / Values
path[,path...]
Details
Key
--model, -m
Type / Values
string
Details
Key
--no-alt-screen
Type / Values
boolean
Details
Key
--oss
Type / Values
boolean
Details
Key
--profile, -p
Type / Values
string
Details
Key
--sandbox, -s
Type / Values
read-only | workspace-write | danger-full-access
Details
Key
--search
Type / Values
boolean
Details
Key
PROMPT
Type / Values
string
Details

These options apply to the base codex command and propagate to each subcommand unless a section below specifies otherwise. When you run a subcommand, place global flags after it (for example, codex exec --oss ...) so Codex applies them as intended.

Command overview

The Maturity column uses feature maturity labels such as Experimental, Beta, and Stable. See Feature Maturity for how to interpret these labels.

Maturity
Stable
Details
Maturity
Stable
Details
Maturity
Experimental
Details
Maturity
Stable
Details
Maturity
Experimental
Details
Maturity
Stable
Details
Maturity
Experimental
Details
Maturity
Stable
Details
Maturity
Experimental
Details
Maturity
Stable
Details
Maturity
Stable
Details
Maturity
Stable
Details
Maturity
Stable
Details
Maturity
Experimental
Details
Maturity
Experimental
Details
Maturity
Stable
Details
Maturity
Experimental
Details

Command details

codex (interactive)

Running codex with no subcommand launches the interactive terminal UI (TUI). The agent accepts the global flags above plus image attachments. Web search defaults to cached mode; use --search to switch to live browsing and --full-auto to let Codex run most commands without prompts.

codex app-server

Launch the Codex app server locally. This is primarily for development and debugging and may change without notice.

Key
--listen
Type / Values
stdio:// | ws://IP:PORT
Details

codex app-server --listen stdio:// keeps the default JSONL-over-stdio behavior. --listen ws://IP:PORT enables WebSocket transport (experimental). If you generate schemas for client bindings, add --experimental to include gated fields and methods.

codex app

Launch Codex Desktop from the terminal on macOS and optionally open a specific workspace path.

Key
--download-url
Type / Values
url
Details
Key
PATH
Type / Values
path
Details

codex app installs/opens the desktop app on macOS, then opens the provided workspace path. This subcommand is macOS-only.

codex debug app-server send-message-v2

Send one message through app-server’s V2 thread/turn flow using the built-in app-server test client.

Key
USER_MESSAGE
Type / Values
string
Details

This debug flow initializes with experimentalApi: true, starts a thread, sends a turn, and streams server notifications. Use it to reproduce and inspect app-server protocol behavior locally.

codex apply

Apply the most recent diff from a Codex cloud task to your local repository. You must authenticate and have access to the task.

Key
TASK_ID
Type / Values
string
Details

Codex prints the patched files and exits non-zero if git apply fails (for example, due to conflicts).

codex cloud

Interact with Codex cloud tasks from the terminal. The default command opens an interactive picker; codex cloud exec submits a task directly, and codex cloud list returns recent tasks for scripting or quick inspection.

Key
--attempts
Type / Values
1-4
Details
Key
--env
Type / Values
ENV_ID
Details
Key
QUERY
Type / Values
string
Details

Authentication follows the same credentials as the main CLI. Codex exits non-zero if the task submission fails.

codex cloud list

List recent cloud tasks with optional filtering and pagination.

Key
--cursor
Type / Values
string
Details
Key
--env
Type / Values
ENV_ID
Details
Key
--json
Type / Values
boolean
Details
Key
--limit
Type / Values
1-20
Details

Plain-text output prints a task URL followed by status details. Use --json for automation. The JSON payload contains a tasks array plus an optional cursor value. Each task includes id, url, title, status, updated_at, environment_id, environment_label, summary, is_review, and attempt_total.

codex completion

Generate shell completion scripts and redirect the output to the appropriate location, for example codex completion zsh > "${fpath[1]}/_codex".

Key
SHELL
Type / Values
bash | zsh | fish | power-shell | elvish
Details

codex features

Manage feature flags stored in ~/.codex/config.toml. The enable and disable commands persist changes so they apply to future sessions. When you launch with --profile, Codex writes to that profile instead of the root configuration.

Key
Disable subcommand
Type / Values
codex features disable <feature>
Details
Key
Enable subcommand
Type / Values
codex features enable <feature>
Details
Key
List subcommand
Type / Values
codex features list
Details

codex exec

Use codex exec (or the short form codex e) for scripted or CI-style runs that should finish without human interaction.

Key
--cd, -C
Type / Values
path
Details
Key
--color
Type / Values
always | never | auto
Details
Key
--dangerously-bypass-approvals-and-sandbox, --yolo
Type / Values
boolean
Details
Key
--ephemeral
Type / Values
boolean
Details
Key
--full-auto
Type / Values
boolean
Details
Key
--image, -i
Type / Values
path[,path...]
Details
Key
--json, --experimental-json
Type / Values
boolean
Details
Key
--model, -m
Type / Values
string
Details
Key
--oss
Type / Values
boolean
Details
Key
--output-last-message, -o
Type / Values
path
Details
Key
--output-schema
Type / Values
path
Details
Key
--profile, -p
Type / Values
string
Details
Key
--sandbox, -s
Type / Values
read-only | workspace-write | danger-full-access
Details
Key
--skip-git-repo-check
Type / Values
boolean
Details
Key
-c, --config
Type / Values
key=value
Details
Key
PROMPT
Type / Values
string | - (read stdin)
Details
Key
Resume subcommand
Type / Values
codex exec resume [SESSION_ID]
Details

Codex writes formatted output by default. Add --json to receive newline-delimited JSON events (one per state change). The optional resume subcommand lets you continue non-interactive tasks. Use --last to pick the most recent session from the current working directory, or add --all to search across all sessions:

Key
--all
Type / Values
boolean
Details
Key
--image, -i
Type / Values
path[,path...]
Details
Key
--last
Type / Values
boolean
Details
Key
PROMPT
Type / Values
string | - (read stdin)
Details
Key
SESSION_ID
Type / Values
uuid
Details

codex execpolicy

Check execpolicy rule files before you save them. codex execpolicy check accepts one or more --rules flags (for example, files under ~/.codex/rules) and emits JSON showing the strictest decision and any matching rules. Add --pretty to format the output. The execpolicy command is currently in preview.

Key
--pretty
Type / Values
boolean
Details
Key
--rules, -r
Type / Values
path (repeatable)
Details
Key
COMMAND...
Type / Values
var-args
Details

codex login

Authenticate the CLI with a ChatGPT account or API key. With no flags, Codex opens a browser for the ChatGPT OAuth flow.

Key
--device-auth
Type / Values
boolean
Details
Key
--with-api-key
Type / Values
boolean
Details
Key
status subcommand
Type / Values
codex login status
Details

codex login status exits with 0 when credentials are present, which is helpful in automation scripts.

codex logout

Remove saved credentials for both API key and ChatGPT authentication. This command has no flags.

codex mcp

Manage Model Context Protocol server entries stored in ~/.codex/config.toml.

Key
add <name>
Type / Values
-- <command...> | --url <value>
Details
Key
get <name>
Type / Values
--json
Details
Key
list
Type / Values
--json
Details
Key
login <name>
Type / Values
--scopes scope1,scope2
Details
Key
logout <name>
Details
Key
remove <name>
Details

The add subcommand supports both stdio and streamable HTTP transports:

Key
--bearer-token-env-var
Type / Values
ENV_VAR
Details
Key
--env KEY=VALUE
Type / Values
repeatable
Details
Key
--url
Type / Values
https://…
Details
Key
COMMAND...
Type / Values
stdio transport
Details

OAuth actions (login, logout) only work with streamable HTTP servers (and only when the server supports OAuth).

codex mcp-server

Run Codex as an MCP server over stdio so that other tools can connect. This command inherits global configuration overrides and exits when the downstream client closes the connection.

codex resume

Continue an interactive session by ID or resume the most recent conversation. codex resume scopes --last to the current working directory unless you pass --all. It accepts the same global flags as codex, including model and sandbox overrides.

Key
--all
Type / Values
boolean
Details
Key
--last
Type / Values
boolean
Details
Key
SESSION_ID
Type / Values
uuid
Details

codex fork

Fork a previous interactive session into a new thread. By default, codex fork opens the session picker; add --last to fork your most recent session instead.

Key
--all
Type / Values
boolean
Details
Key
--last
Type / Values
boolean
Details
Key
SESSION_ID
Type / Values
uuid
Details

codex sandbox

Use the sandbox helper to run a command under the same policies Codex uses internally.

macOS seatbelt

Key
--config, -c
Type / Values
key=value
Details
Key
--full-auto
Type / Values
boolean
Details
Key
COMMAND...
Type / Values
var-args
Details

Linux Landlock

Key
--config, -c
Type / Values
key=value
Details
Key
--full-auto
Type / Values
boolean
Details
Key
COMMAND...
Type / Values
var-args
Details

Flag combinations and safety tips

  • Set --full-auto for unattended local work, but avoid combining it with --dangerously-bypass-approvals-and-sandbox unless you are inside a dedicated sandbox VM.
  • When you need to grant Codex write access to more directories, prefer --add-dir rather than forcing --sandbox danger-full-access.
  • Pair --json with --output-last-message in CI to capture machine-readable progress and a final natural-language summary.