cli/reference.md +942 −1459
1# Command line options1# Command line options
2 2
33## How to read this referenceexport const globalFlagOptions = [
44 {
55This 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. key: "PROMPT",
66 type: "string",
77The CLI inherits most defaults from <code>~/.codex/config.toml</code>. Any description:
88 <code>-c key=value</code> overrides you pass at the command line take "Optional text instruction to start the session. Omit to launch the TUI without a pre-filled message.",
99 precedence for that invocation. See [Config },
1010 basics](https://developers.openai.com/codex/config-basic#configuration-precedence) for more information. {
1111 key: "--image, -i",
1212## Global flags type: "path[,path...]",
1313 description:
1414| Key | Type / Values | Details | "Attach one or more image files to the initial prompt. Separate multiple paths with commas or repeat the flag.",
1515| --- | --- | --- | },
1616| `--add-dir` | `path` | Grant additional directories write access alongside the main workspace. Repeat for multiple paths. | {
1717| `--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. | key: "--model, -m",
1818| `--cd, -C` | `path` | Set the working directory for the agent before it starts processing your request. | type: "string",
1919| `--config, -c` | `key=value` | Override configuration values. Values parse as JSON if possible; otherwise the literal string is used. | description:
2020| `--dangerously-bypass-approvals-and-sandbox, --yolo` | `boolean` | Run every command without approvals or sandboxing. Only use inside an externally hardened environment. | "Override the model set in configuration (for example `gpt-5.4`).",
2121| `--disable` | `feature` | Force-disable a feature flag (translates to `-c features.<name>=false`). Repeatable. | },
2222| `--enable` | `feature` | Force-enable a feature flag (translates to `-c features.<name>=true`). Repeatable. | {
2323| `--full-auto` | `boolean` | Shortcut for low-friction local work: sets `--ask-for-approval on-request` and `--sandbox workspace-write`. | key: "--oss",
2424| `--image, -i` | `path[,path...]` | Attach one or more image files to the initial prompt. Separate multiple paths with commas or repeat the flag. | type: "boolean",
2525| `--model, -m` | `string` | Override the model set in configuration (for example `gpt-5.4`). | defaultValue: "false",
2626| `--no-alt-screen` | `boolean` | Disable alternate screen mode for the TUI (overrides `tui.alternate_screen` for this run). | description:
2727| `--oss` | `boolean` | Use the local open source model provider (equivalent to `-c model_provider="oss"`). Validates that Ollama is running. | 'Use the local open source model provider (equivalent to `-c model_provider="oss"`). Validates that Ollama is running.',
2828| `--profile, -p` | `string` | Configuration profile name to load from `~/.codex/config.toml`. | },
2929| `--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. | {
3030| `--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`. | key: "--profile, -p",
3131| `--sandbox, -s` | `read-only | workspace-write | danger-full-access` | Select the sandbox policy for model-generated shell commands. | type: "string",
3232| `--search` | `boolean` | Enable live web search (sets `web_search = "live"` instead of the default `"cached"`). | description:
3333| `PROMPT` | `string` | Optional text instruction to start the session. Omit to launch the TUI without a pre-filled message. | "Configuration profile name to load from `~/.codex/config.toml`.",
3434 },
3535Key {
3636 key: "--sandbox, -s",
3737`--add-dir` type: "read-only | workspace-write | danger-full-access",
3838 description:
3939Type / Values "Select the sandbox policy for model-generated shell commands.",
4040 },
4141`path` {
4242 key: "--ask-for-approval, -a",
4343Details type: "untrusted | on-request | never",
4444 description:
4545Grant additional directories write access alongside the main workspace. Repeat for multiple paths. "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.",
4646 },
4747Key {
4848 key: "--dangerously-bypass-approvals-and-sandbox, --yolo",
4949`--ask-for-approval, -a` type: "boolean",
5050 defaultValue: "false",
5151Type / Values description:
5252 "Run every command without approvals or sandboxing. Only use inside an externally hardened environment.",
5353`untrusted | on-request | never` },
5454 {
5555Details key: "--cd, -C",
5656 type: "path",
5757Control 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. description:
5858 "Set the working directory for the agent before it starts processing your request.",
5959Key },
6060 {
6161`--cd, -C` key: "--search",
6262 type: "boolean",
6363Type / Values defaultValue: "false",
6464 description:
6565`path` 'Enable live web search (sets `web_search = "live"` instead of the default `"cached"`).',
6666 },
6767Details {
6868 key: "--add-dir",
6969Set the working directory for the agent before it starts processing your request. type: "path",
7070 description:
7171Key "Grant additional directories write access alongside the main workspace. Repeat for multiple paths.",
7272 },
7373`--config, -c` {
7474 key: "--no-alt-screen",
7575Type / Values type: "boolean",
7676 defaultValue: "false",
7777`key=value` description:
7878 "Disable alternate screen mode for the TUI (overrides `tui.alternate_screen` for this run).",
7979Details },
8080 {
8181Override configuration values. Values parse as JSON if possible; otherwise the literal string is used. key: "--remote",
8282 type: "ws://host:port | wss://host:port",
8383Key description:
8484 "Connect the interactive TUI to a remote app-server WebSocket endpoint. Supported for `codex`, `codex resume`, and `codex fork`; other subcommands reject remote mode.",
8585`--dangerously-bypass-approvals-and-sandbox, --yolo` },
8686 {
8787Type / Values key: "--remote-auth-token-env",
8888 type: "ENV_VAR",
8989`boolean` description:
9090 "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`.",
9191Details },
9292 {
9393Run every command without approvals or sandboxing. Only use inside an externally hardened environment. key: "--enable",
9494 type: "feature",
9595Key description:
9696 "Force-enable a feature flag (translates to `-c features.<name>=true`). Repeatable.",
9797`--disable` },
9898 {
9999Type / Values key: "--disable",
100100 type: "feature",
101101`feature` description:
102102 "Force-disable a feature flag (translates to `-c features.<name>=false`). Repeatable.",
103103Details },
104104 {
105105Force-disable a feature flag (translates to `-c features.<name>=false`). Repeatable. key: "--config, -c",
106106 type: "key=value",
107107Key description:
108108 "Override configuration values. Values parse as JSON if possible; otherwise the literal string is used.",
109109`--enable` },
110110 ];
111111Type / Values
112112 export const commandOverview = [
113113`feature` {
114114 key: "codex",
115115Details href: "/codex/cli/reference#codex-interactive",
116116 type: "stable",
117117Force-enable a feature flag (translates to `-c features.<name>=true`). Repeatable. description:
118118 "Launch the terminal UI. Accepts the global flags above plus an optional prompt or image attachments.",
119119Key },
120120 {
121121`--full-auto` key: "codex app-server",
122122 href: "/codex/cli/reference#codex-app-server",
123123Type / Values type: "experimental",
124124 description:
125125`boolean` "Launch the Codex app server for local development or debugging.",
126126 },
127127Details {
128128 key: "codex app",
129129Shortcut for low-friction local work: sets `--ask-for-approval on-request` and `--sandbox workspace-write`. href: "/codex/cli/reference#codex-app",
130130 type: "stable",
131131Key description:
132132 "Launch the Codex desktop app on macOS or Windows. On macOS, Codex can open a workspace path; on Windows, Codex prints the path to open.",
133133`--image, -i` },
134134 {
135135Type / Values key: "codex debug app-server send-message-v2",
136136 href: "/codex/cli/reference#codex-debug-app-server-send-message-v2",
137137`path[,path...]` type: "experimental",
138138 description:
139139Details "Debug app-server by sending a single V2 message through the built-in test client.",
140140 },
141141Attach one or more image files to the initial prompt. Separate multiple paths with commas or repeat the flag. {
142142 key: "codex debug models",
143143Key href: "/codex/cli/reference#codex-debug-models",
144144 type: "experimental",
145145`--model, -m` description:
146146 "Print the raw model catalog Codex sees, including an option to inspect only the bundled catalog.",
147147Type / Values },
148148 {
149149`string` key: "codex apply",
150150 href: "/codex/cli/reference#codex-apply",
151151Details type: "stable",
152152 description:
153153Override the model set in configuration (for example `gpt-5.4`). "Apply the latest diff generated by a Codex Cloud task to your local working tree. Alias: `codex a`.",
154154 },
155155Key {
156156 key: "codex cloud",
157157`--no-alt-screen` href: "/codex/cli/reference#codex-cloud",
158158 type: "experimental",
159159Type / Values description:
160160 "Browse or execute Codex Cloud tasks from the terminal without opening the TUI. Alias: `codex cloud-tasks`.",
161161`boolean` },
162162 {
163163Details key: "codex completion",
164164 href: "/codex/cli/reference#codex-completion",
165165Disable alternate screen mode for the TUI (overrides `tui.alternate_screen` for this run). type: "stable",
166166 description:
167167Key "Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell.",
168168 },
169169`--oss` {
170170 key: "codex features",
171171Type / Values href: "/codex/cli/reference#codex-features",
172172 type: "stable",
173173`boolean` description:
174174 "List feature flags and persistently enable or disable them in `config.toml`.",
175175Details },
176176 {
177177Use the local open source model provider (equivalent to `-c model_provider="oss"`). Validates that Ollama is running. key: "codex exec",
178178 href: "/codex/cli/reference#codex-exec",
179179Key type: "stable",
180180 description:
181181`--profile, -p` "Run Codex non-interactively. Alias: `codex e`. Stream results to stdout or JSONL and optionally resume previous sessions.",
182182 },
183183Type / Values {
184184 key: "codex execpolicy",
185185`string` href: "/codex/cli/reference#codex-execpolicy",
186186 type: "experimental",
187187Details description:
188188 "Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked.",
189189Configuration profile name to load from `~/.codex/config.toml`. },
190190 {
191191Key key: "codex login",
192192 href: "/codex/cli/reference#codex-login",
193193`--remote` type: "stable",
194194 description:
195195Type / Values "Authenticate Codex using ChatGPT OAuth, device auth, or an API key piped over stdin.",
196196 },
197197`ws://host:port | wss://host:port` {
198198 key: "codex logout",
199199Details href: "/codex/cli/reference#codex-logout",
200200 type: "stable",
201201Connect the interactive TUI to a remote app-server WebSocket endpoint. Supported for `codex`, `codex resume`, and `codex fork`; other subcommands reject remote mode. description: "Remove stored authentication credentials.",
202202 },
203203Key {
204204 key: "codex mcp",
205205`--remote-auth-token-env` href: "/codex/cli/reference#codex-mcp",
206206 type: "experimental",
207207Type / Values description:
208208 "Manage Model Context Protocol servers (list, add, remove, authenticate).",
209209`ENV_VAR` },
210210 {
211211Details key: "codex plugin marketplace",
212212 href: "/codex/cli/reference#codex-plugin-marketplace",
213213Read 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`. type: "experimental",
214214 description:
215215Key "Add, upgrade, or remove plugin marketplaces from Git or local sources.",
216216 },
217217`--sandbox, -s` {
218218 key: "codex mcp-server",
219219Type / Values href: "/codex/cli/reference#codex-mcp-server",
220220 type: "experimental",
221221`read-only | workspace-write | danger-full-access` description:
222222 "Run Codex itself as an MCP server over stdio. Useful when another agent consumes Codex.",
223223Details },
224224 {
225225Select the sandbox policy for model-generated shell commands. key: "codex resume",
226226 href: "/codex/cli/reference#codex-resume",
227227Key type: "stable",
228228 description:
229229`--search` "Continue a previous interactive session by ID or resume the most recent conversation.",
230230 },
231231Type / Values {
232232 key: "codex fork",
233233`boolean` href: "/codex/cli/reference#codex-fork",
234234 type: "stable",
235235Details description:
236236 "Fork a previous interactive session into a new thread, preserving the original transcript.",
237237Enable live web search (sets `web_search = "live"` instead of the default `"cached"`). },
238238 {
239239Key key: "codex sandbox",
240240 href: "/codex/cli/reference#codex-sandbox",
241241`PROMPT` type: "experimental",
242242 description:
243243Type / Values "Run arbitrary commands inside Codex-provided macOS, Linux, or Windows sandboxes.",
244244 },
245245`string` {
246246 key: "codex update",
247247Details href: "/codex/cli/reference#codex-update",
248248 type: "stable",
249249Optional text instruction to start the session. Omit to launch the TUI without a pre-filled message. description:
250250 "Check for and apply a Codex CLI update when the installed release supports self-update.",
251251Expand to view all },
252252 ];
253253These options apply to the base `codex` command and propagate to each subcommand unless a section below specifies otherwise.
254254When you run a subcommand, place global flags after it (for example, `codex exec --oss ...`) so Codex applies them as intended.export const execOptions = [
255255 {
256256## Command overview key: "PROMPT",
257257 type: "string | - (read stdin)",
258258The Maturity column uses feature maturity labels such as Experimental, Beta, description:
259259 and Stable. See [Feature Maturity](https://developers.openai.com/codex/feature-maturity) for how to "Initial instruction for the task. Use `-` to pipe the prompt from stdin.",
260260 interpret these labels. },
261261 {
262262| Key | Maturity | Details | key: "--image, -i",
263263| --- | --- | --- | type: "path[,path...]",
264264| [`codex`](https://developers.openai.com/codex/cli/reference#codex-interactive) | Stable | Launch the terminal UI. Accepts the global flags above plus an optional prompt or image attachments. | description:
265265| [`codex app`](https://developers.openai.com/codex/cli/reference#codex-app) | Stable | Launch the Codex desktop app on macOS, optionally opening a specific workspace path. | "Attach images to the first message. Repeatable; supports comma-separated lists.",
266266| [`codex app-server`](https://developers.openai.com/codex/cli/reference#codex-app-server) | Experimental | Launch the Codex app server for local development or debugging. | },
267267| [`codex apply`](https://developers.openai.com/codex/cli/reference#codex-apply) | Stable | Apply the latest diff generated by a Codex Cloud task to your local working tree. Alias: `codex a`. | {
268268| [`codex cloud`](https://developers.openai.com/codex/cli/reference#codex-cloud) | Experimental | Browse or execute Codex Cloud tasks from the terminal without opening the TUI. Alias: `codex cloud-tasks`. | key: "--model, -m",
269269| [`codex completion`](https://developers.openai.com/codex/cli/reference#codex-completion) | Stable | Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell. | type: "string",
270270| [`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. | description: "Override the configured model for this run.",
271271| [`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. | },
272272| [`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. | {
273273| [`codex features`](https://developers.openai.com/codex/cli/reference#codex-features) | Stable | List feature flags and persistently enable or disable them in `config.toml`. | key: "--oss",
274274| [`codex fork`](https://developers.openai.com/codex/cli/reference#codex-fork) | Stable | Fork a previous interactive session into a new thread, preserving the original transcript. | type: "boolean",
275275| [`codex login`](https://developers.openai.com/codex/cli/reference#codex-login) | Stable | Authenticate Codex using ChatGPT OAuth, device auth, or an API key piped over stdin. | defaultValue: "false",
276276| [`codex logout`](https://developers.openai.com/codex/cli/reference#codex-logout) | Stable | Remove stored authentication credentials. | description:
277277| [`codex mcp`](https://developers.openai.com/codex/cli/reference#codex-mcp) | Experimental | Manage Model Context Protocol servers (list, add, remove, authenticate). | "Use the local open source provider (requires a running Ollama instance).",
278278| [`codex mcp-server`](https://developers.openai.com/codex/cli/reference#codex-mcp-server) | Experimental | Run Codex itself as an MCP server over stdio. Useful when another agent consumes Codex. | },
279279| [`codex resume`](https://developers.openai.com/codex/cli/reference#codex-resume) | Stable | Continue a previous interactive session by ID or resume the most recent conversation. | {
280280| [`codex sandbox`](https://developers.openai.com/codex/cli/reference#codex-sandbox) | Experimental | Run arbitrary commands inside Codex-provided macOS seatbelt or Linux bubblewrap sandboxes. | key: "--sandbox, -s",
281281 type: "read-only | workspace-write | danger-full-access",
282282Key description:
283283 "Sandbox policy for model-generated commands. Defaults to configuration.",
284284[`codex`](https://developers.openai.com/codex/cli/reference#codex-interactive) },
285285 {
286286Maturity key: "--profile, -p",
287287 type: "string",
288288Stable description: "Select a configuration profile defined in config.toml.",
289289 },
290290Details {
291291 key: "--full-auto",
292292Launch the terminal UI. Accepts the global flags above plus an optional prompt or image attachments. type: "boolean",
293293 defaultValue: "false",
294294Key description:
295295 "Deprecated compatibility flag. Prefer `--sandbox workspace-write`; Codex prints a warning when this flag is used.",
296296[`codex app`](https://developers.openai.com/codex/cli/reference#codex-app) },
297297 {
298298Maturity key: "--dangerously-bypass-approvals-and-sandbox, --yolo",
299299 type: "boolean",
300300Stable defaultValue: "false",
301301 description:
302302Details "Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner.",
303303 },
304304Launch the Codex desktop app on macOS, optionally opening a specific workspace path. {
305305 key: "--cd, -C",
306306Key type: "path",
307307 description: "Set the workspace root before executing the task.",
308308[`codex app-server`](https://developers.openai.com/codex/cli/reference#codex-app-server) },
309309 {
310310Maturity key: "--skip-git-repo-check",
311311 type: "boolean",
312312Experimental defaultValue: "false",
313313 description:
314314Details "Allow running outside a Git repository (useful for one-off directories).",
315315 },
316316Launch the Codex app server for local development or debugging. {
317317 key: "--ephemeral",
318318Key type: "boolean",
319319 defaultValue: "false",
320320[`codex apply`](https://developers.openai.com/codex/cli/reference#codex-apply) description: "Run without persisting session rollout files to disk.",
321321 },
322322Maturity {
323323 key: "--ignore-user-config",
324324Stable type: "boolean",
325325 defaultValue: "false",
326326Details description:
327327 "Do not load `$CODEX_HOME/config.toml`. Authentication still uses `CODEX_HOME`.",
328328Apply the latest diff generated by a Codex Cloud task to your local working tree. Alias: `codex a`. },
329329 {
330330Key key: "--ignore-rules",
331331 type: "boolean",
332332[`codex cloud`](https://developers.openai.com/codex/cli/reference#codex-cloud) defaultValue: "false",
333333 description:
334334Maturity "Do not load user or project execpolicy `.rules` files for this run.",
335335 },
336336Experimental {
337337 key: "--output-schema",
338338Details type: "path",
339339 description:
340340Browse or execute Codex Cloud tasks from the terminal without opening the TUI. Alias: `codex cloud-tasks`. "JSON Schema file describing the expected final response shape. Codex validates tool output against it.",
341341 },
342342Key {
343343 key: "--color",
344344[`codex completion`](https://developers.openai.com/codex/cli/reference#codex-completion) type: "always | never | auto",
345345 defaultValue: "auto",
346346Maturity description: "Control ANSI color in stdout.",
347347 },
348348Stable {
349349 key: "--json, --experimental-json",
350350Details type: "boolean",
351351 defaultValue: "false",
352352Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell. description:
353353 "Print newline-delimited JSON events instead of formatted text.",
354354Key },
355355 {
356356[`codex debug app-server send-message-v2`](https://developers.openai.com/codex/cli/reference#codex-debug-app-server-send-message-v2) key: "--output-last-message, -o",
357357 type: "path",
358358Maturity description:
359359 "Write the assistant’s final message to a file. Useful for downstream scripting.",
360360Experimental },
361361 {
362362Details key: "Resume subcommand",
363363 type: "codex exec resume [SESSION_ID]",
364364Debug app-server by sending a single V2 message through the built-in test client. description:
365365 "Resume an exec session by ID or add `--last` to continue the most recent session from the current working directory. Add `--all` to consider sessions from any directory. Accepts an optional follow-up prompt.",
366366Key },
367367 {
368368[`codex exec`](https://developers.openai.com/codex/cli/reference#codex-exec) key: "-c, --config",
369369 type: "key=value",
370370Maturity description:
371371 "Inline configuration override for the non-interactive run (repeatable).",
372372Stable },
373373 ];
374374Details
375375 export const appServerOptions = [
376376Run Codex non-interactively. Alias: `codex e`. Stream results to stdout or JSONL and optionally resume previous sessions. {
377377 key: "--listen",
378378Key type: "stdio:// | ws://IP:PORT",
379379 defaultValue: "stdio://",
380380[`codex execpolicy`](https://developers.openai.com/codex/cli/reference#codex-execpolicy) description:
381381 "Transport listener URL. Use `ws://IP:PORT` to expose a WebSocket endpoint for remote clients.",
382382Maturity },
383383 {
384384Experimental key: "--ws-auth",
385385 type: "capability-token | signed-bearer-token",
386386Details description:
387387 "Authentication mode for app-server WebSocket clients. If omitted, WebSocket auth is disabled; non-local listeners warn during startup.",
388388Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked. },
389389 {
390390Key key: "--ws-token-file",
391391 type: "absolute path",
392392[`codex features`](https://developers.openai.com/codex/cli/reference#codex-features) description:
393393 "File containing the shared capability token. Required with `--ws-auth capability-token`.",
394394Maturity },
395395 {
396396Stable key: "--ws-shared-secret-file",
397397 type: "absolute path",
398398Details description:
399399 "File containing the HMAC shared secret used to validate signed JWT bearer tokens. Required with `--ws-auth signed-bearer-token`.",
400400List feature flags and persistently enable or disable them in `config.toml`. },
401401 {
402402Key key: "--ws-issuer",
403403 type: "string",
404404[`codex fork`](https://developers.openai.com/codex/cli/reference#codex-fork) description:
405405 "Expected `iss` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`.",
406406Maturity },
407407 {
408408Stable key: "--ws-audience",
409409 type: "string",
410410Details description:
411411 "Expected `aud` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`.",
412412Fork a previous interactive session into a new thread, preserving the original transcript. },
413413 {
414414Key key: "--ws-max-clock-skew-seconds",
415415 type: "number",
416416[`codex login`](https://developers.openai.com/codex/cli/reference#codex-login) defaultValue: "30",
417417 description:
418418Maturity "Clock skew allowance when validating signed bearer token `exp` and `nbf` claims. Requires `--ws-auth signed-bearer-token`.",
419419 },
420420Stable];
421421
422422Detailsexport const appOptions = [
423423 {
424424Authenticate Codex using ChatGPT OAuth, device auth, or an API key piped over stdin. key: "PATH",
425425 type: "path",
426426Key defaultValue: ".",
427427 description:
428428[`codex logout`](https://developers.openai.com/codex/cli/reference#codex-logout) "Workspace path for Codex Desktop. On macOS, Codex opens this path; on Windows, Codex prints the path.",
429429 },
430430Maturity {
431431 key: "--download-url",
432432Stable type: "url",
433433 description:
434434Details "Advanced override for the Codex desktop installer URL used during install.",
435435 },
436436Remove stored authentication credentials.];
437437
438438Keyexport const debugAppServerSendMessageV2Options = [
439439 {
440440[`codex mcp`](https://developers.openai.com/codex/cli/reference#codex-mcp) key: "USER_MESSAGE",
441441 type: "string",
442442Maturity description:
443443 "Message text sent to app-server through the built-in V2 test-client flow.",
444444Experimental },
445445 ];
446446Details
447447 export const debugModelsOptions = [
448448Manage Model Context Protocol servers (list, add, remove, authenticate). {
449449 key: "--bundled",
450450Key type: "boolean",
451451 defaultValue: "false",
452452[`codex mcp-server`](https://developers.openai.com/codex/cli/reference#codex-mcp-server) description:
453453 "Skip refresh and print only the model catalog bundled with the current Codex binary.",
454454Maturity },
455455 ];
456456Experimental
457457 export const resumeOptions = [
458458Details {
459459 key: "SESSION_ID",
460460Run Codex itself as an MCP server over stdio. Useful when another agent consumes Codex. type: "uuid",
461461 description:
462462Key "Resume the specified session. Omit and use `--last` to continue the most recent session.",
463463 },
464464[`codex resume`](https://developers.openai.com/codex/cli/reference#codex-resume) {
465465 key: "--last",
466466Maturity type: "boolean",
467467 defaultValue: "false",
468468Stable description:
469469 "Skip the picker and resume the most recent conversation from the current working directory.",
470470Details },
471471 {
472472Continue a previous interactive session by ID or resume the most recent conversation. key: "--all",
473473 type: "boolean",
474474Key defaultValue: "false",
475475 description:
476476[`codex sandbox`](https://developers.openai.com/codex/cli/reference#codex-sandbox) "Include sessions outside the current working directory when selecting the most recent session.",
477477 },
478478Maturity];
479479
480480Experimentalexport const featuresOptions = [
481481 {
482482Details key: "List subcommand",
483483 type: "codex features list",
484484Run arbitrary commands inside Codex-provided macOS seatbelt or Linux bubblewrap sandboxes. description:
485485 "Show known feature flags, their maturity stage, and their effective state.",
486486Expand to view all },
487487 {
488488## Command details key: "Enable subcommand",
489489 type: "codex features enable <feature>",
490490### `codex` (interactive) description:
491491 "Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided.",
492492Running `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. },
493493 {
494494Use `--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. See [Codex CLI features](https://developers.openai.com/codex/cli/features#connect-the-tui-to-a-remote-app-server) for setup examples and authentication guidance. key: "Disable subcommand",
495495 type: "codex features disable <feature>",
496496### `codex app-server` description:
497497 "Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided.",
498498Launch the Codex app server locally. This is primarily for development and debugging and may change without notice. },
499499 ];
500500| Key | Type / Values | Details |
501501| --- | --- | --- |export const execResumeOptions = [
502502| `--listen` | `stdio:// | ws://IP:PORT` | Transport listener URL. Use `ws://IP:PORT` to expose a WebSocket endpoint for remote clients. | {
503503| `--ws-audience` | `string` | Expected `aud` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`. | key: "SESSION_ID",
504504| `--ws-auth` | `capability-token | signed-bearer-token` | Authentication mode for app-server WebSocket clients. If omitted, WebSocket auth is disabled; non-local listeners warn during startup. | type: "uuid",
505505| `--ws-issuer` | `string` | Expected `iss` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`. | description:
506506| `--ws-max-clock-skew-seconds` | `number` | Clock skew allowance when validating signed bearer token `exp` and `nbf` claims. Requires `--ws-auth signed-bearer-token`. | "Resume the specified session. Omit and use `--last` to continue the most recent session.",
507507| `--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`. | },
508508| `--ws-token-file` | `absolute path` | File containing the shared capability token. Required with `--ws-auth capability-token`. | {
509509 key: "--last",
510510Key type: "boolean",
511511 defaultValue: "false",
512512`--listen` description:
513513 "Resume the most recent conversation from the current working directory.",
514514Type / Values },
515515 {
516516`stdio:// | ws://IP:PORT` key: "--all",
517517 type: "boolean",
518518Details defaultValue: "false",
519519 description:
520520Transport listener URL. Use `ws://IP:PORT` to expose a WebSocket endpoint for remote clients. "Include sessions outside the current working directory when selecting the most recent session.",
521521 },
522522Key {
523523 key: "--image, -i",
524524`--ws-audience` type: "path[,path...]",
525525 description:
526526Type / Values "Attach one or more images to the follow-up prompt. Separate multiple paths with commas or repeat the flag.",
527527 },
528528`string` {
529529 key: "PROMPT",
530530Details type: "string | - (read stdin)",
531531 description:
532532Expected `aud` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`. "Optional follow-up instruction sent immediately after resuming.",
533533 },
534534Key];
535535
536536`--ws-auth`export const forkOptions = [
537537 {
538538Type / Values key: "SESSION_ID",
539539 type: "uuid",
540540`capability-token | signed-bearer-token` description:
541541 "Fork the specified session. Omit and use `--last` to fork the most recent session.",
542542Details },
543543 {
544544Authentication mode for app-server WebSocket clients. If omitted, WebSocket auth is disabled; non-local listeners warn during startup. key: "--last",
545545 type: "boolean",
546546Key defaultValue: "false",
547547 description:
548548`--ws-issuer` "Skip the picker and fork the most recent conversation automatically.",
549549 },
550550Type / Values {
551551 key: "--all",
552552`string` type: "boolean",
553553 defaultValue: "false",
554554Details description:
555555 "Show sessions beyond the current working directory in the picker.",
556556Expected `iss` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`. },
557557 ];
558558Key
559559 export const execpolicyOptions = [
560560`--ws-max-clock-skew-seconds` {
561561 key: "--rules, -r",
562562Type / Values type: "path (repeatable)",
563563 description:
564564`number` "Path to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across files.",
565565 },
566566Details {
567567 key: "--pretty",
568568Clock skew allowance when validating signed bearer token `exp` and `nbf` claims. Requires `--ws-auth signed-bearer-token`. type: "boolean",
569569 defaultValue: "false",
570570Key description: "Pretty-print the JSON result.",
571571 },
572572`--ws-shared-secret-file` {
573573 key: "COMMAND...",
574574Type / Values type: "var-args",
575575 description: "Command to be checked against the specified policies.",
576576`absolute path` },
577577 ];
578578Details
579579 export const loginOptions = [
580580File containing the HMAC shared secret used to validate signed JWT bearer tokens. Required with `--ws-auth signed-bearer-token`. {
581581 key: "--with-api-key",
582582Key type: "boolean",
583583 description:
584584`--ws-token-file` "Read an API key from stdin (for example `printenv OPENAI_API_KEY | codex login --with-api-key`).",
585585 },
586586Type / Values {
587587 key: "--device-auth",
588588`absolute path` type: "boolean",
589589 description:
590590Details "Use OAuth device code flow instead of launching a browser window.",
591591 },
592592File containing the shared capability token. Required with `--ws-auth capability-token`. {
593593 key: "status subcommand",
594594`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://`. If you generate schemas for client bindings, add `--experimental` to include gated fields and methods. type: "codex login status",
595595 description:
596596### `codex app` "Print the active authentication mode and exit with 0 when logged in.",
597597 },
598598Launch Codex Desktop from the terminal on macOS and optionally open a specific workspace path.];
599599
600600| Key | Type / Values | Details |export const applyOptions = [
601601| --- | --- | --- | {
602602| `--download-url` | `url` | Advanced override for the Codex desktop DMG download URL used during install. | key: "TASK_ID",
603603| `PATH` | `path` | Workspace path to open in Codex Desktop (`codex app` is available on macOS only). | type: "string",
604604 description:
605605Key "Identifier of the Codex Cloud task whose diff should be applied.",
606606 },
607607`--download-url`];
608608
609609Type / Valuesexport const sandboxMacOptions = [
610610 {
611611`url` key: "--permissions-profile",
612612 type: "NAME",
613613Details description:
614614 "Apply a named permissions profile from the active configuration stack.",
615615Advanced override for the Codex desktop DMG download URL used during install. },
616616 {
617617Key key: "--cd, -C",
618618 type: "DIR",
619619`PATH` description:
620620 "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
621621Type / Values },
622622 {
623623`path` key: "--include-managed-config",
624624 type: "boolean",
625625Details defaultValue: "false",
626626 description:
627627Workspace path to open in Codex Desktop (`codex app` is available on macOS only). "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
628628 },
629629`codex app` installs/opens the desktop app on macOS, then opens the provided workspace path. This subcommand is macOS-only. {
630630 key: "--allow-unix-socket",
631631### `codex debug app-server send-message-v2` type: "path",
632632 description:
633633Send one message through app-server's V2 thread/turn flow using the built-in app-server test client. "Allow the sandboxed command to bind or connect Unix sockets rooted at this path. Repeat to allow multiple paths.",
634634 },
635635| Key | Type / Values | Details | {
636636| --- | --- | --- | key: "--log-denials",
637637| `USER_MESSAGE` | `string` | Message text sent to app-server through the built-in V2 test-client flow. | type: "boolean",
638638 defaultValue: "false",
639639Key description:
640640 "Capture macOS sandbox denials with `log stream` while the command runs and print them after exit.",
641641`USER_MESSAGE` },
642642 {
643643Type / Values key: "--config, -c",
644644 type: "key=value",
645645`string` description:
646646 "Pass configuration overrides into the sandboxed run (repeatable).",
647647Details },
648648 {
649649Message text sent to app-server through the built-in V2 test-client flow. key: "COMMAND...",
650650 type: "var-args",
651651This 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. description:
652652 "Shell command to execute under macOS Seatbelt. Everything after `--` is forwarded.",
653653### `codex apply` },
654654 ];
655655Apply the most recent diff from a Codex cloud task to your local repository. You must authenticate and have access to the task.
656656 export const sandboxLinuxOptions = [
657657| Key | Type / Values | Details | {
658658| --- | --- | --- | key: "--permissions-profile",
659659| `TASK_ID` | `string` | Identifier of the Codex Cloud task whose diff should be applied. | type: "NAME",
660660 description:
661661Key "Apply a named permissions profile from the active configuration stack.",
662662 },
663663`TASK_ID` {
664664 key: "--cd, -C",
665665Type / Values type: "DIR",
666666 description:
667667`string` "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
668668 },
669669Details {
670670 key: "--include-managed-config",
671671Identifier of the Codex Cloud task whose diff should be applied. type: "boolean",
672672 defaultValue: "false",
673673Codex prints the patched files and exits non-zero if `git apply` fails (for example, due to conflicts). description:
674674 "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
675675### `codex cloud` },
676676 {
677677Interact 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: "--config, -c",
678678 type: "key=value",
679679| Key | Type / Values | Details | description:
680680| --- | --- | --- | "Configuration overrides applied before launching the sandbox (repeatable).",
681681| `--attempts` | `1-4` | Number of assistant attempts (best-of-N) Codex Cloud should run. | },
682682| `--env` | `ENV_ID` | Target Codex Cloud environment identifier (required). Use `codex cloud` to list options. | {
683683| `QUERY` | `string` | Task prompt. If omitted, Codex prompts interactively for details. | key: "COMMAND...",
684684 type: "var-args",
685685Key description:
686686 "Command to execute under Landlock + seccomp. Provide the executable after `--`.",
687687`--attempts` },
688688 ];
689689Type / Values
690690 export const sandboxWindowsOptions = [
691691`1-4` {
692692 key: "--permissions-profile",
693693Details type: "NAME",
694694 description:
695695Number of assistant attempts (best-of-N) Codex Cloud should run. "Apply a named permissions profile from the active configuration stack.",
696696 },
697697Key {
698698 key: "--cd, -C",
699699`--env` type: "DIR",
700700 description:
701701Type / Values "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
702702 },
703703`ENV_ID` {
704704 key: "--include-managed-config",
705705Details type: "boolean",
706706 defaultValue: "false",
707707Target Codex Cloud environment identifier (required). Use `codex cloud` to list options. description:
708708 "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
709709Key },
710710 {
711711`QUERY` key: "--config, -c",
712712 type: "key=value",
713713Type / Values description:
714714 "Configuration overrides applied before launching the sandbox (repeatable).",
715715`string` },
716716 {
717717Details key: "COMMAND...",
718718 type: "var-args",
719719Task prompt. If omitted, Codex prompts interactively for details. description:
720720 "Command to execute under the native Windows sandbox. Provide the executable after `--`.",
721721Authentication follows the same credentials as the main CLI. Codex exits non-zero if the task submission fails. },
722722 ];
723723#### `codex cloud list`
724724 export const completionOptions = [
725725List recent cloud tasks with optional filtering and pagination. {
726726 key: "SHELL",
727727| Key | Type / Values | Details | type: "bash | zsh | fish | power-shell | elvish",
728728| --- | --- | --- | defaultValue: "bash",
729729| `--cursor` | `string` | Pagination cursor returned by a previous request. | description: "Shell to generate completions for. Output prints to stdout.",
730730| `--env` | `ENV_ID` | Filter tasks by environment identifier. | },
731731| `--json` | `boolean` | Emit machine-readable JSON instead of plain text. |];
732732| `--limit` | `1-20` | Maximum number of tasks to return. |
733733 export const cloudExecOptions = [
734734Key {
735735 key: "QUERY",
736736`--cursor` type: "string",
737737 description:
738738Type / Values "Task prompt. If omitted, Codex prompts interactively for details.",
739739 },
740740`string` {
741741 key: "--env",
742742Details type: "ENV_ID",
743743 description:
744744Pagination cursor returned by a previous request. "Target Codex Cloud environment identifier (required). Use `codex cloud` to list options.",
745745 },
746746Key {
747747 key: "--attempts",
748748`--env` type: "1-4",
749749 defaultValue: "1",
750750Type / Values description:
751751 "Number of assistant attempts (best-of-N) Codex Cloud should run.",
752752`ENV_ID` },
753753 ];
754754Details
755755 export const cloudListOptions = [
756756Filter tasks by environment identifier. {
757757 key: "--env",
758758Key type: "ENV_ID",
759759 description: "Filter tasks by environment identifier.",
760760`--json` },
761761 {
762762Type / Values key: "--limit",
763763 type: "1-20",
764764`boolean` defaultValue: "20",
765765 description: "Maximum number of tasks to return.",
766766Details },
767767 {
768768Emit machine-readable JSON instead of plain text. key: "--cursor",
769769 type: "string",
770770Key description: "Pagination cursor returned by a previous request.",
771771 },
772772`--limit` {
773773 key: "--json",
774774Type / Values type: "boolean",
775775 defaultValue: "false",
776776`1-20` description: "Emit machine-readable JSON instead of plain text.",
777777 },
778778Details];
779779
780780Maximum number of tasks to return.export const mcpCommands = [
781781 {
782782Plain-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`. key: "list",
783783 type: "--json",
784784### `codex completion` description:
785785 "List configured MCP servers. Add `--json` for machine-readable output.",
786786Generate shell completion scripts and redirect the output to the appropriate location, for example `codex completion zsh > "${fpath[1]}/_codex"`. },
787787 {
788788| Key | Type / Values | Details | key: "get <name>",
789789| --- | --- | --- | type: "--json",
790790| `SHELL` | `bash | zsh | fish | power-shell | elvish` | Shell to generate completions for. Output prints to stdout. | description:
791791 "Show a specific server configuration. `--json` prints the raw config entry.",
792792Key },
793793 {
794794`SHELL` key: "add <name>",
795795 type: "-- <command...> | --url <value>",
796796Type / Values description:
797797 "Register a server using a stdio launcher command or a streamable HTTP URL. Supports `--env KEY=VALUE` for stdio transports.",
798798`bash | zsh | fish | power-shell | elvish` },
799799 {
800800Details key: "remove <name>",
801801 description: "Delete a stored MCP server definition.",
802802Shell to generate completions for. Output prints to stdout. },
803803 {
804804### `codex features` key: "login <name>",
805805 type: "--scopes scope1,scope2",
806806Manage 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. description:
807807 "Start an OAuth login for a streamable HTTP server (servers that support OAuth only).",
808808| Key | Type / Values | Details | },
809809| --- | --- | --- | {
810810| `Disable subcommand` | `codex features disable <feature>` | Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided. | key: "logout <name>",
811811| `Enable subcommand` | `codex features enable <feature>` | Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided. | description:
812812| `List subcommand` | `codex features list` | Show known feature flags, their maturity stage, and their effective state. | "Remove stored OAuth credentials for a streamable HTTP server.",
813813 },
814814Key];
815815
816816`Disable subcommand`export const mcpAddOptions = [
817817 {
818818Type / Values key: "COMMAND...",
819819 type: "stdio transport",
820820`codex features disable <feature>` description:
821821 "Executable plus arguments to launch the MCP server. Provide after `--`.",
822822Details },
823823 {
824824Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided. key: "--env KEY=VALUE",
825825 type: "repeatable",
826826Key description:
827827 "Environment variable assignments applied when launching a stdio server.",
828828`Enable subcommand` },
829829 {
830830Type / Values key: "--url",
831831 type: "https://…",
832832`codex features enable <feature>` description:
833833 "Register a streamable HTTP server instead of stdio. Mutually exclusive with `COMMAND...`.",
834834Details },
835835 {
836836Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided. key: "--bearer-token-env-var",
837837 type: "ENV_VAR",
838838Key description:
839839 "Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server.",
840840`List subcommand` },
841841 ];
842842Type / Values
843843 export const marketplaceCommands = [
844844`codex features list` {
845845 key: "add <source>",
846846Details type: "[--ref REF] [--sparse PATH]",
847847 description:
848848Show known feature flags, their maturity stage, and their effective state. "Install a plugin marketplace from GitHub shorthand, a Git URL, an SSH URL, or a local marketplace root directory. `--sparse` is supported only for Git sources and can be repeated.",
849849 },
850850### `codex exec` {
851851 key: "upgrade [marketplace-name]",
852852Use `codex exec` (or the short form `codex e`) for scripted or CI-style runs that should finish without human interaction. description:
853853 "Refresh one configured Git marketplace, or all configured Git marketplaces when no name is provided.",
854854| Key | Type / Values | Details | },
855855| --- | --- | --- | {
856856| `--cd, -C` | `path` | Set the workspace root before executing the task. | key: "remove <marketplace-name>",
857857| `--color` | `always | never | auto` | Control ANSI color in stdout. | description: "Remove a configured plugin marketplace.",
858858| `--dangerously-bypass-approvals-and-sandbox, --yolo` | `boolean` | Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner. | },
859859| `--ephemeral` | `boolean` | Run without persisting session rollout files to disk. |];
860| `--full-auto` | `boolean` | Apply the low-friction automation preset (`workspace-write` sandbox and `on-request` approvals). |
861| `--image, -i` | `path[,path...]` | Attach images to the first message. Repeatable; supports comma-separated lists. |
862| `--json, --experimental-json` | `boolean` | Print newline-delimited JSON events instead of formatted text. |
863| `--model, -m` | `string` | Override the configured model for this run. |
864| `--oss` | `boolean` | Use the local open source provider (requires a running Ollama instance). |
865| `--output-last-message, -o` | `path` | Write the assistant’s final message to a file. Useful for downstream scripting. |
866| `--output-schema` | `path` | JSON Schema file describing the expected final response shape. Codex validates tool output against it. |
867| `--profile, -p` | `string` | Select a configuration profile defined in config.toml. |
868| `--sandbox, -s` | `read-only | workspace-write | danger-full-access` | Sandbox policy for model-generated commands. Defaults to configuration. |
869| `--skip-git-repo-check` | `boolean` | Allow running outside a Git repository (useful for one-off directories). |
870| `-c, --config` | `key=value` | Inline configuration override for the non-interactive run (repeatable). |
871| `PROMPT` | `string | - (read stdin)` | Initial instruction for the task. Use `-` to pipe the prompt from stdin. |
872| `Resume subcommand` | `codex exec resume [SESSION_ID]` | Resume an exec session by ID or add `--last` to continue the most recent session from the current working directory. Add `--all` to consider sessions from any directory. Accepts an optional follow-up prompt. |
873
874Key
875
876`--cd, -C`
877
878Type / Values
879
880`path`
881
882Details
883
884Set the workspace root before executing the task.
885
886Key
887
888`--color`
889
890Type / Values
891
892`always | never | auto`
893
894Details
895
896Control ANSI color in stdout.
897
898Key
899
900`--dangerously-bypass-approvals-and-sandbox, --yolo`
901
902Type / Values
903
904`boolean`
905
906Details
907
908Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner.
909
910Key
911
912`--ephemeral`
913
914Type / Values
915
916`boolean`
917
918Details
919 860
920861Run without persisting session rollout files to disk.## How to read this reference
921
922Key
923
924`--full-auto`
925
926Type / Values
927
928`boolean`
929
930Details
931
932Apply the low-friction automation preset (`workspace-write` sandbox and `on-request` approvals).
933
934Key
935
936`--image, -i`
937
938Type / Values
939
940`path[,path...]`
941
942Details
943
944Attach images to the first message. Repeatable; supports comma-separated lists.
945
946Key
947
948`--json, --experimental-json`
949
950Type / Values
951
952`boolean`
953
954Details
955
956Print newline-delimited JSON events instead of formatted text.
957
958Key
959
960`--model, -m`
961
962Type / Values
963
964`string`
965
966Details
967
968Override the configured model for this run.
969
970Key
971
972`--oss`
973
974Type / Values
975
976`boolean`
977
978Details
979
980Use the local open source provider (requires a running Ollama instance).
981 862
982863KeyThis 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.
983 864
984865`--output-last-message, -o`The CLI inherits most defaults from <code>~/.codex/config.toml</code>. Any
866 <code>-c key=value</code> overrides you pass at the command line take
867 precedence for that invocation. See [Config
868 basics](https://developers.openai.com/codex/config-basic#configuration-precedence) for more information.
985 869
986870Type / Values## Global flags
987 871
988872`path`<ConfigTable client:load options={globalFlagOptions} />
989 873
990874DetailsThese options apply to the base `codex` command and propagate to each subcommand unless a section below specifies otherwise.
875When you run a subcommand, place global flags after it (for example, `codex exec --oss ...`) so Codex applies them as intended.
991 876
992877Write the assistant’s final message to a file. Useful for downstream scripting.## Command overview
993 878
994879KeyThe Maturity column uses feature maturity labels such as Experimental, Beta,
880 and Stable. See [Feature Maturity](https://developers.openai.com/codex/feature-maturity) for how to
881 interpret these labels.
995 882
996883`--output-schema`<ConfigTable
884 client:load
885 options={commandOverview}
886 secondColumnTitle="Maturity"
887 secondColumnVariant="maturity"
888/>
997 889
998890Type / Values## Command details
999 891
1000892`path`### `codex` (interactive)
1001 893
1002894DetailsRunning `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`.
1003 895
1004896JSON Schema file describing the expected final response shape. Codex validates tool output against it.Use `--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. See [Codex CLI features](https://developers.openai.com/codex/cli/features#connect-the-tui-to-a-remote-app-server) for setup examples and authentication guidance.
1005 897
1006898Key### `codex app-server`
1007 899
1008900`--profile, -p`Launch the Codex app server locally. This is primarily for development and debugging and may change without notice.
1009 901
1010902Type / Values<ConfigTable client:load options={appServerOptions} />
1011 903
1012904`string``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://`. If you generate schemas for client bindings, add `--experimental` to include gated fields and methods.
1013 905
1014906Details### `codex app`
1015 907
1016908Select a configuration profile defined in config.toml.Launch Codex Desktop from the terminal on macOS or Windows. On macOS, Codex can open a specific workspace path; on Windows, Codex prints the path to open.
1017 909
1018910Key<ConfigTable client:load options={appOptions} />
1019 911
1020912`--sandbox, -s``codex app` opens an installed Codex Desktop app, or starts the installer when
913the app is missing. On macOS, Codex opens the provided workspace path; on
914Windows, it prints the path to open after installation.
1021 915
1022916Type / Values### `codex debug app-server send-message-v2`
1023 917
1024918`read-only | workspace-write | danger-full-access`Send one message through app-server's V2 thread/turn flow using the built-in app-server test client.
1025 919
1026920Details<ConfigTable client:load options={debugAppServerSendMessageV2Options} />
1027 921
1028922Sandbox policy for model-generated commands. Defaults to configuration.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.
1029 923
1030924Key### `codex debug models`
1031 925
1032926`--skip-git-repo-check`Print the raw model catalog Codex sees as JSON.
1033 927
1034928Type / Values<ConfigTable client:load options={debugModelsOptions} />
1035 929
1036930`boolean`Use `--bundled` when you want to inspect only the catalog bundled with the current binary, without refreshing from the remote models endpoint.
1037 931
1038932Details### `codex apply`
1039 933
1040934Allow running outside a Git repository (useful for one-off directories).Apply the most recent diff from a Codex cloud task to your local repository. You must authenticate and have access to the task.
1041 935
1042936Key<ConfigTable client:load options={applyOptions} />
1043 937
1044938`-c, --config`Codex prints the patched files and exits non-zero if `git apply` fails (for example, due to conflicts).
1045 939
1046940Type / Values### `codex cloud`
1047 941
1048942`key=value`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.
1049 943
1050944Details<ConfigTable client:load options={cloudExecOptions} />
1051 945
1052946Inline configuration override for the non-interactive run (repeatable).Authentication follows the same credentials as the main CLI. Codex exits non-zero if the task submission fails.
1053 947
1054948Key#### `codex cloud list`
1055 949
1056950`PROMPT`List recent cloud tasks with optional filtering and pagination.
1057 951
1058952Type / Values<ConfigTable client:load options={cloudListOptions} />
1059 953
1060954`string | - (read stdin)`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`.
1061 955
1062956Details### `codex completion`
1063 957
1064958Initial instruction for the task. Use `-` to pipe the prompt from stdin.Generate shell completion scripts and redirect the output to the appropriate location, for example `codex completion zsh > "${fpath[1]}/_codex"`.
1065 959
1066960Key<ConfigTable client:load options={completionOptions} />
1067 961
1068962`Resume subcommand`### `codex features`
1069 963
1070964Type / ValuesManage 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.
1071 965
1072966`codex exec resume [SESSION_ID]`<ConfigTable client:load options={featuresOptions} />
1073 967
1074968Details### `codex exec`
1075 969
1076970Resume an exec session by ID or add `--last` to continue the most recent session from the current working directory. Add `--all` to consider sessions from any directory. Accepts an optional follow-up prompt.Use `codex exec` (or the short form `codex e`) for scripted or CI-style runs that should finish without human interaction.
1077 971
1078972Expand to view all<ConfigTable client:load options={execOptions} />
1079 973
1080Codex 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:974Codex 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:
1081 975
1082976| Key | Type / Values | Details |<ConfigTable client:load options={execResumeOptions} />
1083| --- | --- | --- |
1084| `--all` | `boolean` | Include sessions outside the current working directory when selecting the most recent session. |
1085| `--image, -i` | `path[,path...]` | Attach one or more images to the follow-up prompt. Separate multiple paths with commas or repeat the flag. |
1086| `--last` | `boolean` | Resume the most recent conversation from the current working directory. |
1087| `PROMPT` | `string | - (read stdin)` | Optional follow-up instruction sent immediately after resuming. |
1088| `SESSION_ID` | `uuid` | Resume the specified session. Omit and use `--last` to continue the most recent session. |
1089
1090Key
1091
1092`--all`
1093
1094Type / Values
1095
1096`boolean`
1097
1098Details
1099
1100Include sessions outside the current working directory when selecting the most recent session.
1101
1102Key
1103
1104`--image, -i`
1105
1106Type / Values
1107
1108`path[,path...]`
1109
1110Details
1111
1112Attach one or more images to the follow-up prompt. Separate multiple paths with commas or repeat the flag.
1113
1114Key
1115
1116`--last`
1117
1118Type / Values
1119
1120`boolean`
1121
1122Details
1123
1124Resume the most recent conversation from the current working directory.
1125
1126Key
1127
1128`PROMPT`
1129
1130Type / Values
1131
1132`string | - (read stdin)`
1133
1134Details
1135
1136Optional follow-up instruction sent immediately after resuming.
1137
1138Key
1139
1140`SESSION_ID`
1141
1142Type / Values
1143
1144`uuid`
1145
1146Details
1147
1148Resume the specified session. Omit and use `--last` to continue the most recent session.
1149 977
1150### `codex execpolicy`978### `codex execpolicy`
1151 979
1152Check `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.980Check `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.
1153 981
1154982| Key | Type / Values | Details |<ConfigTable client:load options={execpolicyOptions} />
1155| --- | --- | --- |
1156| `--pretty` | `boolean` | Pretty-print the JSON result. |
1157| `--rules, -r` | `path (repeatable)` | Path to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across files. |
1158| `COMMAND...` | `var-args` | Command to be checked against the specified policies. |
1159
1160Key
1161
1162`--pretty`
1163
1164Type / Values
1165
1166`boolean`
1167
1168Details
1169
1170Pretty-print the JSON result.
1171
1172Key
1173
1174`--rules, -r`
1175
1176Type / Values
1177
1178`path (repeatable)`
1179
1180Details
1181
1182Path to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across files.
1183
1184Key
1185
1186`COMMAND...`
1187
1188Type / Values
1189
1190`var-args`
1191
1192Details
1193
1194Command to be checked against the specified policies.
1195 983
1196### `codex login`984### `codex login`
1197 985
1198Authenticate the CLI with a ChatGPT account or API key. With no flags, Codex opens a browser for the ChatGPT OAuth flow.986Authenticate the CLI with a ChatGPT account or API key. With no flags, Codex opens a browser for the ChatGPT OAuth flow.
1199 987
1200988| Key | Type / Values | Details |<ConfigTable client:load options={loginOptions} />
1201| --- | --- | --- |
1202| `--device-auth` | `boolean` | Use OAuth device code flow instead of launching a browser window. |
1203| `--with-api-key` | `boolean` | Read an API key from stdin (for example `printenv OPENAI_API_KEY | codex login --with-api-key`). |
1204| `status subcommand` | `codex login status` | Print the active authentication mode and exit with 0 when logged in. |
1205
1206Key
1207
1208`--device-auth`
1209
1210Type / Values
1211
1212`boolean`
1213
1214Details
1215
1216Use OAuth device code flow instead of launching a browser window.
1217
1218Key
1219
1220`--with-api-key`
1221
1222Type / Values
1223
1224`boolean`
1225
1226Details
1227
1228Read an API key from stdin (for example `printenv OPENAI_API_KEY | codex login --with-api-key`).
1229
1230Key
1231
1232`status subcommand`
1233
1234Type / Values
1235
1236`codex login status`
1237
1238Details
1239
1240Print the active authentication mode and exit with 0 when logged in.
1241 989
1242`codex login status` exits with `0` when credentials are present, which is helpful in automation scripts.990`codex login status` exits with `0` when credentials are present, which is helpful in automation scripts.
1243 991
1249 997
1250Manage Model Context Protocol server entries stored in `~/.codex/config.toml`.998Manage Model Context Protocol server entries stored in `~/.codex/config.toml`.
1251 999
12521000| Key | Type / Values | Details |<ConfigTable client:load options={mcpCommands} />
1253| --- | --- | --- |
1254| `add <name>` | `-- <command...> | --url <value>` | Register a server using a stdio launcher command or a streamable HTTP URL. Supports `--env KEY=VALUE` for stdio transports. |
1255| `get <name>` | `--json` | Show a specific server configuration. `--json` prints the raw config entry. |
1256| `list` | `--json` | List configured MCP servers. Add `--json` for machine-readable output. |
1257| `login <name>` | `--scopes scope1,scope2` | Start an OAuth login for a streamable HTTP server (servers that support OAuth only). |
1258| `logout <name>` | | Remove stored OAuth credentials for a streamable HTTP server. |
1259| `remove <name>` | | Delete a stored MCP server definition. |
1260
1261Key
1262
1263`add <name>`
1264
1265Type / Values
1266
1267`-- <command...> | --url <value>`
1268
1269Details
1270
1271Register a server using a stdio launcher command or a streamable HTTP URL. Supports `--env KEY=VALUE` for stdio transports.
1272
1273Key
1274
1275`get <name>`
1276
1277Type / Values
1278
1279`--json`
1280
1281Details
1282
1283Show a specific server configuration. `--json` prints the raw config entry.
1284
1285Key
1286
1287`list`
1288
1289Type / Values
1290
1291`--json`
1292
1293Details
1294
1295List configured MCP servers. Add `--json` for machine-readable output.
1296
1297Key
1298
1299`login <name>`
1300
1301Type / Values
1302
1303`--scopes scope1,scope2`
1304
1305Details
1306
1307Start an OAuth login for a streamable HTTP server (servers that support OAuth only).
1308
1309Key
1310
1311`logout <name>`
1312
1313Details
1314
1315Remove stored OAuth credentials for a streamable HTTP server.
1316
1317Key
1318
1319`remove <name>`
1320
1321Details
1322
1323Delete a stored MCP server definition.
1324 1001
1325The `add` subcommand supports both stdio and streamable HTTP transports:1002The `add` subcommand supports both stdio and streamable HTTP transports:
1326 1003
13271004| Key | Type / Values | Details |<ConfigTable client:load options={mcpAddOptions} />
1328| --- | --- | --- |
1329| `--bearer-token-env-var` | `ENV_VAR` | Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server. |
1330| `--env KEY=VALUE` | `repeatable` | Environment variable assignments applied when launching a stdio server. |
1331| `--url` | `https://…` | Register a streamable HTTP server instead of stdio. Mutually exclusive with `COMMAND...`. |
1332| `COMMAND...` | `stdio transport` | Executable plus arguments to launch the MCP server. Provide after `--`. |
1333
1334Key
1335
1336`--bearer-token-env-var`
1337
1338Type / Values
1339
1340`ENV_VAR`
1341
1342Details
1343
1344Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server.
1345
1346Key
1347
1348`--env KEY=VALUE`
1349
1350Type / Values
1351
1352`repeatable`
1353 1005
13541006DetailsOAuth actions (`login`, `logout`) only work with streamable HTTP servers (and only when the server supports OAuth).
1355
1356Environment variable assignments applied when launching a stdio server.
1357
1358Key
1359
1360`--url`
1361
1362Type / Values
1363
1364`https://…`
1365
1366Details
1367
1368Register a streamable HTTP server instead of stdio. Mutually exclusive with `COMMAND...`.
1369
1370Key
1371
1372`COMMAND...`
1373
1374Type / Values
1375 1007
13761008`stdio transport`### `codex plugin marketplace`
1377 1009
13781010DetailsManage plugin marketplace sources that Codex can browse and install from.
1379 1011
13801012Executable plus arguments to launch the MCP server. Provide after `--`.<ConfigTable client:load options={marketplaceCommands} />
1381 1013
13821014OAuth actions (`login`, `logout`) only work with streamable HTTP servers (and only when the server supports OAuth).`codex plugin marketplace add` accepts GitHub shorthand such as `owner/repo` or
1015`owner/repo@ref`, HTTP or HTTPS Git URLs, SSH Git URLs, and local marketplace
1016root directories. Use `--ref` to pin a Git ref, and repeat `--sparse PATH` to
1017use a sparse checkout for Git-backed marketplace repositories.
1383 1018
1384### `codex mcp-server`1019### `codex mcp-server`
1385 1020
1389 1024
1390Continue 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.1025Continue 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.
1391 1026
13921027| Key | Type / Values | Details |<ConfigTable client:load options={resumeOptions} />
1393| --- | --- | --- |
1394| `--all` | `boolean` | Include sessions outside the current working directory when selecting the most recent session. |
1395| `--last` | `boolean` | Skip the picker and resume the most recent conversation from the current working directory. |
1396| `SESSION_ID` | `uuid` | Resume the specified session. Omit and use `--last` to continue the most recent session. |
1397
1398Key
1399
1400`--all`
1401
1402Type / Values
1403
1404`boolean`
1405
1406Details
1407
1408Include sessions outside the current working directory when selecting the most recent session.
1409
1410Key
1411
1412`--last`
1413
1414Type / Values
1415
1416`boolean`
1417
1418Details
1419
1420Skip the picker and resume the most recent conversation from the current working directory.
1421
1422Key
1423
1424`SESSION_ID`
1425
1426Type / Values
1427
1428`uuid`
1429
1430Details
1431
1432Resume the specified session. Omit and use `--last` to continue the most recent session.
1433 1028
1434### `codex fork`1029### `codex fork`
1435 1030
1436Fork 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.1031Fork 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.
1437 1032
14381033| Key | Type / Values | Details |<ConfigTable client:load options={forkOptions} />
1439| --- | --- | --- |
1440| `--all` | `boolean` | Show sessions beyond the current working directory in the picker. |
1441| `--last` | `boolean` | Skip the picker and fork the most recent conversation automatically. |
1442| `SESSION_ID` | `uuid` | Fork the specified session. Omit and use `--last` to fork the most recent session. |
1443
1444Key
1445
1446`--all`
1447
1448Type / Values
1449
1450`boolean`
1451
1452Details
1453
1454Show sessions beyond the current working directory in the picker.
1455
1456Key
1457
1458`--last`
1459
1460Type / Values
1461
1462`boolean`
1463
1464Details
1465
1466Skip the picker and fork the most recent conversation automatically.
1467
1468Key
1469
1470`SESSION_ID`
1471
1472Type / Values
1473
1474`uuid`
1475
1476Details
1477
1478Fork the specified session. Omit and use `--last` to fork the most recent session.
1479 1034
1480### `codex sandbox`1035### `codex sandbox`
1481 1036
1483 1038
1484#### macOS seatbelt1039#### macOS seatbelt
1485 1040
14861041| Key | Type / Values | Details |<ConfigTable client:load options={sandboxMacOptions} />
1487| --- | --- | --- |
1488| `--config, -c` | `key=value` | Pass configuration overrides into the sandboxed run (repeatable). |
1489| `--full-auto` | `boolean` | Grant write access to the current workspace and `/tmp` without approvals. |
1490| `COMMAND...` | `var-args` | Shell command to execute under macOS Seatbelt. Everything after `--` is forwarded. |
1491
1492Key
1493
1494`--config, -c`
1495
1496Type / Values
1497
1498`key=value`
1499
1500Details
1501
1502Pass configuration overrides into the sandboxed run (repeatable).
1503
1504Key
1505
1506`--full-auto`
1507
1508Type / Values
1509
1510`boolean`
1511
1512Details
1513
1514Grant write access to the current workspace and `/tmp` without approvals.
1515
1516Key
1517
1518`COMMAND...`
1519
1520Type / Values
1521
1522`var-args`
1523
1524Details
1525
1526Shell command to execute under macOS Seatbelt. Everything after `--` is forwarded.
1527 1042
1528#### Linux Landlock1043#### Linux Landlock
1529 1044
15301045| Key | Type / Values | Details |<ConfigTable client:load options={sandboxLinuxOptions} />
1531| --- | --- | --- |
1532| `--config, -c` | `key=value` | Configuration overrides applied before launching the sandbox (repeatable). |
1533| `--full-auto` | `boolean` | Grant write access to the current workspace and `/tmp` inside the Landlock sandbox. |
1534| `COMMAND...` | `var-args` | Command to execute under Landlock + seccomp. Provide the executable after `--`. |
1535
1536Key
1537
1538`--config, -c`
1539
1540Type / Values
1541
1542`key=value`
1543
1544Details
1545
1546Configuration overrides applied before launching the sandbox (repeatable).
1547
1548Key
1549
1550`--full-auto`
1551
1552Type / Values
1553
1554`boolean`
1555
1556Details
1557
1558Grant write access to the current workspace and `/tmp` inside the Landlock sandbox.
1559
1560Key
1561
1562`COMMAND...`
1563 1046
15641047Type / Values#### Windows
1565 1048
15661049`var-args`<ConfigTable client:load options={sandboxWindowsOptions} />
1567 1050
15681051Details### `codex update`
1569 1052
15701053Command to execute under Landlock + seccomp. Provide the executable after `--`.Check for and apply a Codex CLI update when the installed release supports self-update. Debug builds print a message telling you to install a release build instead.
1571 1054
1572## Flag combinations and safety tips1055## Flag combinations and safety tips
1573 1056
15741057- 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.- Use `--sandbox workspace-write` for unattended local work that can stay inside the workspace, and avoid `--dangerously-bypass-approvals-and-sandbox` unless you are inside a dedicated sandbox VM.
1575- When you need to grant Codex write access to more directories, prefer `--add-dir` rather than forcing `--sandbox danger-full-access`.1058- When you need to grant Codex write access to more directories, prefer `--add-dir` rather than forcing `--sandbox danger-full-access`.
1576- Pair `--json` with `--output-last-message` in CI to capture machine-readable progress and a final natural-language summary.1059- Pair `--json` with `--output-last-message` in CI to capture machine-readable progress and a final natural-language summary.
1577 1060