16| `--add-dir` | `path` | Grant additional directories write access alongside the main workspace. Repeat for multiple paths. |16| `--add-dir` | `path` | Grant additional directories write access alongside the main workspace. Repeat for multiple paths. |
17| `--ask-for-approval, -a` | `untrusted | on-request | never` | Control when Codex pauses for human approval before running a command. `on-failure` is deprecated; prefer `on-request` for interactive runs or `never` for non-interactive runs. |17| `--ask-for-approval, -a` | `untrusted | on-request | never` | Control when Codex pauses for human approval before running a command. `on-failure` is deprecated; prefer `on-request` for interactive runs or `never` for non-interactive runs. |
18| `--cd, -C` | `path` | Set the working directory for the agent before it starts processing your request. |18| `--cd, -C` | `path` | Set the working directory for the agent before it starts processing your request. |
19| `--config, -c` | `key=value` | Override configuration values. Values parse as JSON if possible; otherwise the literal string is used. |19| `--config, -c` | `key=value` | Override configuration values. Values parse as TOML if possible; otherwise the literal string is used. |
20| `--dangerously-bypass-approvals-and-sandbox, --yolo` | `boolean` | Run every command without approvals or sandboxing. Only use inside an externally hardened environment. |20| `--dangerously-bypass-approvals-and-sandbox, --yolo` | `boolean` | Run every command without approvals or sandboxing. Only use inside an externally hardened environment. |
21| `--dangerously-bypass-hook-trust` | `boolean` | Run enabled hooks without requiring persisted hook trust for this invocation. Intended only for automation that already vets hook sources. |21| `--dangerously-bypass-hook-trust` | `boolean` | Run enabled hooks without requiring persisted hook trust for this invocation. Intended only for automation that already vets hook sources. |
22| `--disable` | `feature` | Force-disable a feature flag (translates to `-c features.<name>=false`). Repeatable. |22| `--disable` | `feature` | Force-disable a feature flag (translates to `-c features.<name>=false`). Repeatable. |
26| `--no-alt-screen` | `boolean` | Disable alternate screen mode for the TUI (overrides `tui.alternate_screen` for this run). |26| `--no-alt-screen` | `boolean` | Disable alternate screen mode for the TUI (overrides `tui.alternate_screen` for this run). |
27| `--oss` | `boolean` | Use the local open source model provider (equivalent to `-c model_provider="oss"`). Validates that Ollama is running. |27| `--oss` | `boolean` | Use the local open source model provider (equivalent to `-c model_provider="oss"`). Validates that Ollama is running. |
28| `--profile, -p` | `string` | Layer `$CODEX_HOME/profile-name.config.toml` on top of the base user config. |28| `--profile, -p` | `string` | Layer `$CODEX_HOME/profile-name.config.toml` on top of the base user config. |
29| `--remote` | `ws://host:port | wss://host:port` | Connect the interactive TUI to a remote app-server WebSocket endpoint. Supported for `codex`, `codex resume`, and `codex fork`; other subcommands reject remote mode. |29| `--remote` | `ws://host:port | wss://host:port | unix:// | unix://PATH` | Connect the interactive TUI to a remote app-server endpoint over WebSocket or a Unix socket. Supported for `codex`, `codex resume`, and `codex fork`; other subcommands reject remote mode. |
30| `--remote-auth-token-env` | `ENV_VAR` | Read a bearer token from this environment variable and send it when connecting with `--remote`. Requires `--remote`; tokens are only sent over `wss://` URLs or `ws://` URLs whose host is `localhost`, `127.0.0.1`, or `::1`. |30| `--remote-auth-token-env` | `ENV_VAR` | Read a bearer token from this environment variable and send it when connecting with `--remote`. Requires `--remote`; tokens are only sent over `wss://` URLs or local-only `ws://` URLs. |
31| `--sandbox, -s` | `read-only | workspace-write | danger-full-access` | Select the sandbox policy for model-generated shell commands. |31| `--sandbox, -s` | `read-only | workspace-write | danger-full-access` | Select the sandbox policy for model-generated shell commands. |
32| `--search` | `boolean` | Enable live web search (sets `web_search = "live"` instead of the default `"cached"`). |32| `--search` | `boolean` | Enable live web search (sets `web_search = "live"` instead of the default `"cached"`). |
33| `--strict-config` | `boolean` | Error when `config.toml` contains fields this Codex version does not recognize. Supported by runtime commands such as `codex`, `exec`, `review`, `resume`, `fork`, `app-server`, `mcp-server`, and `exec-server`. |
33| `PROMPT` | `string` | Optional text instruction to start the session. Omit to launch the TUI without a pre-filled message. |34| `PROMPT` | `string` | Optional text instruction to start the session. Omit to launch the TUI without a pre-filled message. |
34 35
35Key36Key
78 79
79Details80Details
80 81
81Override configuration values. Values parse as JSON if possible; otherwise the literal string is used.82Override configuration values. Values parse as TOML if possible; otherwise the literal string is used.
82 83
83Key84Key
84 85
194 195
195Type / Values196Type / Values
196 197
197`ws://host:port | wss://host:port`198`ws://host:port | wss://host:port | unix:// | unix://PATH`
198 199
199Details200Details
200 201
201Connect the interactive TUI to a remote app-server WebSocket endpoint. Supported for `codex`, `codex resume`, and `codex fork`; other subcommands reject remote mode.202Connect the interactive TUI to a remote app-server endpoint over WebSocket or a Unix socket. Supported for `codex`, `codex resume`, and `codex fork`; other subcommands reject remote mode.
202 203
203Key204Key
204 205
210 211
211Details212Details
212 213
213Read a bearer token from this environment variable and send it when connecting with `--remote`. Requires `--remote`; tokens are only sent over `wss://` URLs or `ws://` URLs whose host is `localhost`, `127.0.0.1`, or `::1`.214Read a bearer token from this environment variable and send it when connecting with `--remote`. Requires `--remote`; tokens are only sent over `wss://` URLs or local-only `ws://` URLs.
214 215
215Key216Key
216 217
238 239
239Key240Key
240 241
242`--strict-config`
243
244Type / Values
245
246`boolean`
247
248Details
249
250Error when `config.toml` contains fields this Codex version does not recognize. Supported by runtime commands such as `codex`, `exec`, `review`, `resume`, `fork`, `app-server`, `mcp-server`, and `exec-server`.
251
252Key
253
241`PROMPT`254`PROMPT`
242 255
243Type / Values256Type / Values
250 263
251Expand to view all264Expand to view all
252 265
253These options apply to the base `codex` command and propagate to each subcommand unless a section below specifies otherwise.266These options apply to the base `codex` command. Most propagate to commands;
254When you run a subcommand, place global flags after it (for example, `codex exec --oss ...`) so Codex applies them as intended.267see the notes above or the relevant command help for exceptions. For propagated
268flags, follow the relevant command help. For example, `codex exec --oss ...`
269applies `--oss` to `exec`.
255 270
256## Command overview271## Command overview
257 272
269| [`codex completion`](https://developers.openai.com/codex/cli/reference#codex-completion) | Stable | Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell. |284| [`codex completion`](https://developers.openai.com/codex/cli/reference#codex-completion) | Stable | Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell. |
270| [`codex debug app-server send-message-v2`](https://developers.openai.com/codex/cli/reference#codex-debug-app-server-send-message-v2) | Experimental | Debug app-server by sending a single V2 message through the built-in test client. |285| [`codex debug app-server send-message-v2`](https://developers.openai.com/codex/cli/reference#codex-debug-app-server-send-message-v2) | Experimental | Debug app-server by sending a single V2 message through the built-in test client. |
271| [`codex debug models`](https://developers.openai.com/codex/cli/reference#codex-debug-models) | Experimental | Print the raw model catalog Codex sees, including an option to inspect only the bundled catalog. |286| [`codex debug models`](https://developers.openai.com/codex/cli/reference#codex-debug-models) | Experimental | Print the raw model catalog Codex sees, including an option to inspect only the bundled catalog. |
287| [`codex doctor`](https://developers.openai.com/codex/cli/reference#codex-doctor) | Stable | Generate a diagnostic report for local installation, config, auth, runtime, Git, terminal, app-server, and thread inventory issues. |
272| [`codex exec`](https://developers.openai.com/codex/cli/reference#codex-exec) | Stable | Run Codex non-interactively. Alias: `codex e`. Stream results to stdout or JSONL and optionally resume previous sessions. |288| [`codex exec`](https://developers.openai.com/codex/cli/reference#codex-exec) | Stable | Run Codex non-interactively. Alias: `codex e`. Stream results to stdout or JSONL and optionally resume previous sessions. |
273| [`codex execpolicy`](https://developers.openai.com/codex/cli/reference#codex-execpolicy) | Experimental | Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked. |289| [`codex execpolicy`](https://developers.openai.com/codex/cli/reference#codex-execpolicy) | Experimental | Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked. |
274| [`codex features`](https://developers.openai.com/codex/cli/reference#codex-features) | Stable | List feature flags and persistently enable or disable them in `config.toml`. |290| [`codex features`](https://developers.openai.com/codex/cli/reference#codex-features) | Stable | List feature flags and persistently enable or disable them in `config.toml`. |
381 397
382Key398Key
383 399
400[`codex doctor`](https://developers.openai.com/codex/cli/reference#codex-doctor)
401
402Maturity
403
404Stable
405
406Details
407
408Generate a diagnostic report for local installation, config, auth, runtime, Git, terminal, app-server, and thread inventory issues.
409
410Key
411
384[`codex exec`](https://developers.openai.com/codex/cli/reference#codex-exec)412[`codex exec`](https://developers.openai.com/codex/cli/reference#codex-exec)
385 413
386Maturity414Maturity
543 571
544Running `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. For low-friction local work, use `--sandbox workspace-write --ask-for-approval on-request`.572Running `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. For low-friction local work, use `--sandbox workspace-write --ask-for-approval on-request`.
545 573
546Use `--remote ws://host:port` or `--remote wss://host:port` to connect the TUI to an app server started with `codex app-server --listen ws://IP:PORT`. Add `--remote-auth-token-env <ENV_VAR>` when the server requires a bearer token for WebSocket authentication.574Use `--remote ws://host:port` or `--remote wss://host:port` to connect the TUI to an app server started with `codex app-server --listen ws://IP:PORT`. For a local Unix socket, use `--remote unix://` for the default socket or `--remote unix://PATH` for an explicit path. Add `--remote-auth-token-env <ENV_VAR>` when the server requires a bearer token for WebSocket authentication.
547 575
548### `codex app-server`576### `codex app-server`
549 577
558| `--ws-issuer` | `string` | Expected `iss` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`. |586| `--ws-issuer` | `string` | Expected `iss` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`. |
559| `--ws-max-clock-skew-seconds` | `number` | Clock skew allowance when validating signed bearer token `exp` and `nbf` claims. Requires `--ws-auth signed-bearer-token`. |587| `--ws-max-clock-skew-seconds` | `number` | Clock skew allowance when validating signed bearer token `exp` and `nbf` claims. Requires `--ws-auth signed-bearer-token`. |
560| `--ws-shared-secret-file` | `absolute path` | File containing the HMAC shared secret used to validate signed JWT bearer tokens. Required with `--ws-auth signed-bearer-token`. |588| `--ws-shared-secret-file` | `absolute path` | File containing the HMAC shared secret used to validate signed JWT bearer tokens. Required with `--ws-auth signed-bearer-token`. |
561| `--ws-token-file` | `absolute path` | File containing the shared capability token. Required with `--ws-auth capability-token`. |589| `--ws-token-file` | `absolute path` | File containing the shared capability token. Use with `--ws-auth capability-token` unless you provide `--ws-token-sha256` instead. |
590| `--ws-token-sha256` | `hexadecimal SHA-256 digest` | Expected SHA-256 digest for capability-token authentication. Use instead of `--ws-token-file` when the client token comes from another source. |
562 591
563Key592Key
564 593
654 683
655Details684Details
656 685
657File containing the shared capability token. Required with `--ws-auth capability-token`.686File containing the shared capability token. Use with `--ws-auth capability-token` unless you provide `--ws-token-sha256` instead.
687
688Key
689
690`--ws-token-sha256`
691
692Type / Values
693
694`hexadecimal SHA-256 digest`
695
696Details
697
698Expected SHA-256 digest for capability-token authentication. Use instead of `--ws-token-file` when the client token comes from another source.
658 699
659`codex app-server --listen stdio://` keeps the default JSONL-over-stdio behavior. `--listen ws://IP:PORT` enables WebSocket transport for app-server clients. The server accepts `ws://` listen URLs; use TLS termination or a secure proxy when clients connect with `wss://`. Use `--listen unix://` to accept WebSocket handshakes on Codex’s default Unix socket, or `--listen unix:///absolute/path.sock` to choose a socket path. If you generate schemas for client bindings, add `--experimental` to include gated fields and methods.700`codex app-server --listen stdio://` keeps the default JSONL-over-stdio behavior. `--listen ws://IP:PORT` enables WebSocket transport for app-server clients. The server accepts `ws://` listen URLs; use TLS termination or a secure proxy when clients connect with `wss://`. Use `--listen unix://` to accept WebSocket handshakes on Codex’s default Unix socket, or `--listen unix:///absolute/path.sock` to choose a socket path. If you generate schemas for client bindings, add `--experimental` to include gated fields and methods.
660 701
897 938
898Shell to generate completions for. Output prints to stdout.939Shell to generate completions for. Output prints to stdout.
899 940
941### `codex doctor`
942
943Generate a local diagnostic report before filing a support issue or
944while investigating a broken Codex installation. The report checks installation,
945configuration, authentication, runtime, Git, terminal, app-server, and thread
946inventory health.
947
948| Key | Type / Values | Details |
949| --- | --- | --- |
950| `--all` | `boolean` | Expand long lists in the detailed human-readable report. |
951| `--ascii` | `boolean` | Use ASCII status labels and separators in human-readable output. |
952| `--json` | `boolean` | Emit a redacted machine-readable support report. |
953| `--no-color` | `boolean` | Disable ANSI color in human-readable output. |
954| `--summary` | `boolean` | Show grouped check rows and the final count summary only. |
955
956Key
957
958`--all`
959
960Type / Values
961
962`boolean`
963
964Details
965
966Expand long lists in the detailed human-readable report.
967
968Key
969
970`--ascii`
971
972Type / Values
973
974`boolean`
975
976Details
977
978Use ASCII status labels and separators in human-readable output.
979
980Key
981
982`--json`
983
984Type / Values
985
986`boolean`
987
988Details
989
990Emit a redacted machine-readable support report.
991
992Key
993
994`--no-color`
995
996Type / Values
997
998`boolean`
999
1000Details
1001
1002Disable ANSI color in human-readable output.
1003
1004Key
1005
1006`--summary`
1007
1008Type / Values
1009
1010`boolean`
1011
1012Details
1013
1014Show grouped check rows and the final count summary only.
1015
900### `codex features`1016### `codex features`
901 1017
902Manage feature flags stored in `~/.codex/config.toml` or the selected profile file. The `enable` and `disable` commands persist changes so they apply to future sessions. When you launch with `--profile profile-name`, Codex writes to `$CODEX_HOME/profile-name.config.toml` instead of the base user config.1018Manage feature flags stored in `$CODEX_HOME/config.toml`. The `enable` and
1019`disable` commands persist changes so they apply to future sessions. The
1020`features` subcommand doesn’t accept `--profile`.
903 1021
904| Key | Type / Values | Details |1022| Key | Type / Values | Details |
905| --- | --- | --- |1023| --- | --- | --- |
906| `Disable subcommand` | `codex features disable <feature>` | Persistently disable a feature flag in the active config file. With `--profile profile-name`, writes to `$CODEX_HOME/profile-name.config.toml`. |1024| `Disable subcommand` | `codex features disable <feature>` | Persistently disable a feature flag in `$CODEX_HOME/config.toml`. |
907| `Enable subcommand` | `codex features enable <feature>` | Persistently enable a feature flag in the active config file. With `--profile profile-name`, writes to `$CODEX_HOME/profile-name.config.toml`. |1025| `Enable subcommand` | `codex features enable <feature>` | Persistently enable a feature flag in `$CODEX_HOME/config.toml`. |
908| `List subcommand` | `codex features list` | Show known feature flags, their maturity stage, and their effective state. |1026| `List subcommand` | `codex features list` | Show known feature flags, their maturity stage, and their effective state. |
909 1027
910Key1028Key
917 1035
918Details1036Details
919 1037
920Persistently disable a feature flag in the active config file. With `--profile profile-name`, writes to `$CODEX_HOME/profile-name.config.toml`.1038Persistently disable a feature flag in `$CODEX_HOME/config.toml`.
921 1039
922Key1040Key
923 1041
929 1047
930Details1048Details
931 1049
932Persistently enable a feature flag in the active config file. With `--profile profile-name`, writes to `$CODEX_HOME/profile-name.config.toml`.1050Persistently enable a feature flag in `$CODEX_HOME/config.toml`.
933 1051
934Key1052Key
935 1053
1476| --- | --- | --- |1594| --- | --- | --- |
1477| `--bearer-token-env-var` | `ENV_VAR` | Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server. |1595| `--bearer-token-env-var` | `ENV_VAR` | Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server. |
1478| `--env KEY=VALUE` | `repeatable` | Environment variable assignments applied when launching a stdio server. |1596| `--env KEY=VALUE` | `repeatable` | Environment variable assignments applied when launching a stdio server. |
1597| `--oauth-client-id` | `CLIENT_ID` | OAuth client identifier for a streamable HTTP MCP server. Requires `--url`. |
1598| `--oauth-resource` | `RESOURCE` | OAuth resource parameter to include during login for a streamable HTTP MCP server. Requires `--url`. |
1479| `--url` | `https://…` | Register a streamable HTTP server instead of stdio. Mutually exclusive with `COMMAND...`. |1599| `--url` | `https://…` | Register a streamable HTTP server instead of stdio. Mutually exclusive with `COMMAND...`. |
1480| `COMMAND...` | `stdio transport` | Executable plus arguments to launch the MCP server. Provide after `--`. |1600| `COMMAND...` | `stdio transport` | Executable plus arguments to launch the MCP server. Provide after `--`. |
1481 1601
1505 1625
1506Key1626Key
1507 1627
1628`--oauth-client-id`
1629
1630Type / Values
1631
1632`CLIENT_ID`
1633
1634Details
1635
1636OAuth client identifier for a streamable HTTP MCP server. Requires `--url`.
1637
1638Key
1639
1640`--oauth-resource`
1641
1642Type / Values
1643
1644`RESOURCE`
1645
1646Details
1647
1648OAuth resource parameter to include during login for a streamable HTTP MCP server. Requires `--url`.
1649
1650Key
1651
1508`--url`1652`--url`
1509 1653
1510Type / Values1654Type / Values
1695| `--include-managed-config` | `boolean` | Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`. |1839| `--include-managed-config` | `boolean` | Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`. |
1696| `--log-denials` | `boolean` | Capture macOS sandbox denials with `log stream` while the command runs and print them after exit. |1840| `--log-denials` | `boolean` | Capture macOS sandbox denials with `log stream` while the command runs and print them after exit. |
1697| `--permissions-profile` | `NAME` | Apply a named permissions profile from the active configuration stack. |1841| `--permissions-profile` | `NAME` | Apply a named permissions profile from the active configuration stack. |
1842| `--profile, -p` | `NAME` | Layer `$CODEX_HOME/NAME.config.toml` on top of the base user config. |
1698| `COMMAND...` | `var-args` | Shell command to execute under macOS Seatbelt. Everything after `--` is forwarded. |1843| `COMMAND...` | `var-args` | Shell command to execute under macOS Seatbelt. Everything after `--` is forwarded. |
1699 1844
1700Key1845Key
1771 1916
1772Key1917Key
1773 1918
1919`--profile, -p`
1920
1921Type / Values
1922
1923`NAME`
1924
1925Details
1926
1927Layer `$CODEX_HOME/NAME.config.toml` on top of the base user config.
1928
1929Key
1930
1774`COMMAND...`1931`COMMAND...`
1775 1932
1776Type / Values1933Type / Values
1789| `--config, -c` | `key=value` | Configuration overrides applied before launching the sandbox (repeatable). |1946| `--config, -c` | `key=value` | Configuration overrides applied before launching the sandbox (repeatable). |
1790| `--include-managed-config` | `boolean` | Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`. |1947| `--include-managed-config` | `boolean` | Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`. |
1791| `--permissions-profile` | `NAME` | Apply a named permissions profile from the active configuration stack. |1948| `--permissions-profile` | `NAME` | Apply a named permissions profile from the active configuration stack. |
1949| `--profile, -p` | `NAME` | Layer `$CODEX_HOME/NAME.config.toml` on top of the base user config. |
1792| `COMMAND...` | `var-args` | Command to execute under Landlock + seccomp. Provide the executable after `--`. |1950| `COMMAND...` | `var-args` | Command to execute under Landlock + seccomp. Provide the executable after `--`. |
1793 1951
1794Key1952Key
1841 1999
1842Key2000Key
1843 2001
2002`--profile, -p`
2003
2004Type / Values
2005
2006`NAME`
2007
2008Details
2009
2010Layer `$CODEX_HOME/NAME.config.toml` on top of the base user config.
2011
2012Key
2013
1844`COMMAND...`2014`COMMAND...`
1845 2015
1846Type / Values2016Type / Values
1859| `--config, -c` | `key=value` | Configuration overrides applied before launching the sandbox (repeatable). |2029| `--config, -c` | `key=value` | Configuration overrides applied before launching the sandbox (repeatable). |
1860| `--include-managed-config` | `boolean` | Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`. |2030| `--include-managed-config` | `boolean` | Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`. |
1861| `--permissions-profile` | `NAME` | Apply a named permissions profile from the active configuration stack. |2031| `--permissions-profile` | `NAME` | Apply a named permissions profile from the active configuration stack. |
2032| `--profile, -p` | `NAME` | Layer `$CODEX_HOME/NAME.config.toml` on top of the base user config. |
1862| `COMMAND...` | `var-args` | Command to execute under the native Windows sandbox. Provide the executable after `--`. |2033| `COMMAND...` | `var-args` | Command to execute under the native Windows sandbox. Provide the executable after `--`. |
1863 2034
1864Key2035Key
1911 2082
1912Key2083Key
1913 2084
2085`--profile, -p`
2086
2087Type / Values
2088
2089`NAME`
2090
2091Details
2092
2093Layer `$CODEX_HOME/NAME.config.toml` on top of the base user config.
2094
2095Key
2096
1914`COMMAND...`2097`COMMAND...`
1915 2098
1916Type / Values2099Type / Values