Codex CLI reference - CLI flags
Codex CLI command-line flags
Codex CLI documents 136 CLI flags, including --add-dir, --dangerously-bypass-hook-trust and --disable. You pass these to codex on the command line. Each row gives the docs' description, accepted values and an example where one is documented.
Last verified 1 official pageFull Codex CLI reference
| Flag | Description | Example |
|---|---|---|
--add-dir | Grant additional directories write access alongside the main workspace. Repeat for multiple paths. path Docs: --add-dir | -no example |
--approve-for-me, --not-so-yolo | Use automatic approval review with boolean Docs: --approve-for-me, --not-so-yolo | -no example |
--ask-for-approval, -a | Control when Codex pauses for human approval before running a command. on-request | never Docs: --ask-for-approval, -a | codex --ask-for-approval never "Summarize the current instructions." |
--cd, -C | Set the working directory for the agent before it starts processing your request. path Docs: --cd, -C | codex --cd services/payments --ask-for-approval never "List the instruction sources you loaded." |
--config, -c | Override configuration values. Values parse as TOML if possible; otherwise the literal string is used. key=value Docs: --config, -c | codex --config model='"gpt-6.1-sol"' |
--dangerously-bypass-approvals-and-sandbox, --yolo | Run every command without approvals or sandboxing. Only use inside an externally hardened environment. boolean Docs: --dangerously-bypass-approvals-and-sandbox, --yolo | -no example |
--dangerously-bypass-hook-trust | Run enabled hooks without requiring persisted hook trust for this invocation. Intended only for automation that already vets hook sources. boolean Docs: --dangerously-bypass-hook-trust | -no example |
--disable | Force-disable a feature flag (translates to feature Docs: --disable | -no example |
--enable | Force-enable a feature flag (translates to feature Docs: --enable | codex --enable feature_a --enable feature_b |
--image, -i | Attach one or more image files to the initial prompt. Separate multiple paths with commas or repeat the flag. path[,path...] Docs: --image, -i | -no example |
--local-provider | Choose the local provider used with lmstudio | ollama Docs: --local-provider | -no example |
--model, -m | Override the model set in configuration (for example string Docs: --model, -m | codex --model gpt-6.1-sol |
--no-alt-screen | Disable alternate screen mode for the TUI (overrides boolean Docs: --no-alt-screen | -no example |
--no-daemon | Run the interactive CLI without the shared background server. Can't be combined with boolean Docs: --no-daemon | -no example |
--oss | Use a local open source model provider. Codex uses boolean Docs: --oss | -no example |
--profile, -p | Layer string Docs: --profile, -p | codex --profile deep-review |
--remote | Connect to a remote app-server endpoint over WebSocket or a Unix socket. Supported for ws://host:port | wss://host:port | unix:// | unix://PATH Docs: --remote | --remote ws://host:port |
--remote-auth-token-env | Read a bearer token from this environment variable and send it when connecting with ENV_VAR Docs: --remote-auth-token-env | -no example |
--sandbox, -s | Select the sandbox policy for model-generated shell commands. read-only | workspace-write | danger-full-access Docs: --sandbox, -s | --sandbox workspace-write --ask-for-approval on-request |
--search | Enable live web search (sets boolean Docs: --search | -no example |
--strict-config | Error when boolean Docs: --strict-config | -no example |
--worktree | Start in a new managed Git worktree. Supports new interactive sessions, boolean Docs: --worktree | -no example |
PROMPT | Positional arg of string Docs: PROMPT | -no example |
--analytics-default-enabled |
boolean Docs: --analytics-default-enabled | -no example |
--code-mode-host |
ws://HOST/PATH | wss://HOST/PATH Docs: --code-mode-host | --code-mode-host wss://code-mode.example.com/host |
--listen |
stdio:// | ws://IP:PORT | unix:// | unix://PATH | off Docs: --listen | codex app-server --listen ws://IP:PORT |
--stdio |
boolean Docs: --stdio | -no example |
--ws-audience |
string Docs: --ws-audience | -no example |
--ws-auth |
capability-token | signed-bearer-token Docs: --ws-auth | -no example |
--ws-issuer |
string Docs: --ws-issuer | -no example |
--ws-max-clock-skew-seconds |
number Docs: --ws-max-clock-skew-seconds | -no example |
--ws-shared-secret-file |
absolute path Docs: --ws-shared-secret-file | -no example |
--ws-token-file |
absolute path Docs: --ws-token-file | -no example |
--ws-token-sha256 |
hexadecimal SHA-256 digest Docs: --ws-token-sha256 | -no example |
--download-url |
url Docs: --download-url | -no example |
PATH | Positional arg of path Docs: PATH | -no example |
USER_MESSAGE | Positional arg of string Docs: USER_MESSAGE | -no example |
--bundled |
boolean Docs: --bundled | -no example |
--image, -i |
path[,path...] Docs: --image, -i | -no example |
PROMPT | Positional arg of string Docs: PROMPT | -no example |
TASK_ID | Positional arg of string Docs: TASK_ID | -no example |
--base |
branch Docs: --base | -no example |
--commit |
SHA Docs: --commit | -no example |
--strict-config |
boolean Docs: --strict-config | -no example |
--title |
string Docs: --title | -no example |
--uncommitted |
boolean Docs: --uncommitted | -no example |
PROMPT | Positional arg of string | - (read stdin) Docs: PROMPT | -no example |
--remote |
ws://host:port | wss://host:port | unix:// | unix://PATH Docs: --remote | -no example |
--remote-auth-token-env |
ENV_VAR Docs: --remote-auth-token-env | -no example |
SESSION | Positional arg of session ID | session name Docs: SESSION | codex archive <SESSION>
codex unarchive <SESSION> |
--force |
boolean Docs: --force | codex delete <SESSION_UUID> --force |
--remote |
ws://host:port | wss://host:port | unix:// | unix://PATH Docs: --remote | -no example |
--remote-auth-token-env |
ENV_VAR Docs: --remote-auth-token-env | -no example |
SESSION | Positional arg of session ID | session name Docs: SESSION | codex delete <SESSION> |
--attempts |
1-4 Docs: --attempts | -no example |
--env |
ENV_ID Docs: --env | -no example |
QUERY | Positional arg of string Docs: QUERY | -no example |
--cursor |
string Docs: --cursor | -no example |
--env |
ENV_ID Docs: --env | -no example |
--json |
boolean Docs: --json | -no example |
--limit |
1-20 Docs: --limit | -no example |
SHELL | Positional arg of bash | zsh | fish | power-shell | elvish Docs: SHELL | codex completion zsh > "${fpath[1]}/_codex" |
--all |
boolean Docs: --all | -no example |
--ascii |
boolean Docs: --ascii | -no example |
--json |
boolean Docs: --json | -no example |
--no-color |
boolean Docs: --no-color | -no example |
--summary |
boolean Docs: --summary | -no example |
--approve-for-me, --not-so-yolo |
boolean Docs: --approve-for-me, --not-so-yolo | -no example |
--cd, -C |
path Docs: --cd, -C | -no example |
--color |
always | never | auto Docs: --color | -no example |
--dangerously-bypass-approvals-and-sandbox, --yolo |
boolean Docs: --dangerously-bypass-approvals-and-sandbox, --yolo | -no example |
--dangerously-bypass-hook-trust |
boolean Docs: --dangerously-bypass-hook-trust | -no example |
--ephemeral |
boolean Docs: --ephemeral | -no example |
--ignore-rules |
boolean Docs: --ignore-rules | -no example |
--ignore-user-config |
boolean Docs: --ignore-user-config | -no example |
--image, -i |
path[,path...] Docs: --image, -i | -no example |
--json, --experimental-json |
boolean Docs: --json, --experimental-json | -no example |
--local-provider |
lmstudio | ollama Docs: --local-provider | -no example |
--model, -m |
string Docs: --model, -m | -no example |
--oss |
boolean Docs: --oss | -no example |
--output-last-message, -o |
path Docs: --output-last-message, -o | -no example |
--output-schema |
path Docs: --output-schema | -no example |
--profile, -p |
string Docs: --profile, -p | codex exec --profile deep-review "review this change" |
--sandbox, -s |
read-only | workspace-write | danger-full-access Docs: --sandbox, -s | -no example |
--skip-git-repo-check |
boolean Docs: --skip-git-repo-check | -no example |
--worktree |
boolean Docs: --worktree | -no example |
-c, --config |
key=value Docs: -c, --config | -no example |
PROMPT | Positional arg of string | - (read stdin) Docs: PROMPT | -no example |
--all |
boolean Docs: --all | -no example |
--image, -i |
path[,path...] Docs: --image, -i | -no example |
--last |
boolean Docs: --last | -no example |
PROMPT | Positional arg of string | - (read stdin) Docs: PROMPT | -no example |
SESSION_ID | Positional arg of uuid | session name Docs: SESSION_ID | -no example |
--pretty |
boolean Docs: --pretty | codex execpolicy check --pretty \
--rules ~/.codex/rules/default.rules \
-- gh pr view 7888 --json title,body,comments |
--rules, -r |
path (repeatable) Docs: --rules, -r | codex execpolicy check --pretty \
--rules ~/.codex/rules/default.rules \
-- gh pr view 7888 --json title,body,comments |
COMMAND... | Positional arg of var-args Docs: COMMAND... | -no example |
--device-auth |
boolean Docs: --device-auth | -no example |
--with-access-token |
boolean Docs: --with-access-token | printenv CODEX_ACCESS_TOKEN | codex login --with-access-token |
--with-api-key |
boolean Docs: --with-api-key | printenv OPENAI_API_KEY | codex login --with-api-key |
--bearer-token-env-var |
ENV_VAR Docs: --bearer-token-env-var | -no example |
--env KEY=VALUE |
repeatable Docs: --env KEY=VALUE | -no example |
--oauth-client-id |
CLIENT_ID Docs: --oauth-client-id | -no example |
--oauth-resource |
RESOURCE Docs: --oauth-resource | -no example |
--url |
https://… Docs: --url | -no example |
COMMAND... | Positional arg of stdio transport Docs: COMMAND... | -no example |
--all |
boolean Docs: --all | -no example |
--include-non-interactive |
boolean Docs: --include-non-interactive | -no example |
--last |
boolean Docs: --last | -no example |
SESSION_ID | Positional arg of uuid | session name Docs: SESSION_ID | -no example |
--all |
boolean Docs: --all | -no example |
--last |
boolean Docs: --last | -no example |
SESSION_ID | Positional arg of uuid Docs: SESSION_ID | -no example |
--allow-unix-socket |
path Docs: --allow-unix-socket | -no example |
--cd, -C |
DIR Docs: --cd, -C | -no example |
--config, -c |
key=value Docs: --config, -c | -no example |
--include-managed-config |
boolean Docs: --include-managed-config | -no example |
--log-denials |
boolean Docs: --log-denials | -no example |
--permission-profile, -P |
NAME Docs: --permission-profile, -P | -no example |
--profile, -p |
NAME Docs: --profile, -p | -no example |
COMMAND... | Positional arg of var-args Docs: COMMAND... | -no example |
--cd, -C |
DIR Docs: --cd, -C | -no example |
--config, -c |
key=value Docs: --config, -c | -no example |
--include-managed-config |
boolean Docs: --include-managed-config | -no example |
--permission-profile, -P |
NAME Docs: --permission-profile, -P | -no example |
--profile, -p |
NAME Docs: --profile, -p | -no example |
COMMAND... | Positional arg of var-args Docs: COMMAND... | -no example |
--cd, -C |
DIR Docs: --cd, -C | -no example |
--config, -c |
key=value Docs: --config, -c | -no example |
--include-managed-config |
boolean Docs: --include-managed-config | -no example |
--permission-profile, -P |
NAME Docs: --permission-profile, -P | -no example |
--profile, -p |
NAME Docs: --profile, -p | -no example |
COMMAND... | Positional arg of var-args Docs: COMMAND... | -no example |
--thread |
UUID | exact session name Docs: --thread | codex queue --thread <SESSION_ID> --message "Run the remaining checks" |
--message |
string Docs: --message | codex queue --thread <SESSION_ID> --message "Run the remaining checks" |
--json |
boolean Docs: --json | -no example |
--no-daemon |
boolean Docs: --no-daemon | codex remote-control --no-daemon |
The rest of the Codex CLI reference
FAQ
How many CLI flags does Codex CLI have?
The official Codex CLI docs list 136 CLI flags, including --add-dir, --dangerously-bypass-hook-trust and --disable. All of them are in the table above, in the docs' order.
What does --add-dir do in Codex CLI?
Grant additional directories write access alongside the main workspace. Repeat for multiple paths. Values: path.
Where are Codex CLI command-line flags documented?
On 1 official docs page at learn.chatgpt.com, last read on October 17, 2026. Every row in the table links the exact section it came from.
More on Codex CLI
- Codex CLI in the tools directoryWhat it is, who makes it and how it fits next to other coding agents.
- Codex CLI errors and fixes14 error messages, quoted verbatim, with the documented fix for each.
- Codex and ChatGPT usage limitsPlan and tier limits for this tool, copied from the official docs.
Use other models in Codex CLI
Setup guides from the model-in-tool directory, each with the env vars and base URL from official docs.
Sources
Last verified . Names and examples are copied verbatim from the official page below, and every row above links the exact section it came from.
Newsletter
Know when your tools change
One email per week. New coding agent releases, the flags and commands they add, and what they mean for how you work.