cli/reference.md +968 −1458
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 over stdio, WebSocket, or a Unix socket.",
126126 },
127127Details {
128128 key: "codex remote-control",
129129Shortcut for low-friction local work: sets `--ask-for-approval on-request` and `--sandbox workspace-write`. href: "/codex/cli/reference#codex-remote-control",
130130 type: "experimental",
131131Key description:
132132 "Ensure the local app-server daemon is running with remote-control support enabled.",
133133`--image, -i` },
134134 {
135135Type / Values key: "codex app",
136136 href: "/codex/cli/reference#codex-app",
137137`path[,path...]` type: "stable",
138138 description:
139139Details "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.",
140140 },
141141Attach one or more image files to the initial prompt. Separate multiple paths with commas or repeat the flag. {
142142 key: "codex debug app-server send-message-v2",
143143Key href: "/codex/cli/reference#codex-debug-app-server-send-message-v2",
144144 type: "experimental",
145145`--model, -m` description:
146146 "Debug app-server by sending a single V2 message through the built-in test client.",
147147Type / Values },
148148 {
149149`string` key: "codex debug models",
150150 href: "/codex/cli/reference#codex-debug-models",
151151Details type: "experimental",
152152 description:
153153Override the model set in configuration (for example `gpt-5.4`). "Print the raw model catalog Codex sees, including an option to inspect only the bundled catalog.",
154154 },
155155Key {
156156 key: "codex apply",
157157`--no-alt-screen` href: "/codex/cli/reference#codex-apply",
158158 type: "stable",
159159Type / Values description:
160160 "Apply the latest diff generated by a Codex Cloud task to your local working tree. Alias: `codex a`.",
161161`boolean` },
162162 {
163163Details key: "codex cloud",
164164 href: "/codex/cli/reference#codex-cloud",
165165Disable alternate screen mode for the TUI (overrides `tui.alternate_screen` for this run). type: "experimental",
166166 description:
167167Key "Browse or execute Codex Cloud tasks from the terminal without opening the TUI. Alias: `codex cloud-tasks`.",
168168 },
169169`--oss` {
170170 key: "codex completion",
171171Type / Values href: "/codex/cli/reference#codex-completion",
172172 type: "stable",
173173`boolean` description:
174174 "Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell.",
175175Details },
176176 {
177177Use the local open source model provider (equivalent to `-c model_provider="oss"`). Validates that Ollama is running. key: "codex features",
178178 href: "/codex/cli/reference#codex-features",
179179Key type: "stable",
180180 description:
181181`--profile, -p` "List feature flags and persistently enable or disable them in `config.toml`.",
182182 },
183183Type / Values {
184184 key: "codex exec",
185185`string` href: "/codex/cli/reference#codex-exec",
186186 type: "stable",
187187Details description:
188188 "Run Codex non-interactively. Alias: `codex e`. Stream results to stdout or JSONL and optionally resume previous sessions.",
189189Configuration profile name to load from `~/.codex/config.toml`. },
190190 {
191191Key key: "codex execpolicy",
192192 href: "/codex/cli/reference#codex-execpolicy",
193193`--remote` type: "experimental",
194194 description:
195195Type / Values "Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked.",
196196 },
197197`ws://host:port | wss://host:port` {
198198 key: "codex login",
199199Details href: "/codex/cli/reference#codex-login",
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:
202202 "Authenticate Codex using ChatGPT OAuth, device auth, an API key, or an access token piped over stdin.",
203203Key },
204204 {
205205`--remote-auth-token-env` key: "codex logout",
206206 href: "/codex/cli/reference#codex-logout",
207207Type / Values type: "stable",
208208 description: "Remove stored authentication credentials.",
209209`ENV_VAR` },
210210 {
211211Details key: "codex mcp",
212212 href: "/codex/cli/reference#codex-mcp",
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 "Manage Model Context Protocol servers (list, add, remove, authenticate).",
216216 },
217217`--sandbox, -s` {
218218 key: "codex plugin marketplace",
219219Type / Values href: "/codex/cli/reference#codex-plugin-marketplace",
220220 type: "experimental",
221221`read-only | workspace-write | danger-full-access` description:
222222 "Add, upgrade, or remove plugin marketplaces from Git or local sources.",
223223Details },
224224 {
225225Select the sandbox policy for model-generated shell commands. key: "codex mcp-server",
226226 href: "/codex/cli/reference#codex-mcp-server",
227227Key type: "experimental",
228228 description:
229229`--search` "Run Codex itself as an MCP server over stdio. Useful when another agent consumes Codex.",
230230 },
231231Type / Values {
232232 key: "codex resume",
233233`boolean` href: "/codex/cli/reference#codex-resume",
234234 type: "stable",
235235Details description:
236236 "Continue a previous interactive session by ID or resume the most recent conversation.",
237237Enable live web search (sets `web_search = "live"` instead of the default `"cached"`). },
238238 {
239239Key key: "codex fork",
240240 href: "/codex/cli/reference#codex-fork",
241241`PROMPT` type: "stable",
242242 description:
243243Type / Values "Fork a previous interactive session into a new thread, preserving the original transcript.",
244244 },
245245`string` {
246246 key: "codex sandbox",
247247Details href: "/codex/cli/reference#codex-sandbox",
248248 type: "experimental",
249249Optional text instruction to start the session. Omit to launch the TUI without a pre-filled message. description:
250250 "Run arbitrary commands inside Codex-provided macOS, Linux, or Windows sandboxes.",
251251Expand to view all },
252252 {
253253These options apply to the base `codex` command and propagate to each subcommand unless a section below specifies otherwise. key: "codex update",
254254When you run a subcommand, place global flags after it (for example, `codex exec --oss ...`) so Codex applies them as intended. href: "/codex/cli/reference#codex-update",
255255 type: "stable",
256256## Command overview description:
257257 "Check for and apply a Codex CLI update when the installed release supports self-update.",
258258The Maturity column uses feature maturity labels such as Experimental, Beta, },
259259 and Stable. See [Feature Maturity](https://developers.openai.com/codex/feature-maturity) for how to];
260260 interpret these labels.
261261 export const execOptions = [
262262| Key | Maturity | Details | {
263263| --- | --- | --- | key: "PROMPT",
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. | type: "string | - (read stdin)",
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. | description:
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. | "Initial instruction for the task. Use `-` to pipe the prompt from stdin.",
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`. | {
269269| [`codex completion`](https://developers.openai.com/codex/cli/reference#codex-completion) | Stable | Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell. | key: "--image, -i",
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. | type: "path[,path...]",
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. | description:
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. | "Attach images to the first message. Repeatable; supports comma-separated lists.",
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`. | },
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. | {
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. | key: "--model, -m",
276276| [`codex logout`](https://developers.openai.com/codex/cli/reference#codex-logout) | Stable | Remove stored authentication credentials. | type: "string",
277277| [`codex mcp`](https://developers.openai.com/codex/cli/reference#codex-mcp) | Experimental | Manage Model Context Protocol servers (list, add, remove, authenticate). | description: "Override the configured model for this run.",
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: "--oss",
281281 type: "boolean",
282282Key defaultValue: "false",
283283 description:
284284[`codex`](https://developers.openai.com/codex/cli/reference#codex-interactive) "Use the local open source provider (requires a running Ollama instance).",
285285 },
286286Maturity {
287287 key: "--sandbox, -s",
288288Stable type: "read-only | workspace-write | danger-full-access",
289289 description:
290290Details "Sandbox policy for model-generated commands. Defaults to configuration.",
291291 },
292292Launch the terminal UI. Accepts the global flags above plus an optional prompt or image attachments. {
293293 key: "--profile, -p",
294294Key type: "string",
295295 description: "Select a configuration profile defined in config.toml.",
296296[`codex app`](https://developers.openai.com/codex/cli/reference#codex-app) },
297297 {
298298Maturity key: "--full-auto",
299299 type: "boolean",
300300Stable defaultValue: "false",
301301 description:
302302Details "Deprecated compatibility flag. Prefer `--sandbox workspace-write`; Codex prints a warning when this flag is used.",
303303 },
304304Launch the Codex desktop app on macOS, optionally opening a specific workspace path. {
305305 key: "--dangerously-bypass-approvals-and-sandbox, --yolo",
306306Key type: "boolean",
307307 defaultValue: "false",
308308[`codex app-server`](https://developers.openai.com/codex/cli/reference#codex-app-server) description:
309309 "Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner.",
310310Maturity },
311311 {
312312Experimental key: "--cd, -C",
313313 type: "path",
314314Details description: "Set the workspace root before executing the task.",
315315 },
316316Launch the Codex app server for local development or debugging. {
317317 key: "--skip-git-repo-check",
318318Key type: "boolean",
319319 defaultValue: "false",
320320[`codex apply`](https://developers.openai.com/codex/cli/reference#codex-apply) description:
321321 "Allow running outside a Git repository (useful for one-off directories).",
322322Maturity },
323323 {
324324Stable key: "--ephemeral",
325325 type: "boolean",
326326Details defaultValue: "false",
327327 description: "Run without persisting session rollout files to disk.",
328328Apply the latest diff generated by a Codex Cloud task to your local working tree. Alias: `codex a`. },
329329 {
330330Key key: "--ignore-user-config",
331331 type: "boolean",
332332[`codex cloud`](https://developers.openai.com/codex/cli/reference#codex-cloud) defaultValue: "false",
333333 description:
334334Maturity "Do not load `$CODEX_HOME/config.toml`. Authentication still uses `CODEX_HOME`.",
335335 },
336336Experimental {
337337 key: "--ignore-rules",
338338Details type: "boolean",
339339 defaultValue: "false",
340340Browse or execute Codex Cloud tasks from the terminal without opening the TUI. Alias: `codex cloud-tasks`. description:
341341 "Do not load user or project execpolicy `.rules` files for this run.",
342342Key },
343343 {
344344[`codex completion`](https://developers.openai.com/codex/cli/reference#codex-completion) key: "--output-schema",
345345 type: "path",
346346Maturity description:
347347 "JSON Schema file describing the expected final response shape. Codex validates tool output against it.",
348348Stable },
349349 {
350350Details key: "--color",
351351 type: "always | never | auto",
352352Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell. defaultValue: "auto",
353353 description: "Control ANSI color in stdout.",
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: "--json, --experimental-json",
357357 type: "boolean",
358358Maturity defaultValue: "false",
359359 description:
360360Experimental "Print newline-delimited JSON events instead of formatted text.",
361361 },
362362Details {
363363 key: "--output-last-message, -o",
364364Debug app-server by sending a single V2 message through the built-in test client. type: "path",
365365 description:
366366Key "Write the assistant’s final message to a file. Useful for downstream scripting.",
367367 },
368368[`codex exec`](https://developers.openai.com/codex/cli/reference#codex-exec) {
369369 key: "Resume subcommand",
370370Maturity type: "codex exec resume [SESSION_ID]",
371371 description:
372372Stable "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.",
373373 },
374374Details {
375375 key: "-c, --config",
376376Run Codex non-interactively. Alias: `codex e`. Stream results to stdout or JSONL and optionally resume previous sessions. type: "key=value",
377377 description:
378378Key "Inline configuration override for the non-interactive run (repeatable).",
379379 },
380380[`codex execpolicy`](https://developers.openai.com/codex/cli/reference#codex-execpolicy)];
381381
382382Maturityexport const appServerOptions = [
383383 {
384384Experimental key: "--listen",
385385 type: "stdio:// | ws://IP:PORT | unix:// | unix://PATH | off",
386386Details defaultValue: "stdio://",
387387 description:
388388Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked. "Transport listener URL. Use `stdio://` for JSONL, `ws://IP:PORT` for a TCP WebSocket endpoint, `unix://` for the default Unix socket, `unix://PATH` for a custom Unix socket, or `off` to disable the local transport.",
389389 },
390390Key {
391391 key: "--ws-auth",
392392[`codex features`](https://developers.openai.com/codex/cli/reference#codex-features) type: "capability-token | signed-bearer-token",
393393 description:
394394Maturity "Authentication mode for app-server WebSocket clients. If omitted, WebSocket auth is disabled; non-local listeners warn during startup.",
395395 },
396396Stable {
397397 key: "--ws-token-file",
398398Details type: "absolute path",
399399 description:
400400List feature flags and persistently enable or disable them in `config.toml`. "File containing the shared capability token. Required with `--ws-auth capability-token`.",
401401 },
402402Key {
403403 key: "--ws-shared-secret-file",
404404[`codex fork`](https://developers.openai.com/codex/cli/reference#codex-fork) type: "absolute path",
405405 description:
406406Maturity "File containing the HMAC shared secret used to validate signed JWT bearer tokens. Required with `--ws-auth signed-bearer-token`.",
407407 },
408408Stable {
409409 key: "--ws-issuer",
410410Details type: "string",
411411 description:
412412Fork a previous interactive session into a new thread, preserving the original transcript. "Expected `iss` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`.",
413413 },
414414Key {
415415 key: "--ws-audience",
416416[`codex login`](https://developers.openai.com/codex/cli/reference#codex-login) type: "string",
417417 description:
418418Maturity "Expected `aud` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`.",
419419 },
420420Stable {
421421 key: "--ws-max-clock-skew-seconds",
422422Details type: "number",
423423 defaultValue: "30",
424424Authenticate Codex using ChatGPT OAuth, device auth, or an API key piped over stdin. description:
425425 "Clock skew allowance when validating signed bearer token `exp` and `nbf` claims. Requires `--ws-auth signed-bearer-token`.",
426426Key },
427427 {
428428[`codex logout`](https://developers.openai.com/codex/cli/reference#codex-logout) key: "--analytics-default-enabled",
429429 type: "boolean",
430430Maturity defaultValue: "false",
431431 description:
432432Stable "Defaults analytics to enabled for first-party app-server clients unless the user opts out in config.",
433433 },
434434Details];
435435
436436Remove stored authentication credentials.export const appOptions = [
437437 {
438438Key key: "PATH",
439439 type: "path",
440440[`codex mcp`](https://developers.openai.com/codex/cli/reference#codex-mcp) defaultValue: ".",
441441 description:
442442Maturity "Workspace path for Codex Desktop. On macOS, Codex opens this path; on Windows, Codex prints the path.",
443443 },
444444Experimental {
445445 key: "--download-url",
446446Details type: "url",
447447 description:
448448Manage Model Context Protocol servers (list, add, remove, authenticate). "Advanced override for the Codex desktop installer URL used during install.",
449449 },
450450Key];
451451
452452[`codex mcp-server`](https://developers.openai.com/codex/cli/reference#codex-mcp-server)export const debugAppServerSendMessageV2Options = [
453453 {
454454Maturity key: "USER_MESSAGE",
455455 type: "string",
456456Experimental description:
457457 "Message text sent to app-server through the built-in V2 test-client flow.",
458458Details },
459459 ];
460460Run Codex itself as an MCP server over stdio. Useful when another agent consumes Codex.
461461 export const debugModelsOptions = [
462462Key {
463463 key: "--bundled",
464464[`codex resume`](https://developers.openai.com/codex/cli/reference#codex-resume) type: "boolean",
465465 defaultValue: "false",
466466Maturity description:
467467 "Skip refresh and print only the model catalog bundled with the current Codex binary.",
468468Stable },
469469 ];
470470Details
471471 export const resumeOptions = [
472472Continue a previous interactive session by ID or resume the most recent conversation. {
473473 key: "SESSION_ID",
474474Key type: "uuid",
475475 description:
476476[`codex sandbox`](https://developers.openai.com/codex/cli/reference#codex-sandbox) "Resume the specified session. Omit and use `--last` to continue the most recent session.",
477477 },
478478Maturity {
479479 key: "--last",
480480Experimental type: "boolean",
481481 defaultValue: "false",
482482Details description:
483483 "Skip the picker and resume the most recent conversation from the current working directory.",
484484Run arbitrary commands inside Codex-provided macOS seatbelt or Linux bubblewrap sandboxes. },
485485 {
486486Expand to view all key: "--all",
487487 type: "boolean",
488488## Command details defaultValue: "false",
489489 description:
490490### `codex` (interactive) "Include sessions outside the current working directory when selecting the most recent session.",
491491 },
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.export const featuresOptions = [
495495 {
496496### `codex app-server` key: "List subcommand",
497497 type: "codex features list",
498498Launch the Codex app server locally. This is primarily for development and debugging and may change without notice. description:
499499 "Show known feature flags, their maturity stage, and their effective state.",
500500| Key | Type / Values | Details | },
501501| --- | --- | --- | {
502502| `--listen` | `stdio:// | ws://IP:PORT` | Transport listener URL. Use `ws://IP:PORT` to expose a WebSocket endpoint for remote clients. | key: "Enable subcommand",
503503| `--ws-audience` | `string` | Expected `aud` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`. | type: "codex features enable <feature>",
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. | description:
505505| `--ws-issuer` | `string` | Expected `iss` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`. | "Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided.",
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`. | },
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`. | key: "Disable subcommand",
509509 type: "codex features disable <feature>",
510510Key description:
511511 "Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided.",
512512`--listen` },
513513 ];
514514Type / Values
515515 export const execResumeOptions = [
516516`stdio:// | ws://IP:PORT` {
517517 key: "SESSION_ID",
518518Details type: "uuid",
519519 description:
520520Transport listener URL. Use `ws://IP:PORT` to expose a WebSocket endpoint for remote clients. "Resume the specified session. Omit and use `--last` to continue the most recent session.",
521521 },
522522Key {
523523 key: "--last",
524524`--ws-audience` type: "boolean",
525525 defaultValue: "false",
526526Type / Values description:
527527 "Resume the most recent conversation from the current working directory.",
528528`string` },
529529 {
530530Details key: "--all",
531531 type: "boolean",
532532Expected `aud` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`. defaultValue: "false",
533533 description:
534534Key "Include sessions outside the current working directory when selecting the most recent session.",
535535 },
536536`--ws-auth` {
537537 key: "--image, -i",
538538Type / Values type: "path[,path...]",
539539 description:
540540`capability-token | signed-bearer-token` "Attach one or more images to the follow-up prompt. Separate multiple paths with commas or repeat the flag.",
541541 },
542542Details {
543543 key: "PROMPT",
544544Authentication mode for app-server WebSocket clients. If omitted, WebSocket auth is disabled; non-local listeners warn during startup. type: "string | - (read stdin)",
545545 description:
546546Key "Optional follow-up instruction sent immediately after resuming.",
547547 },
548548`--ws-issuer`];
549549
550550Type / Valuesexport const forkOptions = [
551551 {
552552`string` key: "SESSION_ID",
553553 type: "uuid",
554554Details description:
555555 "Fork the specified session. Omit and use `--last` to fork the most recent session.",
556556Expected `iss` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`. },
557557 {
558558Key key: "--last",
559559 type: "boolean",
560560`--ws-max-clock-skew-seconds` defaultValue: "false",
561561 description:
562562Type / Values "Skip the picker and fork the most recent conversation automatically.",
563563 },
564564`number` {
565565 key: "--all",
566566Details type: "boolean",
567567 defaultValue: "false",
568568Clock skew allowance when validating signed bearer token `exp` and `nbf` claims. Requires `--ws-auth signed-bearer-token`. description:
569569 "Show sessions beyond the current working directory in the picker.",
570570Key },
571571 ];
572572`--ws-shared-secret-file`
573573 export const execpolicyOptions = [
574574Type / Values {
575575 key: "--rules, -r",
576576`absolute path` type: "path (repeatable)",
577577 description:
578578Details "Path to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across files.",
579579 },
580580File containing the HMAC shared secret used to validate signed JWT bearer tokens. Required with `--ws-auth signed-bearer-token`. {
581581 key: "--pretty",
582582Key type: "boolean",
583583 defaultValue: "false",
584584`--ws-token-file` description: "Pretty-print the JSON result.",
585585 },
586586Type / Values {
587587 key: "COMMAND...",
588588`absolute path` type: "var-args",
589589 description: "Command to be checked against the specified policies.",
590590Details },
591591 ];
592592File containing the shared capability token. Required with `--ws-auth capability-token`.
593593 export const loginOptions = [
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. {
595595 key: "--with-api-key",
596596### `codex app` type: "boolean",
597597 description:
598598Launch Codex Desktop from the terminal on macOS and optionally open a specific workspace path. "Read an API key from stdin (for example `printenv OPENAI_API_KEY | codex login --with-api-key`).",
599599 },
600600| Key | Type / Values | Details | {
601601| --- | --- | --- | key: "--with-access-token",
602602| `--download-url` | `url` | Advanced override for the Codex desktop DMG download URL used during install. | type: "boolean",
603603| `PATH` | `path` | Workspace path to open in Codex Desktop (`codex app` is available on macOS only). | description:
604604 "Read an access token from stdin (for example `printenv CODEX_ACCESS_TOKEN | codex login --with-access-token`).",
605605Key },
606606 {
607607`--download-url` key: "--device-auth",
608608 type: "boolean",
609609Type / Values description:
610610 "Use OAuth device code flow instead of launching a browser window.",
611611`url` },
612612 {
613613Details key: "status subcommand",
614614 type: "codex login status",
615615Advanced override for the Codex desktop DMG download URL used during install. description:
616616 "Print the active authentication mode and exit with 0 when logged in.",
617617Key },
618618 ];
619619`PATH`
620620 export const applyOptions = [
621621Type / Values {
622622 key: "TASK_ID",
623623`path` type: "string",
624624 description:
625625Details "Identifier of the Codex Cloud task whose diff should be applied.",
626626 },
627627Workspace path to open in Codex Desktop (`codex app` is available on macOS only).];
628628
629629`codex app` installs/opens the desktop app on macOS, then opens the provided workspace path. This subcommand is macOS-only.export const sandboxMacOptions = [
630630 {
631631### `codex debug app-server send-message-v2` key: "--permissions-profile",
632632 type: "NAME",
633633Send one message through app-server's V2 thread/turn flow using the built-in app-server test client. description:
634634 "Apply a named permissions profile from the active configuration stack.",
635635| Key | Type / Values | Details | },
636636| --- | --- | --- | {
637637| `USER_MESSAGE` | `string` | Message text sent to app-server through the built-in V2 test-client flow. | key: "--cd, -C",
638638 type: "DIR",
639639Key description:
640640 "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
641641`USER_MESSAGE` },
642642 {
643643Type / Values key: "--include-managed-config",
644644 type: "boolean",
645645`string` defaultValue: "false",
646646 description:
647647Details "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
648648 },
649649Message text sent to app-server through the built-in V2 test-client flow. {
650650 key: "--allow-unix-socket",
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. type: "path",
652652 description:
653653### `codex apply` "Allow the sandboxed command to bind or connect Unix sockets rooted at this path. Repeat to allow multiple paths.",
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 key: "--log-denials",
657657| Key | Type / Values | Details | type: "boolean",
658658| --- | --- | --- | defaultValue: "false",
659659| `TASK_ID` | `string` | Identifier of the Codex Cloud task whose diff should be applied. | description:
660660 "Capture macOS sandbox denials with `log stream` while the command runs and print them after exit.",
661661Key },
662662 {
663663`TASK_ID` key: "--config, -c",
664664 type: "key=value",
665665Type / Values description:
666666 "Pass configuration overrides into the sandboxed run (repeatable).",
667667`string` },
668668 {
669669Details key: "COMMAND...",
670670 type: "var-args",
671671Identifier of the Codex Cloud task whose diff should be applied. description:
672672 "Shell command to execute under macOS Seatbelt. Everything after `--` is forwarded.",
673673Codex prints the patched files and exits non-zero if `git apply` fails (for example, due to conflicts). },
674674 ];
675675### `codex cloud`
676676 export const sandboxLinuxOptions = [
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. {
678678 key: "--permissions-profile",
679679| Key | Type / Values | Details | type: "NAME",
680680| --- | --- | --- | description:
681681| `--attempts` | `1-4` | Number of assistant attempts (best-of-N) Codex Cloud should run. | "Apply a named permissions profile from the active configuration stack.",
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. | {
684684 key: "--cd, -C",
685685Key type: "DIR",
686686 description:
687687`--attempts` "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
688688 },
689689Type / Values {
690690 key: "--include-managed-config",
691691`1-4` type: "boolean",
692692 defaultValue: "false",
693693Details description:
694694 "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
695695Number of assistant attempts (best-of-N) Codex Cloud should run. },
696696 {
697697Key key: "--config, -c",
698698 type: "key=value",
699699`--env` description:
700700 "Configuration overrides applied before launching the sandbox (repeatable).",
701701Type / Values },
702702 {
703703`ENV_ID` key: "COMMAND...",
704704 type: "var-args",
705705Details description:
706706 "Command to execute under Landlock + seccomp. Provide the executable after `--`.",
707707Target Codex Cloud environment identifier (required). Use `codex cloud` to list options. },
708708 ];
709709Key
710710 export const sandboxWindowsOptions = [
711711`QUERY` {
712712 key: "--permissions-profile",
713713Type / Values type: "NAME",
714714 description:
715715`string` "Apply a named permissions profile from the active configuration stack.",
716716 },
717717Details {
718718 key: "--cd, -C",
719719Task prompt. If omitted, Codex prompts interactively for details. type: "DIR",
720720 description:
721721Authentication follows the same credentials as the main CLI. Codex exits non-zero if the task submission fails. "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
722722 },
723723#### `codex cloud list` {
724724 key: "--include-managed-config",
725725List recent cloud tasks with optional filtering and pagination. type: "boolean",
726726 defaultValue: "false",
727727| Key | Type / Values | Details | description:
728728| --- | --- | --- | "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
729729| `--cursor` | `string` | Pagination cursor returned by a previous request. | },
730730| `--env` | `ENV_ID` | Filter tasks by environment identifier. | {
731731| `--json` | `boolean` | Emit machine-readable JSON instead of plain text. | key: "--config, -c",
732732| `--limit` | `1-20` | Maximum number of tasks to return. | type: "key=value",
733733 description:
734734Key "Configuration overrides applied before launching the sandbox (repeatable).",
735735 },
736736`--cursor` {
737737 key: "COMMAND...",
738738Type / Values type: "var-args",
739739 description:
740740`string` "Command to execute under the native Windows sandbox. Provide the executable after `--`.",
741741 },
742742Details];
743743
744744Pagination cursor returned by a previous request.export const completionOptions = [
745745 {
746746Key key: "SHELL",
747747 type: "bash | zsh | fish | power-shell | elvish",
748748`--env` defaultValue: "bash",
749749 description: "Shell to generate completions for. Output prints to stdout.",
750750Type / Values },
751751 ];
752752`ENV_ID`
753753 export const cloudExecOptions = [
754754Details {
755755 key: "QUERY",
756756Filter tasks by environment identifier. type: "string",
757757 description:
758758Key "Task prompt. If omitted, Codex prompts interactively for details.",
759759 },
760760`--json` {
761761 key: "--env",
762762Type / Values type: "ENV_ID",
763763 description:
764764`boolean` "Target Codex Cloud environment identifier (required). Use `codex cloud` to list options.",
765765 },
766766Details {
767767 key: "--attempts",
768768Emit machine-readable JSON instead of plain text. type: "1-4",
769769 defaultValue: "1",
770770Key description:
771771 "Number of assistant attempts (best-of-N) Codex Cloud should run.",
772772`--limit` },
773773 ];
774774Type / Values
775775 export const cloudListOptions = [
776776`1-20` {
777777 key: "--env",
778778Details type: "ENV_ID",
779779 description: "Filter tasks by environment identifier.",
780780Maximum number of tasks to return. },
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: "--limit",
783783 type: "1-20",
784784### `codex completion` defaultValue: "20",
785785 description: "Maximum number of tasks to return.",
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: "--cursor",
789789| --- | --- | --- | type: "string",
790790| `SHELL` | `bash | zsh | fish | power-shell | elvish` | Shell to generate completions for. Output prints to stdout. | description: "Pagination cursor returned by a previous request.",
791791 },
792792Key {
793793 key: "--json",
794794`SHELL` type: "boolean",
795795 defaultValue: "false",
796796Type / Values description: "Emit machine-readable JSON instead of plain text.",
797797 },
798798`bash | zsh | fish | power-shell | elvish`];
799799
800800Detailsexport const mcpCommands = [
801801 {
802802Shell to generate completions for. Output prints to stdout. key: "list",
803803 type: "--json",
804804### `codex features` description:
805805 "List configured MCP servers. Add `--json` for machine-readable output.",
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. },
807807 {
808808| Key | Type / Values | Details | key: "get <name>",
809809| --- | --- | --- | type: "--json",
810810| `Disable subcommand` | `codex features disable <feature>` | Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided. | description:
811811| `Enable subcommand` | `codex features enable <feature>` | Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided. | "Show a specific server configuration. `--json` prints the raw config entry.",
812812| `List subcommand` | `codex features list` | Show known feature flags, their maturity stage, and their effective state. | },
813813 {
814814Key key: "add <name>",
815815 type: "-- <command...> | --url <value>",
816816`Disable subcommand` description:
817817 "Register a server using a stdio launcher command or a streamable HTTP URL. Supports `--env KEY=VALUE` for stdio transports.",
818818Type / Values },
819819 {
820820`codex features disable <feature>` key: "remove <name>",
821821 description: "Delete a stored MCP server definition.",
822822Details },
823823 {
824824Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided. key: "login <name>",
825825 type: "--scopes scope1,scope2",
826826Key description:
827827 "Start an OAuth login for a streamable HTTP server (servers that support OAuth only).",
828828`Enable subcommand` },
829829 {
830830Type / Values key: "logout <name>",
831831 description:
832832`codex features enable <feature>` "Remove stored OAuth credentials for a streamable HTTP server.",
833833 },
834834Details];
835835
836836Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided.export const mcpAddOptions = [
837837 {
838838Key key: "COMMAND...",
839839 type: "stdio transport",
840840`List subcommand` description:
841841 "Executable plus arguments to launch the MCP server. Provide after `--`.",
842842Type / Values },
843843 {
844844`codex features list` key: "--env KEY=VALUE",
845845 type: "repeatable",
846846Details description:
847847 "Environment variable assignments applied when launching a stdio server.",
848848Show known feature flags, their maturity stage, and their effective state. },
849849 {
850850### `codex exec` key: "--url",
851851 type: "https://…",
852852Use `codex exec` (or the short form `codex e`) for scripted or CI-style runs that should finish without human interaction. description:
853853 "Register a streamable HTTP server instead of stdio. Mutually exclusive with `COMMAND...`.",
854854| Key | Type / Values | Details | },
855855| --- | --- | --- | {
856856| `--cd, -C` | `path` | Set the workspace root before executing the task. | key: "--bearer-token-env-var",
857857| `--color` | `always | never | auto` | Control ANSI color in stdout. | type: "ENV_VAR",
858858| `--dangerously-bypass-approvals-and-sandbox, --yolo` | `boolean` | Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner. | description:
859859| `--ephemeral` | `boolean` | Run without persisting session rollout files to disk. | "Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server.",
860860| `--full-auto` | `boolean` | Apply the low-friction automation preset (`workspace-write` sandbox and `on-request` approvals). | },
861861| `--image, -i` | `path[,path...]` | Attach images to the first message. Repeatable; supports comma-separated lists. |];
862862| `--json, --experimental-json` | `boolean` | Print newline-delimited JSON events instead of formatted text. |
863863| `--model, -m` | `string` | Override the configured model for this run. |export const marketplaceCommands = [
864864| `--oss` | `boolean` | Use the local open source provider (requires a running Ollama instance). | {
865865| `--output-last-message, -o` | `path` | Write the assistant’s final message to a file. Useful for downstream scripting. | key: "add <source>",
866866| `--output-schema` | `path` | JSON Schema file describing the expected final response shape. Codex validates tool output against it. | type: "[--ref REF] [--sparse PATH]",
867867| `--profile, -p` | `string` | Select a configuration profile defined in config.toml. | description:
868868| `--sandbox, -s` | `read-only | workspace-write | danger-full-access` | Sandbox policy for model-generated commands. Defaults to configuration. | "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.",
869869| `--skip-git-repo-check` | `boolean` | Allow running outside a Git repository (useful for one-off directories). | },
870870| `-c, --config` | `key=value` | Inline configuration override for the non-interactive run (repeatable). | {
871871| `PROMPT` | `string | - (read stdin)` | Initial instruction for the task. Use `-` to pipe the prompt from stdin. | key: "upgrade [marketplace-name]",
872872| `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. | description:
873873 "Refresh one configured Git marketplace, or all configured Git marketplaces when no name is provided.",
874874Key },
875875 {
876876`--cd, -C` key: "remove <marketplace-name>",
877877 description: "Remove a configured plugin marketplace.",
878878Type / Values },
879879 ];
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 880
912881`--ephemeral`## How to read this reference
913
914Type / Values
915
916`boolean`
917
918Details
919
920Run without persisting session rollout files to disk.
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 882
978883DetailsThis 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.
979 884
980885Use the local open source provider (requires a running Ollama instance).The CLI inherits most defaults from <code>~/.codex/config.toml</code>. Any
886 <code>-c key=value</code> overrides you pass at the command line take
887 precedence for that invocation. See [Config
888 basics](https://developers.openai.com/codex/config-basic#configuration-precedence) for more information.
981 889
982890Key## Global flags
983 891
984892`--output-last-message, -o`<ConfigTable client:load options={globalFlagOptions} />
985 893
986894Type / ValuesThese options apply to the base `codex` command and propagate to each subcommand unless a section below specifies otherwise.
895When you run a subcommand, place global flags after it (for example, `codex exec --oss ...`) so Codex applies them as intended.
987 896
988897`path`## Command overview
989 898
990899DetailsThe Maturity column uses feature maturity labels such as Experimental, Beta,
900 and Stable. See [Feature Maturity](https://developers.openai.com/codex/feature-maturity) for how to
901 interpret these labels.
991 902
992903Write the assistant’s final message to a file. Useful for downstream scripting.<ConfigTable
904 client:load
905 options={commandOverview}
906 secondColumnTitle="Maturity"
907 secondColumnVariant="maturity"
908/>
993 909
994910Key## Command details
995 911
996912`--output-schema`### `codex` (interactive)
997 913
998914Type / ValuesRunning `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`.
999 915
1000916`path`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.
1001 917
1002918Details### `codex app-server`
1003 919
1004920JSON Schema file describing the expected final response shape. Codex validates tool output against it.Launch the Codex app server locally. This is primarily for development and debugging and may change without notice.
1005 921
1006922Key<ConfigTable client:load options={appServerOptions} />
1007 923
1008924`--profile, -p``codex app-server --listen stdio://` keeps the default JSONL-over-stdio behavior. `--listen ws://IP:PORT` enables WebSocket transport for app-server clients. The server accepts `ws://` listen URLs; use TLS termination or a secure proxy when clients connect with `wss://`. Use `--listen unix://` to accept WebSocket handshakes on Codex's default Unix socket, or `--listen unix:///absolute/path.sock` to choose a socket path. If you generate schemas for client bindings, add `--experimental` to include gated fields and methods.
1009 925
1010926Type / Values### `codex remote-control`
1011 927
1012928`string`Ensure the app-server daemon is running with remote-control support enabled.
929Managed remote-control clients and SSH remote workflows use this command; it's
930not a replacement for `codex app-server --listen` when you are building a local
931protocol client.
1013 932
1014933Details### `codex app`
1015 934
1016935Select 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 936
1018937Key<ConfigTable client:load options={appOptions} />
1019 938
1020939`--sandbox, -s``codex app` opens an installed Codex Desktop app, or starts the installer when
940the app is missing. On macOS, Codex opens the provided workspace path; on
941Windows, it prints the path to open after installation.
1021 942
1022943Type / Values### `codex debug app-server send-message-v2`
1023 944
1024945`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 946
1026947Details<ConfigTable client:load options={debugAppServerSendMessageV2Options} />
1027 948
1028949Sandbox 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 950
1030951Key### `codex debug models`
1031 952
1032953`--skip-git-repo-check`Print the raw model catalog Codex sees as JSON.
1033 954
1034955Type / Values<ConfigTable client:load options={debugModelsOptions} />
1035 956
1036957`boolean`Use `--bundled` when you want to inspect only the catalog bundled with the current binary, without refreshing from the remote models endpoint.
1037 958
1038959Details### `codex apply`
1039 960
1040961Allow 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 962
1042963Key<ConfigTable client:load options={applyOptions} />
1043 964
1044965`-c, --config`Codex prints the patched files and exits non-zero if `git apply` fails (for example, due to conflicts).
1045 966
1046967Type / Values### `codex cloud`
1047 968
1048969`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 970
1050971Details<ConfigTable client:load options={cloudExecOptions} />
1051 972
1052973Inline 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 974
1054975Key#### `codex cloud list`
1055 976
1056977`PROMPT`List recent cloud tasks with optional filtering and pagination.
1057 978
1058979Type / Values<ConfigTable client:load options={cloudListOptions} />
1059 980
1060981`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 982
1062983Details### `codex completion`
1063 984
1064985Initial 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 986
1066987Key<ConfigTable client:load options={completionOptions} />
1067 988
1068989`Resume subcommand`### `codex features`
1069 990
1070991Type / 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 992
1072993`codex exec resume [SESSION_ID]`<ConfigTable client:load options={featuresOptions} />
1073 994
1074995Details### `codex exec`
1075 996
1076997Resume 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 998
1078999Expand to view all<ConfigTable client:load options={execOptions} />
1079 1000
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:1001Codex 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 1002
10821003| 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 1004
1150### `codex execpolicy`1005### `codex execpolicy`
1151 1006
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.1007Check `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 1008
11541009| 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 1010
1196### `codex login`1011### `codex login`
1197 1012
11981013Authenticate the CLI with a ChatGPT account or API key. With no flags, Codex opens a browser for the ChatGPT OAuth flow.Authenticate the CLI with a ChatGPT account, API key, or access token. With no flags, Codex opens a browser for the ChatGPT OAuth flow.
1199
1200| Key | Type / Values | Details |
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 1014
12281015Read an API key from stdin (for example `printenv OPENAI_API_KEY | codex login --with-api-key`).<ConfigTable client:load options={loginOptions} />
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 1016
1242`codex login status` exits with `0` when credentials are present, which is helpful in automation scripts.1017`codex login status` exits with `0` when credentials are present, which is helpful in automation scripts.
1243 1018
1249 1024
1250Manage Model Context Protocol server entries stored in `~/.codex/config.toml`.1025Manage Model Context Protocol server entries stored in `~/.codex/config.toml`.
1251 1026
12521027| 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 1028
1325The `add` subcommand supports both stdio and streamable HTTP transports:1029The `add` subcommand supports both stdio and streamable HTTP transports:
1326 1030
13271031| 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 1032
13541033DetailsOAuth 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 1034
13761035`stdio transport`### `codex plugin marketplace`
1377 1036
13781037DetailsManage plugin marketplace sources that Codex can browse and install from.
1379 1038
13801039Executable plus arguments to launch the MCP server. Provide after `--`.<ConfigTable client:load options={marketplaceCommands} />
1381 1040
13821041OAuth 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
1042`owner/repo@ref`, HTTP or HTTPS Git URLs, SSH Git URLs, and local marketplace
1043root directories. Use `--ref` to pin a Git ref, and repeat `--sparse PATH` to
1044use a sparse checkout for Git-backed marketplace repositories.
1383 1045
1384### `codex mcp-server`1046### `codex mcp-server`
1385 1047
1389 1051
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.1052Continue 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 1053
13921054| 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 1055
1434### `codex fork`1056### `codex fork`
1435 1057
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.1058Fork 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 1059
14381060| 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 1061
1480### `codex sandbox`1062### `codex sandbox`
1481 1063
1483 1065
1484#### macOS seatbelt1066#### macOS seatbelt
1485 1067
14861068| 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 1069
1528#### Linux Landlock1070#### Linux Landlock
1529 1071
15301072| 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 1073
15641074Type / Values#### Windows
1565 1075
15661076`var-args`<ConfigTable client:load options={sandboxWindowsOptions} />
1567 1077
15681078Details### `codex update`
1569 1079
15701080Command 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 1081
1572## Flag combinations and safety tips1082## Flag combinations and safety tips
1573 1083
15741084- 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`.1085- 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.1086- Pair `--json` with `--output-last-message` in CI to capture machine-readable progress and a final natural-language summary.
1577 1087