cli/reference.md +942 −1353
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-codex`). | 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| `--sandbox, -s` | `read-only | workspace-write | danger-full-access` | Select the sandbox policy for model-generated shell commands. | {
3030| `--search` | `boolean` | Enable live web search (sets `web_search = "live"` instead of the default `"cached"`). | key: "--profile, -p",
3131| `PROMPT` | `string` | Optional text instruction to start the session. Omit to launch the TUI without a pre-filled message. | type: "string",
3232 description:
3333Key "Configuration profile name to load from `~/.codex/config.toml`.",
3434 },
3535`--add-dir` {
3636 key: "--sandbox, -s",
3737Type / Values type: "read-only | workspace-write | danger-full-access",
3838 description:
3939`path` "Select the sandbox policy for model-generated shell commands.",
4040 },
4141Details {
4242 key: "--ask-for-approval, -a",
4343Grant additional directories write access alongside the main workspace. Repeat for multiple paths. type: "untrusted | on-request | never",
4444 description:
4545Key "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 },
4747`--ask-for-approval, -a` {
4848 key: "--dangerously-bypass-approvals-and-sandbox, --yolo",
4949Type / Values type: "boolean",
5050 defaultValue: "false",
5151`untrusted | on-request | never` description:
5252 "Run every command without approvals or sandboxing. Only use inside an externally hardened environment.",
5353Details },
5454 {
5555Control 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: "--cd, -C",
5656 type: "path",
5757Key description:
5858 "Set the working directory for the agent before it starts processing your request.",
5959`--cd, -C` },
6060 {
6161Type / Values key: "--search",
6262 type: "boolean",
6363`path` defaultValue: "false",
6464 description:
6565Details 'Enable live web search (sets `web_search = "live"` instead of the default `"cached"`).',
6666 },
6767Set the working directory for the agent before it starts processing your request. {
6868 key: "--add-dir",
6969Key type: "path",
7070 description:
7171`--config, -c` "Grant additional directories write access alongside the main workspace. Repeat for multiple paths.",
7272 },
7373Type / Values {
7474 key: "--no-alt-screen",
7575`key=value` type: "boolean",
7676 defaultValue: "false",
7777Details description:
7878 "Disable alternate screen mode for the TUI (overrides `tui.alternate_screen` for this run).",
7979Override configuration values. Values parse as JSON if possible; otherwise the literal string is used. },
8080 {
8181Key key: "--remote",
8282 type: "ws://host:port | wss://host:port",
8383`--dangerously-bypass-approvals-and-sandbox, --yolo` 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.",
8585Type / Values },
8686 {
8787`boolean` key: "--remote-auth-token-env",
8888 type: "ENV_VAR",
8989Details 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`.",
9191Run every command without approvals or sandboxing. Only use inside an externally hardened environment. },
9292 {
9393Key key: "--enable",
9494 type: "feature",
9595`--disable` description:
9696 "Force-enable a feature flag (translates to `-c features.<name>=true`). Repeatable.",
9797Type / Values },
9898 {
9999`feature` key: "--disable",
100100 type: "feature",
101101Details description:
102102 "Force-disable a feature flag (translates to `-c features.<name>=false`). Repeatable.",
103103Force-disable a feature flag (translates to `-c features.<name>=false`). Repeatable. },
104104 {
105105Key key: "--config, -c",
106106 type: "key=value",
107107`--enable` description:
108108 "Override configuration values. Values parse as JSON if possible; otherwise the literal string is used.",
109109Type / Values },
110110 ];
111111`feature`
112112 export const commandOverview = [
113113Details {
114114 key: "codex",
115115Force-enable a feature flag (translates to `-c features.<name>=true`). Repeatable. href: "/codex/cli/reference#codex-interactive",
116116 type: "stable",
117117Key description:
118118 "Launch the terminal UI. Accepts the global flags above plus an optional prompt or image attachments.",
119119`--full-auto` },
120120 {
121121Type / Values key: "codex app-server",
122122 href: "/codex/cli/reference#codex-app-server",
123123`boolean` type: "experimental",
124124 description:
125125Details "Launch the Codex app server for local development or debugging.",
126126 },
127127Shortcut for low-friction local work: sets `--ask-for-approval on-request` and `--sandbox workspace-write`. {
128128 key: "codex app",
129129Key href: "/codex/cli/reference#codex-app",
130130 type: "stable",
131131`--image, -i` 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.",
133133Type / Values },
134134 {
135135`path[,path...]` key: "codex debug app-server send-message-v2",
136136 href: "/codex/cli/reference#codex-debug-app-server-send-message-v2",
137137Details type: "experimental",
138138 description:
139139Attach one or more image files to the initial prompt. Separate multiple paths with commas or repeat the flag. "Debug app-server by sending a single V2 message through the built-in test client.",
140140 },
141141Key {
142142 key: "codex debug models",
143143`--model, -m` href: "/codex/cli/reference#codex-debug-models",
144144 type: "experimental",
145145Type / Values description:
146146 "Print the raw model catalog Codex sees, including an option to inspect only the bundled catalog.",
147147`string` },
148148 {
149149Details key: "codex apply",
150150 href: "/codex/cli/reference#codex-apply",
151151Override the model set in configuration (for example `gpt-5-codex`). type: "stable",
152152 description:
153153Key "Apply the latest diff generated by a Codex Cloud task to your local working tree. Alias: `codex a`.",
154154 },
155155`--no-alt-screen` {
156156 key: "codex cloud",
157157Type / Values href: "/codex/cli/reference#codex-cloud",
158158 type: "experimental",
159159`boolean` description:
160160 "Browse or execute Codex Cloud tasks from the terminal without opening the TUI. Alias: `codex cloud-tasks`.",
161161Details },
162162 {
163163Disable alternate screen mode for the TUI (overrides `tui.alternate_screen` for this run). key: "codex completion",
164164 href: "/codex/cli/reference#codex-completion",
165165Key type: "stable",
166166 description:
167167`--oss` "Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell.",
168168 },
169169Type / Values {
170170 key: "codex features",
171171`boolean` href: "/codex/cli/reference#codex-features",
172172 type: "stable",
173173Details description:
174174 "List feature flags and persistently enable or disable them in `config.toml`.",
175175Use the local open source model provider (equivalent to `-c model_provider="oss"`). Validates that Ollama is running. },
176176 {
177177Key key: "codex exec",
178178 href: "/codex/cli/reference#codex-exec",
179179`--profile, -p` type: "stable",
180180 description:
181181Type / Values "Run Codex non-interactively. Alias: `codex e`. Stream results to stdout or JSONL and optionally resume previous sessions.",
182182 },
183183`string` {
184184 key: "codex execpolicy",
185185Details href: "/codex/cli/reference#codex-execpolicy",
186186 type: "experimental",
187187Configuration profile name to load from `~/.codex/config.toml`. description:
188188 "Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked.",
189189Key },
190190 {
191191`--sandbox, -s` key: "codex login",
192192 href: "/codex/cli/reference#codex-login",
193193Type / Values type: "stable",
194194 description:
195195`read-only | workspace-write | danger-full-access` "Authenticate Codex using ChatGPT OAuth, device auth, or an API key piped over stdin.",
196196 },
197197Details {
198198 key: "codex logout",
199199Select the sandbox policy for model-generated shell commands. href: "/codex/cli/reference#codex-logout",
200200 type: "stable",
201201Key description: "Remove stored authentication credentials.",
202202 },
203203`--search` {
204204 key: "codex mcp",
205205Type / Values href: "/codex/cli/reference#codex-mcp",
206206 type: "experimental",
207207`boolean` description:
208208 "Manage Model Context Protocol servers (list, add, remove, authenticate).",
209209Details },
210210 {
211211Enable live web search (sets `web_search = "live"` instead of the default `"cached"`). key: "codex plugin marketplace",
212212 href: "/codex/cli/reference#codex-plugin-marketplace",
213213Key type: "experimental",
214214 description:
215215`PROMPT` "Add, upgrade, or remove plugin marketplaces from Git or local sources.",
216216 },
217217Type / Values {
218218 key: "codex mcp-server",
219219`string` href: "/codex/cli/reference#codex-mcp-server",
220220 type: "experimental",
221221Details description:
222222 "Run Codex itself as an MCP server over stdio. Useful when another agent consumes Codex.",
223223Optional text instruction to start the session. Omit to launch the TUI without a pre-filled message. },
224224 {
225225Expand to view all key: "codex resume",
226226 href: "/codex/cli/reference#codex-resume",
227227These options apply to the base `codex` command and propagate to each subcommand unless a section below specifies otherwise. type: "stable",
228228When you run a subcommand, place global flags after it (for example, `codex exec --oss ...`) so Codex applies them as intended. description:
229229 "Continue a previous interactive session by ID or resume the most recent conversation.",
230230## Command overview },
231231 {
232232The Maturity column uses feature maturity labels such as Experimental, Beta, key: "codex fork",
233233 and Stable. See [Feature Maturity](https://developers.openai.com/codex/feature-maturity) for how to href: "/codex/cli/reference#codex-fork",
234234 interpret these labels. type: "stable",
235235 description:
236236| Key | Maturity | Details | "Fork a previous interactive session into a new thread, preserving the original transcript.",
237237| --- | --- | --- | },
238238| [`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. | {
239239| [`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. | key: "codex sandbox",
240240| [`codex app-server`](https://developers.openai.com/codex/cli/reference#codex-app-server) | Experimental | Launch the Codex app server for local development or debugging. | href: "/codex/cli/reference#codex-sandbox",
241241| [`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`. | type: "experimental",
242242| [`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`. | description:
243243| [`codex completion`](https://developers.openai.com/codex/cli/reference#codex-completion) | Stable | Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell. | "Run arbitrary commands inside Codex-provided macOS, Linux, or Windows sandboxes.",
244244| [`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. | },
245245| [`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. | {
246246| [`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. | key: "codex update",
247247| [`codex features`](https://developers.openai.com/codex/cli/reference#codex-features) | Stable | List feature flags and persistently enable or disable them in `config.toml`. | href: "/codex/cli/reference#codex-update",
248248| [`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: "stable",
249249| [`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. | description:
250250| [`codex logout`](https://developers.openai.com/codex/cli/reference#codex-logout) | Stable | Remove stored authentication credentials. | "Check for and apply a Codex CLI update when the installed release supports self-update.",
251251| [`codex mcp`](https://developers.openai.com/codex/cli/reference#codex-mcp) | Experimental | Manage Model Context Protocol servers (list, add, remove, authenticate). | },
252252| [`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. |];
253253| [`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. |
254254| [`codex sandbox`](https://developers.openai.com/codex/cli/reference#codex-sandbox) | Experimental | Run arbitrary commands inside Codex-provided macOS seatbelt or Linux sandboxes (Landlock by default, optional bubblewrap pipeline). |export const execOptions = [
255255 {
256256Key key: "PROMPT",
257257 type: "string | - (read stdin)",
258258[`codex`](https://developers.openai.com/codex/cli/reference#codex-interactive) description:
259259 "Initial instruction for the task. Use `-` to pipe the prompt from stdin.",
260260Maturity },
261261 {
262262Stable key: "--image, -i",
263263 type: "path[,path...]",
264264Details description:
265265 "Attach images to the first message. Repeatable; supports comma-separated lists.",
266266Launch the terminal UI. Accepts the global flags above plus an optional prompt or image attachments. },
267267 {
268268Key key: "--model, -m",
269269 type: "string",
270270[`codex app`](https://developers.openai.com/codex/cli/reference#codex-app) description: "Override the configured model for this run.",
271271 },
272272Maturity {
273273 key: "--oss",
274274Stable type: "boolean",
275275 defaultValue: "false",
276276Details description:
277277 "Use the local open source provider (requires a running Ollama instance).",
278278Launch the Codex desktop app on macOS, optionally opening a specific workspace path. },
279279 {
280280Key key: "--sandbox, -s",
281281 type: "read-only | workspace-write | danger-full-access",
282282[`codex app-server`](https://developers.openai.com/codex/cli/reference#codex-app-server) description:
283283 "Sandbox policy for model-generated commands. Defaults to configuration.",
284284Maturity },
285285 {
286286Experimental key: "--profile, -p",
287287 type: "string",
288288Details description: "Select a configuration profile defined in config.toml.",
289289 },
290290Launch the Codex app server for local development or debugging. {
291291 key: "--full-auto",
292292Key type: "boolean",
293293 defaultValue: "false",
294294[`codex apply`](https://developers.openai.com/codex/cli/reference#codex-apply) description:
295295 "Deprecated compatibility flag. Prefer `--sandbox workspace-write`; Codex prints a warning when this flag is used.",
296296Maturity },
297297 {
298298Stable key: "--dangerously-bypass-approvals-and-sandbox, --yolo",
299299 type: "boolean",
300300Details defaultValue: "false",
301301 description:
302302Apply the latest diff generated by a Codex Cloud task to your local working tree. Alias: `codex a`. "Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner.",
303303 },
304304Key {
305305 key: "--cd, -C",
306306[`codex cloud`](https://developers.openai.com/codex/cli/reference#codex-cloud) type: "path",
307307 description: "Set the workspace root before executing the task.",
308308Maturity },
309309 {
310310Experimental key: "--skip-git-repo-check",
311311 type: "boolean",
312312Details defaultValue: "false",
313313 description:
314314Browse or execute Codex Cloud tasks from the terminal without opening the TUI. Alias: `codex cloud-tasks`. "Allow running outside a Git repository (useful for one-off directories).",
315315 },
316316Key {
317317 key: "--ephemeral",
318318[`codex completion`](https://developers.openai.com/codex/cli/reference#codex-completion) type: "boolean",
319319 defaultValue: "false",
320320Maturity description: "Run without persisting session rollout files to disk.",
321321 },
322322Stable {
323323 key: "--ignore-user-config",
324324Details type: "boolean",
325325 defaultValue: "false",
326326Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell. description:
327327 "Do not load `$CODEX_HOME/config.toml`. Authentication still uses `CODEX_HOME`.",
328328Key },
329329 {
330330[`codex debug app-server send-message-v2`](https://developers.openai.com/codex/cli/reference#codex-debug-app-server-send-message-v2) key: "--ignore-rules",
331331 type: "boolean",
332332Maturity defaultValue: "false",
333333 description:
334334Experimental "Do not load user or project execpolicy `.rules` files for this run.",
335335 },
336336Details {
337337 key: "--output-schema",
338338Debug app-server by sending a single V2 message through the built-in test client. type: "path",
339339 description:
340340Key "JSON Schema file describing the expected final response shape. Codex validates tool output against it.",
341341 },
342342[`codex exec`](https://developers.openai.com/codex/cli/reference#codex-exec) {
343343 key: "--color",
344344Maturity type: "always | never | auto",
345345 defaultValue: "auto",
346346Stable description: "Control ANSI color in stdout.",
347347 },
348348Details {
349349 key: "--json, --experimental-json",
350350Run Codex non-interactively. Alias: `codex e`. Stream results to stdout or JSONL and optionally resume previous sessions. type: "boolean",
351351 defaultValue: "false",
352352Key description:
353353 "Print newline-delimited JSON events instead of formatted text.",
354354[`codex execpolicy`](https://developers.openai.com/codex/cli/reference#codex-execpolicy) },
355355 {
356356Maturity key: "--output-last-message, -o",
357357 type: "path",
358358Experimental description:
359359 "Write the assistant’s final message to a file. Useful for downstream scripting.",
360360Details },
361361 {
362362Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked. key: "Resume subcommand",
363363 type: "codex exec resume [SESSION_ID]",
364364Key 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.",
366366[`codex features`](https://developers.openai.com/codex/cli/reference#codex-features) },
367367 {
368368Maturity key: "-c, --config",
369369 type: "key=value",
370370Stable description:
371371 "Inline configuration override for the non-interactive run (repeatable).",
372372Details },
373373 ];
374374List feature flags and persistently enable or disable them in `config.toml`.
375375 export const appServerOptions = [
376376Key {
377377 key: "--listen",
378378[`codex fork`](https://developers.openai.com/codex/cli/reference#codex-fork) type: "stdio:// | ws://IP:PORT",
379379 defaultValue: "stdio://",
380380Maturity description:
381381 "Transport listener URL. Use `ws://IP:PORT` to expose a WebSocket endpoint for remote clients.",
382382Stable },
383383 {
384384Details key: "--ws-auth",
385385 type: "capability-token | signed-bearer-token",
386386Fork a previous interactive session into a new thread, preserving the original transcript. description:
387387 "Authentication mode for app-server WebSocket clients. If omitted, WebSocket auth is disabled; non-local listeners warn during startup.",
388388Key },
389389 {
390390[`codex login`](https://developers.openai.com/codex/cli/reference#codex-login) key: "--ws-token-file",
391391 type: "absolute path",
392392Maturity description:
393393 "File containing the shared capability token. Required with `--ws-auth capability-token`.",
394394Stable },
395395 {
396396Details key: "--ws-shared-secret-file",
397397 type: "absolute path",
398398Authenticate Codex using ChatGPT OAuth, device auth, or an API key piped over stdin. description:
399399 "File containing the HMAC shared secret used to validate signed JWT bearer tokens. Required with `--ws-auth signed-bearer-token`.",
400400Key },
401401 {
402402[`codex logout`](https://developers.openai.com/codex/cli/reference#codex-logout) key: "--ws-issuer",
403403 type: "string",
404404Maturity description:
405405 "Expected `iss` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`.",
406406Stable },
407407 {
408408Details key: "--ws-audience",
409409 type: "string",
410410Remove stored authentication credentials. description:
411411 "Expected `aud` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`.",
412412Key },
413413 {
414414[`codex mcp`](https://developers.openai.com/codex/cli/reference#codex-mcp) key: "--ws-max-clock-skew-seconds",
415415 type: "number",
416416Maturity defaultValue: "30",
417417 description:
418418Experimental "Clock skew allowance when validating signed bearer token `exp` and `nbf` claims. Requires `--ws-auth signed-bearer-token`.",
419419 },
420420Details];
421421
422422Manage Model Context Protocol servers (list, add, remove, authenticate).export const appOptions = [
423423 {
424424Key key: "PATH",
425425 type: "path",
426426[`codex mcp-server`](https://developers.openai.com/codex/cli/reference#codex-mcp-server) defaultValue: ".",
427427 description:
428428Maturity "Workspace path for Codex Desktop. On macOS, Codex opens this path; on Windows, Codex prints the path.",
429429 },
430430Experimental {
431431 key: "--download-url",
432432Details type: "url",
433433 description:
434434Run Codex itself as an MCP server over stdio. Useful when another agent consumes Codex. "Advanced override for the Codex desktop installer URL used during install.",
435435 },
436436Key];
437437
438438[`codex resume`](https://developers.openai.com/codex/cli/reference#codex-resume)export const debugAppServerSendMessageV2Options = [
439439 {
440440Maturity key: "USER_MESSAGE",
441441 type: "string",
442442Stable description:
443443 "Message text sent to app-server through the built-in V2 test-client flow.",
444444Details },
445445 ];
446446Continue a previous interactive session by ID or resume the most recent conversation.
447447 export const debugModelsOptions = [
448448Key {
449449 key: "--bundled",
450450[`codex sandbox`](https://developers.openai.com/codex/cli/reference#codex-sandbox) type: "boolean",
451451 defaultValue: "false",
452452Maturity description:
453453 "Skip refresh and print only the model catalog bundled with the current Codex binary.",
454454Experimental },
455455 ];
456456Details
457457 export const resumeOptions = [
458458Run arbitrary commands inside Codex-provided macOS seatbelt or Linux sandboxes (Landlock by default, optional bubblewrap pipeline). {
459459 key: "SESSION_ID",
460460Expand to view all type: "uuid",
461461 description:
462462## Command details "Resume the specified session. Omit and use `--last` to continue the most recent session.",
463463 },
464464### `codex` (interactive) {
465465 key: "--last",
466466Running `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. type: "boolean",
467467 defaultValue: "false",
468468### `codex app-server` description:
469469 "Skip the picker and resume the most recent conversation from the current working directory.",
470470Launch the Codex app server locally. This is primarily for development and debugging and may change without notice. },
471471 {
472472| Key | Type / Values | Details | key: "--all",
473473| --- | --- | --- | type: "boolean",
474474| `--listen` | `stdio:// | ws://IP:PORT` | Transport listener URL. `ws://` is experimental and intended for development/testing. | defaultValue: "false",
475475 description:
476476Key "Include sessions outside the current working directory when selecting the most recent session.",
477477 },
478478`--listen`];
479479
480480Type / Valuesexport const featuresOptions = [
481481 {
482482`stdio:// | ws://IP:PORT` key: "List subcommand",
483483 type: "codex features list",
484484Details description:
485485 "Show known feature flags, their maturity stage, and their effective state.",
486486Transport listener URL. `ws://` is experimental and intended for development/testing. },
487487 {
488488`codex app-server --listen stdio://` keeps the default JSONL-over-stdio behavior. `--listen ws://IP:PORT` enables WebSocket transport (experimental). If you generate schemas for client bindings, add `--experimental` to include gated fields and methods. key: "Enable subcommand",
489489 type: "codex features enable <feature>",
490490### `codex app` description:
491491 "Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided.",
492492Launch Codex Desktop from the terminal on macOS and optionally open a specific workspace path. },
493493 {
494494| Key | Type / Values | Details | key: "Disable subcommand",
495495| --- | --- | --- | type: "codex features disable <feature>",
496496| `--download-url` | `url` | Advanced override for the Codex desktop DMG download URL used during install. | description:
497497| `PATH` | `path` | Workspace path to open in Codex Desktop (`codex app` is available on macOS only). | "Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided.",
498498 },
499499Key];
500500
501501`--download-url`export const execResumeOptions = [
502502 {
503503Type / Values key: "SESSION_ID",
504504 type: "uuid",
505505`url` description:
506506 "Resume the specified session. Omit and use `--last` to continue the most recent session.",
507507Details },
508508 {
509509Advanced override for the Codex desktop DMG download URL used during install. key: "--last",
510510 type: "boolean",
511511Key defaultValue: "false",
512512 description:
513513`PATH` "Resume the most recent conversation from the current working directory.",
514514 },
515515Type / Values {
516516 key: "--all",
517517`path` type: "boolean",
518518 defaultValue: "false",
519519Details description:
520520 "Include sessions outside the current working directory when selecting the most recent session.",
521521Workspace path to open in Codex Desktop (`codex app` is available on macOS only). },
522522 {
523523`codex app` installs/opens the desktop app on macOS, then opens the provided workspace path. This subcommand is macOS-only. key: "--image, -i",
524524 type: "path[,path...]",
525525### `codex debug app-server send-message-v2` description:
526526 "Attach one or more images to the follow-up prompt. Separate multiple paths with commas or repeat the flag.",
527527Send one message through app-server's V2 thread/turn flow using the built-in app-server test client. },
528528 {
529529| Key | Type / Values | Details | key: "PROMPT",
530530| --- | --- | --- | type: "string | - (read stdin)",
531531| `USER_MESSAGE` | `string` | Message text sent to app-server through the built-in V2 test-client flow. | description:
532532 "Optional follow-up instruction sent immediately after resuming.",
533533Key },
534534 ];
535535`USER_MESSAGE`
536536 export const forkOptions = [
537537Type / Values {
538538 key: "SESSION_ID",
539539`string` type: "uuid",
540540 description:
541541Details "Fork the specified session. Omit and use `--last` to fork the most recent session.",
542542 },
543543Message text sent to app-server through the built-in V2 test-client flow. {
544544 key: "--last",
545545This 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. type: "boolean",
546546 defaultValue: "false",
547547### `codex apply` description:
548548 "Skip the picker and fork the most recent conversation automatically.",
549549Apply the most recent diff from a Codex cloud task to your local repository. You must authenticate and have access to the task. },
550550 {
551551| Key | Type / Values | Details | key: "--all",
552552| --- | --- | --- | type: "boolean",
553553| `TASK_ID` | `string` | Identifier of the Codex Cloud task whose diff should be applied. | defaultValue: "false",
554554 description:
555555Key "Show sessions beyond the current working directory in the picker.",
556556 },
557557`TASK_ID`];
558558
559559Type / Valuesexport const execpolicyOptions = [
560560 {
561561`string` key: "--rules, -r",
562562 type: "path (repeatable)",
563563Details description:
564564 "Path to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across files.",
565565Identifier of the Codex Cloud task whose diff should be applied. },
566566 {
567567Codex prints the patched files and exits non-zero if `git apply` fails (for example, due to conflicts). key: "--pretty",
568568 type: "boolean",
569569### `codex cloud` defaultValue: "false",
570570 description: "Pretty-print the JSON result.",
571571Interact 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. },
572572 {
573573| Key | Type / Values | Details | key: "COMMAND...",
574574| --- | --- | --- | type: "var-args",
575575| `--attempts` | `1-4` | Number of assistant attempts (best-of-N) Codex Cloud should run. | description: "Command to be checked against the specified policies.",
576576| `--env` | `ENV_ID` | Target Codex Cloud environment identifier (required). Use `codex cloud` to list options. | },
577577| `QUERY` | `string` | Task prompt. If omitted, Codex prompts interactively for details. |];
578578
579579Keyexport const loginOptions = [
580580 {
581581`--attempts` key: "--with-api-key",
582582 type: "boolean",
583583Type / Values description:
584584 "Read an API key from stdin (for example `printenv OPENAI_API_KEY | codex login --with-api-key`).",
585585`1-4` },
586586 {
587587Details key: "--device-auth",
588588 type: "boolean",
589589Number of assistant attempts (best-of-N) Codex Cloud should run. description:
590590 "Use OAuth device code flow instead of launching a browser window.",
591591Key },
592592 {
593593`--env` key: "status subcommand",
594594 type: "codex login status",
595595Type / Values description:
596596 "Print the active authentication mode and exit with 0 when logged in.",
597597`ENV_ID` },
598598 ];
599599Details
600600 export const applyOptions = [
601601Target Codex Cloud environment identifier (required). Use `codex cloud` to list options. {
602602 key: "TASK_ID",
603603Key type: "string",
604604 description:
605605`QUERY` "Identifier of the Codex Cloud task whose diff should be applied.",
606606 },
607607Type / Values];
608608
609609`string`export const sandboxMacOptions = [
610610 {
611611Details key: "--permissions-profile",
612612 type: "NAME",
613613Task prompt. If omitted, Codex prompts interactively for details. description:
614614 "Apply a named permissions profile from the active configuration stack.",
615615Authentication follows the same credentials as the main CLI. Codex exits non-zero if the task submission fails. },
616616 {
617617#### `codex cloud list` key: "--cd, -C",
618618 type: "DIR",
619619List recent cloud tasks with optional filtering and pagination. description:
620620 "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
621621| Key | Type / Values | Details | },
622622| --- | --- | --- | {
623623| `--cursor` | `string` | Pagination cursor returned by a previous request. | key: "--include-managed-config",
624624| `--env` | `ENV_ID` | Filter tasks by environment identifier. | type: "boolean",
625625| `--json` | `boolean` | Emit machine-readable JSON instead of plain text. | defaultValue: "false",
626626| `--limit` | `1-20` | Maximum number of tasks to return. | description:
627627 "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
628628Key },
629629 {
630630`--cursor` key: "--allow-unix-socket",
631631 type: "path",
632632Type / Values description:
633633 "Allow the sandboxed command to bind or connect Unix sockets rooted at this path. Repeat to allow multiple paths.",
634634`string` },
635635 {
636636Details key: "--log-denials",
637637 type: "boolean",
638638Pagination cursor returned by a previous request. defaultValue: "false",
639639 description:
640640Key "Capture macOS sandbox denials with `log stream` while the command runs and print them after exit.",
641641 },
642642`--env` {
643643 key: "--config, -c",
644644Type / Values type: "key=value",
645645 description:
646646`ENV_ID` "Pass configuration overrides into the sandboxed run (repeatable).",
647647 },
648648Details {
649649 key: "COMMAND...",
650650Filter tasks by environment identifier. type: "var-args",
651651 description:
652652Key "Shell command to execute under macOS Seatbelt. Everything after `--` is forwarded.",
653653 },
654654`--json`];
655655
656656Type / Valuesexport const sandboxLinuxOptions = [
657657 {
658658`boolean` key: "--permissions-profile",
659659 type: "NAME",
660660Details description:
661661 "Apply a named permissions profile from the active configuration stack.",
662662Emit machine-readable JSON instead of plain text. },
663663 {
664664Key key: "--cd, -C",
665665 type: "DIR",
666666`--limit` description:
667667 "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
668668Type / Values },
669669 {
670670`1-20` key: "--include-managed-config",
671671 type: "boolean",
672672Details defaultValue: "false",
673673 description:
674674Maximum number of tasks to return. "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
675675 },
676676Plain-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`. {
677677 key: "--config, -c",
678678### `codex completion` type: "key=value",
679679 description:
680680Generate shell completion scripts and redirect the output to the appropriate location, for example `codex completion zsh > "${fpath[1]}/_codex"`. "Configuration overrides applied before launching the sandbox (repeatable).",
681681 },
682682| Key | Type / Values | Details | {
683683| --- | --- | --- | key: "COMMAND...",
684684| `SHELL` | `bash | zsh | fish | power-shell | elvish` | Shell to generate completions for. Output prints to stdout. | type: "var-args",
685685 description:
686686Key "Command to execute under Landlock + seccomp. Provide the executable after `--`.",
687687 },
688688`SHELL`];
689689
690690Type / Valuesexport const sandboxWindowsOptions = [
691691 {
692692`bash | zsh | fish | power-shell | elvish` key: "--permissions-profile",
693693 type: "NAME",
694694Details description:
695695 "Apply a named permissions profile from the active configuration stack.",
696696Shell to generate completions for. Output prints to stdout. },
697697 {
698698### `codex features` key: "--cd, -C",
699699 type: "DIR",
700700Manage 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:
701701 "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
702702| Key | Type / Values | Details | },
703703| --- | --- | --- | {
704704| `Disable subcommand` | `codex features disable <feature>` | Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided. | key: "--include-managed-config",
705705| `Enable subcommand` | `codex features enable <feature>` | Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided. | type: "boolean",
706706| `List subcommand` | `codex features list` | Show known feature flags, their maturity stage, and their effective state. | defaultValue: "false",
707707 description:
708708Key "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
709709 },
710710`Disable subcommand` {
711711 key: "--config, -c",
712712Type / Values type: "key=value",
713713 description:
714714`codex features disable <feature>` "Configuration overrides applied before launching the sandbox (repeatable).",
715715 },
716716Details {
717717 key: "COMMAND...",
718718Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided. type: "var-args",
719719 description:
720720Key "Command to execute under the native Windows sandbox. Provide the executable after `--`.",
721721 },
722722`Enable subcommand`];
723723
724724Type / Valuesexport const completionOptions = [
725725 {
726726`codex features enable <feature>` key: "SHELL",
727727 type: "bash | zsh | fish | power-shell | elvish",
728728Details defaultValue: "bash",
729729 description: "Shell to generate completions for. Output prints to stdout.",
730730Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided. },
731731 ];
732732Key
733733 export const cloudExecOptions = [
734734`List subcommand` {
735735 key: "QUERY",
736736Type / Values type: "string",
737737 description:
738738`codex features list` "Task prompt. If omitted, Codex prompts interactively for details.",
739739 },
740740Details {
741741 key: "--env",
742742Show known feature flags, their maturity stage, and their effective state. type: "ENV_ID",
743743 description:
744744### `codex exec` "Target Codex Cloud environment identifier (required). Use `codex cloud` to list options.",
745745 },
746746Use `codex exec` (or the short form `codex e`) for scripted or CI-style runs that should finish without human interaction. {
747747 key: "--attempts",
748748| Key | Type / Values | Details | type: "1-4",
749749| --- | --- | --- | defaultValue: "1",
750750| `--cd, -C` | `path` | Set the workspace root before executing the task. | description:
751751| `--color` | `always | never | auto` | Control ANSI color in stdout. | "Number of assistant attempts (best-of-N) Codex Cloud should run.",
752752| `--dangerously-bypass-approvals-and-sandbox, --yolo` | `boolean` | Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner. | },
753753| `--ephemeral` | `boolean` | Run without persisting session rollout files to disk. |];
754754| `--full-auto` | `boolean` | Apply the low-friction automation preset (`workspace-write` sandbox and `on-request` approvals). |
755755| `--image, -i` | `path[,path...]` | Attach images to the first message. Repeatable; supports comma-separated lists. |export const cloudListOptions = [
756756| `--json, --experimental-json` | `boolean` | Print newline-delimited JSON events instead of formatted text. | {
757757| `--model, -m` | `string` | Override the configured model for this run. | key: "--env",
758758| `--oss` | `boolean` | Use the local open source provider (requires a running Ollama instance). | type: "ENV_ID",
759759| `--output-last-message, -o` | `path` | Write the assistant’s final message to a file. Useful for downstream scripting. | description: "Filter tasks by environment identifier.",
760760| `--output-schema` | `path` | JSON Schema file describing the expected final response shape. Codex validates tool output against it. | },
761761| `--profile, -p` | `string` | Select a configuration profile defined in config.toml. | {
762762| `--sandbox, -s` | `read-only | workspace-write | danger-full-access` | Sandbox policy for model-generated commands. Defaults to configuration. | key: "--limit",
763763| `--skip-git-repo-check` | `boolean` | Allow running outside a Git repository (useful for one-off directories). | type: "1-20",
764764| `-c, --config` | `key=value` | Inline configuration override for the non-interactive run (repeatable). | defaultValue: "20",
765765| `PROMPT` | `string | - (read stdin)` | Initial instruction for the task. Use `-` to pipe the prompt from stdin. | description: "Maximum number of tasks to return.",
766766| `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. | },
767767 {
768768Key key: "--cursor",
769769 type: "string",
770770`--cd, -C` description: "Pagination cursor returned by a previous request.",
771771 },
772772Type / Values {
773773 key: "--json",
774774`path` type: "boolean",
775775 defaultValue: "false",
776776Details description: "Emit machine-readable JSON instead of plain text.",
777777 },
778778Set the workspace root before executing the task.];
779779
780780Keyexport const mcpCommands = [
781781 {
782782`--color` key: "list",
783783 type: "--json",
784784Type / Values description:
785785 "List configured MCP servers. Add `--json` for machine-readable output.",
786786`always | never | auto` },
787787 {
788788Details key: "get <name>",
789789 type: "--json",
790790Control ANSI color in stdout. description:
791791 "Show a specific server configuration. `--json` prints the raw config entry.",
792792Key },
793793 {
794794`--dangerously-bypass-approvals-and-sandbox, --yolo` 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`boolean` },
799799 {
800800Details key: "remove <name>",
801801 description: "Delete a stored MCP server definition.",
802802Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner. },
803803 {
804804Key key: "login <name>",
805805 type: "--scopes scope1,scope2",
806806`--ephemeral` description:
807807 "Start an OAuth login for a streamable HTTP server (servers that support OAuth only).",
808808Type / Values },
809 {
810 key: "logout <name>",
811 description:
812 "Remove stored OAuth credentials for a streamable HTTP server.",
813 },
814];
815
816export const mcpAddOptions = [
817 {
818 key: "COMMAND...",
819 type: "stdio transport",
820 description:
821 "Executable plus arguments to launch the MCP server. Provide after `--`.",
822 },
823 {
824 key: "--env KEY=VALUE",
825 type: "repeatable",
826 description:
827 "Environment variable assignments applied when launching a stdio server.",
828 },
829 {
830 key: "--url",
831 type: "https://…",
832 description:
833 "Register a streamable HTTP server instead of stdio. Mutually exclusive with `COMMAND...`.",
834 },
835 {
836 key: "--bearer-token-env-var",
837 type: "ENV_VAR",
838 description:
839 "Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server.",
840 },
841];
842
843export const marketplaceCommands = [
844 {
845 key: "add <source>",
846 type: "[--ref REF] [--sparse PATH]",
847 description:
848 "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.",
849 },
850 {
851 key: "upgrade [marketplace-name]",
852 description:
853 "Refresh one configured Git marketplace, or all configured Git marketplaces when no name is provided.",
854 },
855 {
856 key: "remove <marketplace-name>",
857 description: "Remove a configured plugin marketplace.",
858 },
859];
809 860
810861`boolean`## How to read this reference
811
812Details
813
814Run without persisting session rollout files to disk.
815
816Key
817
818`--full-auto`
819
820Type / Values
821
822`boolean`
823
824Details
825
826Apply the low-friction automation preset (`workspace-write` sandbox and `on-request` approvals).
827
828Key
829
830`--image, -i`
831
832Type / Values
833
834`path[,path...]`
835
836Details
837
838Attach images to the first message. Repeatable; supports comma-separated lists.
839
840Key
841
842`--json, --experimental-json`
843
844Type / Values
845
846`boolean`
847
848Details
849
850Print newline-delimited JSON events instead of formatted text.
851
852Key
853
854`--model, -m`
855
856Type / Values
857
858`string`
859
860Details
861
862Override the configured model for this run.
863
864Key
865
866`--oss`
867
868Type / Values
869
870`boolean`
871
872Details
873
874Use the local open source provider (requires a running Ollama instance).
875 862
876863KeyThis 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.
877 864
878865`--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.
879 869
880870Type / Values## Global flags
881 871
882872`path`<ConfigTable client:load options={globalFlagOptions} />
883 873
884874DetailsThese 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.
885 876
886877Write the assistant’s final message to a file. Useful for downstream scripting.## Command overview
887 878
888879KeyThe 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.
889 882
890883`--output-schema`<ConfigTable
884 client:load
885 options={commandOverview}
886 secondColumnTitle="Maturity"
887 secondColumnVariant="maturity"
888/>
891 889
892890Type / Values## Command details
893 891
894892`path`### `codex` (interactive)
895 893
896894DetailsRunning `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`.
897 895
898896JSON 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.
899 897
900898Key### `codex app-server`
901 899
902900`--profile, -p`Launch the Codex app server locally. This is primarily for development and debugging and may change without notice.
903 901
904902Type / Values<ConfigTable client:load options={appServerOptions} />
905 903
906904`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.
907 905
908906Details### `codex app`
909 907
910908Select 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.
911 909
912910Key<ConfigTable client:load options={appOptions} />
913 911
914912`--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.
915 915
916916Type / Values### `codex debug app-server send-message-v2`
917 917
918918`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.
919 919
920920Details<ConfigTable client:load options={debugAppServerSendMessageV2Options} />
921 921
922922Sandbox 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.
923 923
924924Key### `codex debug models`
925 925
926926`--skip-git-repo-check`Print the raw model catalog Codex sees as JSON.
927 927
928928Type / Values<ConfigTable client:load options={debugModelsOptions} />
929 929
930930`boolean`Use `--bundled` when you want to inspect only the catalog bundled with the current binary, without refreshing from the remote models endpoint.
931 931
932932Details### `codex apply`
933 933
934934Allow 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.
935 935
936936Key<ConfigTable client:load options={applyOptions} />
937 937
938938`-c, --config`Codex prints the patched files and exits non-zero if `git apply` fails (for example, due to conflicts).
939 939
940940Type / Values### `codex cloud`
941 941
942942`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.
943 943
944944Details<ConfigTable client:load options={cloudExecOptions} />
945 945
946946Inline 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.
947 947
948948Key#### `codex cloud list`
949 949
950950`PROMPT`List recent cloud tasks with optional filtering and pagination.
951 951
952952Type / Values<ConfigTable client:load options={cloudListOptions} />
953 953
954954`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`.
955 955
956956Details### `codex completion`
957 957
958958Initial 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"`.
959 959
960960Key<ConfigTable client:load options={completionOptions} />
961 961
962962`Resume subcommand`### `codex features`
963 963
964964Type / 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.
965 965
966966`codex exec resume [SESSION_ID]`<ConfigTable client:load options={featuresOptions} />
967 967
968968Details### `codex exec`
969 969
970970Resume 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.
971 971
972972Expand to view all<ConfigTable client:load options={execOptions} />
973 973
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: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:
975 975
976976| Key | Type / Values | Details |<ConfigTable client:load options={execResumeOptions} />
977| --- | --- | --- |
978| `--all` | `boolean` | Include sessions outside the current working directory when selecting the most recent session. |
979| `--image, -i` | `path[,path...]` | Attach one or more images to the follow-up prompt. Separate multiple paths with commas or repeat the flag. |
980| `--last` | `boolean` | Resume the most recent conversation from the current working directory. |
981| `PROMPT` | `string | - (read stdin)` | Optional follow-up instruction sent immediately after resuming. |
982| `SESSION_ID` | `uuid` | Resume the specified session. Omit and use `--last` to continue the most recent session. |
983
984Key
985
986`--all`
987
988Type / Values
989
990`boolean`
991
992Details
993
994Include sessions outside the current working directory when selecting the most recent session.
995
996Key
997
998`--image, -i`
999
1000Type / Values
1001
1002`path[,path...]`
1003
1004Details
1005
1006Attach one or more images to the follow-up prompt. Separate multiple paths with commas or repeat the flag.
1007
1008Key
1009
1010`--last`
1011
1012Type / Values
1013
1014`boolean`
1015
1016Details
1017
1018Resume the most recent conversation from the current working directory.
1019
1020Key
1021
1022`PROMPT`
1023
1024Type / Values
1025
1026`string | - (read stdin)`
1027
1028Details
1029
1030Optional follow-up instruction sent immediately after resuming.
1031
1032Key
1033
1034`SESSION_ID`
1035
1036Type / Values
1037
1038`uuid`
1039
1040Details
1041
1042Resume the specified session. Omit and use `--last` to continue the most recent session.
1043 977
1044### `codex execpolicy`978### `codex execpolicy`
1045 979
1046Check `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.
1047 981
1048982| Key | Type / Values | Details |<ConfigTable client:load options={execpolicyOptions} />
1049| --- | --- | --- |
1050| `--pretty` | `boolean` | Pretty-print the JSON result. |
1051| `--rules, -r` | `path (repeatable)` | Path to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across files. |
1052| `COMMAND...` | `var-args` | Command to be checked against the specified policies. |
1053
1054Key
1055
1056`--pretty`
1057
1058Type / Values
1059
1060`boolean`
1061
1062Details
1063
1064Pretty-print the JSON result.
1065
1066Key
1067
1068`--rules, -r`
1069
1070Type / Values
1071
1072`path (repeatable)`
1073
1074Details
1075
1076Path to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across files.
1077
1078Key
1079
1080`COMMAND...`
1081
1082Type / Values
1083
1084`var-args`
1085
1086Details
1087
1088Command to be checked against the specified policies.
1089 983
1090### `codex login`984### `codex login`
1091 985
1092Authenticate 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.
1093 987
1094988| Key | Type / Values | Details |<ConfigTable client:load options={loginOptions} />
1095| --- | --- | --- |
1096| `--device-auth` | `boolean` | Use OAuth device code flow instead of launching a browser window. |
1097| `--with-api-key` | `boolean` | Read an API key from stdin (for example `printenv OPENAI_API_KEY | codex login --with-api-key`). |
1098| `status subcommand` | `codex login status` | Print the active authentication mode and exit with 0 when logged in. |
1099
1100Key
1101
1102`--device-auth`
1103
1104Type / Values
1105
1106`boolean`
1107
1108Details
1109
1110Use OAuth device code flow instead of launching a browser window.
1111
1112Key
1113
1114`--with-api-key`
1115
1116Type / Values
1117
1118`boolean`
1119
1120Details
1121
1122Read an API key from stdin (for example `printenv OPENAI_API_KEY | codex login --with-api-key`).
1123
1124Key
1125
1126`status subcommand`
1127
1128Type / Values
1129
1130`codex login status`
1131
1132Details
1133
1134Print the active authentication mode and exit with 0 when logged in.
1135 989
1136`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.
1137 991
1143 997
1144Manage Model Context Protocol server entries stored in `~/.codex/config.toml`.998Manage Model Context Protocol server entries stored in `~/.codex/config.toml`.
1145 999
11461000| Key | Type / Values | Details |<ConfigTable client:load options={mcpCommands} />
1147| --- | --- | --- |
1148| `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. |
1149| `get <name>` | `--json` | Show a specific server configuration. `--json` prints the raw config entry. |
1150| `list` | `--json` | List configured MCP servers. Add `--json` for machine-readable output. |
1151| `login <name>` | `--scopes scope1,scope2` | Start an OAuth login for a streamable HTTP server (servers that support OAuth only). |
1152| `logout <name>` | | Remove stored OAuth credentials for a streamable HTTP server. |
1153| `remove <name>` | | Delete a stored MCP server definition. |
1154
1155Key
1156
1157`add <name>`
1158
1159Type / Values
1160
1161`-- <command...> | --url <value>`
1162
1163Details
1164
1165Register a server using a stdio launcher command or a streamable HTTP URL. Supports `--env KEY=VALUE` for stdio transports.
1166
1167Key
1168
1169`get <name>`
1170
1171Type / Values
1172
1173`--json`
1174
1175Details
1176
1177Show a specific server configuration. `--json` prints the raw config entry.
1178
1179Key
1180
1181`list`
1182
1183Type / Values
1184
1185`--json`
1186
1187Details
1188
1189List configured MCP servers. Add `--json` for machine-readable output.
1190
1191Key
1192
1193`login <name>`
1194
1195Type / Values
1196
1197`--scopes scope1,scope2`
1198
1199Details
1200
1201Start an OAuth login for a streamable HTTP server (servers that support OAuth only).
1202
1203Key
1204
1205`logout <name>`
1206
1207Details
1208
1209Remove stored OAuth credentials for a streamable HTTP server.
1210
1211Key
1212
1213`remove <name>`
1214
1215Details
1216
1217Delete a stored MCP server definition.
1218 1001
1219The `add` subcommand supports both stdio and streamable HTTP transports:1002The `add` subcommand supports both stdio and streamable HTTP transports:
1220 1003
12211004| Key | Type / Values | Details |<ConfigTable client:load options={mcpAddOptions} />
1222| --- | --- | --- |
1223| `--bearer-token-env-var` | `ENV_VAR` | Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server. |
1224| `--env KEY=VALUE` | `repeatable` | Environment variable assignments applied when launching a stdio server. |
1225| `--url` | `https://…` | Register a streamable HTTP server instead of stdio. Mutually exclusive with `COMMAND...`. |
1226| `COMMAND...` | `stdio transport` | Executable plus arguments to launch the MCP server. Provide after `--`. |
1227
1228Key
1229
1230`--bearer-token-env-var`
1231
1232Type / Values
1233
1234`ENV_VAR`
1235
1236Details
1237
1238Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server.
1239
1240Key
1241
1242`--env KEY=VALUE`
1243
1244Type / Values
1245
1246`repeatable`
1247 1005
12481006DetailsOAuth actions (`login`, `logout`) only work with streamable HTTP servers (and only when the server supports OAuth).
1249
1250Environment variable assignments applied when launching a stdio server.
1251
1252Key
1253
1254`--url`
1255
1256Type / Values
1257
1258`https://…`
1259
1260Details
1261
1262Register a streamable HTTP server instead of stdio. Mutually exclusive with `COMMAND...`.
1263
1264Key
1265
1266`COMMAND...`
1267
1268Type / Values
1269 1007
12701008`stdio transport`### `codex plugin marketplace`
1271 1009
12721010DetailsManage plugin marketplace sources that Codex can browse and install from.
1273 1011
12741012Executable plus arguments to launch the MCP server. Provide after `--`.<ConfigTable client:load options={marketplaceCommands} />
1275 1013
12761014OAuth 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.
1277 1018
1278### `codex mcp-server`1019### `codex mcp-server`
1279 1020
1283 1024
1284Continue 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.
1285 1026
12861027| Key | Type / Values | Details |<ConfigTable client:load options={resumeOptions} />
1287| --- | --- | --- |
1288| `--all` | `boolean` | Include sessions outside the current working directory when selecting the most recent session. |
1289| `--last` | `boolean` | Skip the picker and resume the most recent conversation from the current working directory. |
1290| `SESSION_ID` | `uuid` | Resume the specified session. Omit and use `--last` to continue the most recent session. |
1291
1292Key
1293
1294`--all`
1295
1296Type / Values
1297
1298`boolean`
1299
1300Details
1301
1302Include sessions outside the current working directory when selecting the most recent session.
1303
1304Key
1305
1306`--last`
1307
1308Type / Values
1309
1310`boolean`
1311
1312Details
1313
1314Skip the picker and resume the most recent conversation from the current working directory.
1315
1316Key
1317
1318`SESSION_ID`
1319
1320Type / Values
1321
1322`uuid`
1323
1324Details
1325
1326Resume the specified session. Omit and use `--last` to continue the most recent session.
1327 1028
1328### `codex fork`1029### `codex fork`
1329 1030
1330Fork 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.
1331 1032
13321033| Key | Type / Values | Details |<ConfigTable client:load options={forkOptions} />
1333| --- | --- | --- |
1334| `--all` | `boolean` | Show sessions beyond the current working directory in the picker. |
1335| `--last` | `boolean` | Skip the picker and fork the most recent conversation automatically. |
1336| `SESSION_ID` | `uuid` | Fork the specified session. Omit and use `--last` to fork the most recent session. |
1337
1338Key
1339
1340`--all`
1341
1342Type / Values
1343
1344`boolean`
1345
1346Details
1347
1348Show sessions beyond the current working directory in the picker.
1349
1350Key
1351
1352`--last`
1353
1354Type / Values
1355
1356`boolean`
1357
1358Details
1359
1360Skip the picker and fork the most recent conversation automatically.
1361
1362Key
1363
1364`SESSION_ID`
1365
1366Type / Values
1367
1368`uuid`
1369
1370Details
1371
1372Fork the specified session. Omit and use `--last` to fork the most recent session.
1373 1034
1374### `codex sandbox`1035### `codex sandbox`
1375 1036
1377 1038
1378#### macOS seatbelt1039#### macOS seatbelt
1379 1040
13801041| Key | Type / Values | Details |<ConfigTable client:load options={sandboxMacOptions} />
1381| --- | --- | --- |
1382| `--config, -c` | `key=value` | Pass configuration overrides into the sandboxed run (repeatable). |
1383| `--full-auto` | `boolean` | Grant write access to the current workspace and `/tmp` without approvals. |
1384| `COMMAND...` | `var-args` | Shell command to execute under macOS Seatbelt. Everything after `--` is forwarded. |
1385
1386Key
1387
1388`--config, -c`
1389
1390Type / Values
1391
1392`key=value`
1393
1394Details
1395
1396Pass configuration overrides into the sandboxed run (repeatable).
1397
1398Key
1399
1400`--full-auto`
1401
1402Type / Values
1403
1404`boolean`
1405
1406Details
1407
1408Grant write access to the current workspace and `/tmp` without approvals.
1409
1410Key
1411
1412`COMMAND...`
1413
1414Type / Values
1415
1416`var-args`
1417
1418Details
1419
1420Shell command to execute under macOS Seatbelt. Everything after `--` is forwarded.
1421 1042
1422#### Linux Landlock1043#### Linux Landlock
1423 1044
14241045| Key | Type / Values | Details |<ConfigTable client:load options={sandboxLinuxOptions} />
1425| --- | --- | --- |
1426| `--config, -c` | `key=value` | Configuration overrides applied before launching the sandbox (repeatable). |
1427| `--full-auto` | `boolean` | Grant write access to the current workspace and `/tmp` inside the Landlock sandbox. |
1428| `COMMAND...` | `var-args` | Command to execute under Landlock + seccomp. Provide the executable after `--`. |
1429
1430Key
1431
1432`--config, -c`
1433
1434Type / Values
1435
1436`key=value`
1437
1438Details
1439
1440Configuration overrides applied before launching the sandbox (repeatable).
1441
1442Key
1443
1444`--full-auto`
1445
1446Type / Values
1447
1448`boolean`
1449
1450Details
1451
1452Grant write access to the current workspace and `/tmp` inside the Landlock sandbox.
1453
1454Key
1455
1456`COMMAND...`
1457 1046
14581047Type / Values#### Windows
1459 1048
14601049`var-args`<ConfigTable client:load options={sandboxWindowsOptions} />
1461 1050
14621051Details### `codex update`
1463 1052
14641053Command 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.
1465 1054
1466## Flag combinations and safety tips1055## Flag combinations and safety tips
1467 1056
14681057- 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.
1469- 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`.
1470- 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.
1471 1060