cli/reference.md +968 −1352
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 over stdio, WebSocket, or a Unix socket.",
126126 },
127127Shortcut for low-friction local work: sets `--ask-for-approval on-request` and `--sandbox workspace-write`. {
128128 key: "codex remote-control",
129129Key href: "/codex/cli/reference#codex-remote-control",
130130 type: "experimental",
131131`--image, -i` description:
132132 "Ensure the local app-server daemon is running with remote-control support enabled.",
133133Type / Values },
134134 {
135135`path[,path...]` key: "codex app",
136136 href: "/codex/cli/reference#codex-app",
137137Details type: "stable",
138138 description:
139139Attach one or more image files to the initial prompt. Separate multiple paths with commas or repeat the flag. "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 },
141141Key {
142142 key: "codex debug app-server send-message-v2",
143143`--model, -m` href: "/codex/cli/reference#codex-debug-app-server-send-message-v2",
144144 type: "experimental",
145145Type / Values description:
146146 "Debug app-server by sending a single V2 message through the built-in test client.",
147147`string` },
148148 {
149149Details key: "codex debug models",
150150 href: "/codex/cli/reference#codex-debug-models",
151151Override the model set in configuration (for example `gpt-5-codex`). type: "experimental",
152152 description:
153153Key "Print the raw model catalog Codex sees, including an option to inspect only the bundled catalog.",
154154 },
155155`--no-alt-screen` {
156156 key: "codex apply",
157157Type / Values href: "/codex/cli/reference#codex-apply",
158158 type: "stable",
159159`boolean` description:
160160 "Apply the latest diff generated by a Codex Cloud task to your local working tree. Alias: `codex a`.",
161161Details },
162162 {
163163Disable alternate screen mode for the TUI (overrides `tui.alternate_screen` for this run). key: "codex cloud",
164164 href: "/codex/cli/reference#codex-cloud",
165165Key type: "experimental",
166166 description:
167167`--oss` "Browse or execute Codex Cloud tasks from the terminal without opening the TUI. Alias: `codex cloud-tasks`.",
168168 },
169169Type / Values {
170170 key: "codex completion",
171171`boolean` href: "/codex/cli/reference#codex-completion",
172172 type: "stable",
173173Details description:
174174 "Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell.",
175175Use the local open source model provider (equivalent to `-c model_provider="oss"`). Validates that Ollama is running. },
176176 {
177177Key key: "codex features",
178178 href: "/codex/cli/reference#codex-features",
179179`--profile, -p` type: "stable",
180180 description:
181181Type / Values "List feature flags and persistently enable or disable them in `config.toml`.",
182182 },
183183`string` {
184184 key: "codex exec",
185185Details href: "/codex/cli/reference#codex-exec",
186186 type: "stable",
187187Configuration profile name to load from `~/.codex/config.toml`. description:
188188 "Run Codex non-interactively. Alias: `codex e`. Stream results to stdout or JSONL and optionally resume previous sessions.",
189189Key },
190190 {
191191`--sandbox, -s` key: "codex execpolicy",
192192 href: "/codex/cli/reference#codex-execpolicy",
193193Type / Values type: "experimental",
194194 description:
195195`read-only | workspace-write | danger-full-access` "Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked.",
196196 },
197197Details {
198198 key: "codex login",
199199Select the sandbox policy for model-generated shell commands. href: "/codex/cli/reference#codex-login",
200200 type: "stable",
201201Key description:
202202 "Authenticate Codex using ChatGPT OAuth, device auth, an API key, or an access token piped over stdin.",
203203`--search` },
204204 {
205205Type / Values key: "codex logout",
206206 href: "/codex/cli/reference#codex-logout",
207207`boolean` type: "stable",
208208 description: "Remove stored authentication credentials.",
209209Details },
210210 {
211211Enable live web search (sets `web_search = "live"` instead of the default `"cached"`). key: "codex mcp",
212212 href: "/codex/cli/reference#codex-mcp",
213213Key type: "experimental",
214214 description:
215215`PROMPT` "Manage Model Context Protocol servers (list, add, remove, authenticate).",
216216 },
217217Type / Values {
218218 key: "codex plugin marketplace",
219219`string` href: "/codex/cli/reference#codex-plugin-marketplace",
220220 type: "experimental",
221221Details description:
222222 "Add, upgrade, or remove plugin marketplaces from Git or local sources.",
223223Optional text instruction to start the session. Omit to launch the TUI without a pre-filled message. },
224224 {
225225Expand to view all key: "codex mcp-server",
226226 href: "/codex/cli/reference#codex-mcp-server",
227227These options apply to the base `codex` command and propagate to each subcommand unless a section below specifies otherwise. type: "experimental",
228228When you run a subcommand, place global flags after it (for example, `codex exec --oss ...`) so Codex applies them as intended. description:
229229 "Run Codex itself as an MCP server over stdio. Useful when another agent consumes Codex.",
230230## Command overview },
231231 {
232232The Maturity column uses feature maturity labels such as Experimental, Beta, key: "codex resume",
233233 and Stable. See [Feature Maturity](https://developers.openai.com/codex/feature-maturity) for how to href: "/codex/cli/reference#codex-resume",
234234 interpret these labels. type: "stable",
235235 description:
236236| Key | Maturity | Details | "Continue a previous interactive session by ID or resume the most recent conversation.",
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 fork",
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-fork",
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: "stable",
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. | "Fork a previous interactive session into a new thread, preserving the original transcript.",
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 sandbox",
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-sandbox",
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: "experimental",
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. | "Run arbitrary commands inside Codex-provided macOS, Linux, or Windows sandboxes.",
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. | key: "codex update",
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). | href: "/codex/cli/reference#codex-update",
255255 type: "stable",
256256Key description:
257257 "Check for and apply a Codex CLI update when the installed release supports self-update.",
258258[`codex`](https://developers.openai.com/codex/cli/reference#codex-interactive) },
259259 ];
260260Maturity
261261 export const execOptions = [
262262Stable {
263263 key: "PROMPT",
264264Details type: "string | - (read stdin)",
265265 description:
266266Launch the terminal UI. Accepts the global flags above plus an optional prompt or image attachments. "Initial instruction for the task. Use `-` to pipe the prompt from stdin.",
267267 },
268268Key {
269269 key: "--image, -i",
270270[`codex app`](https://developers.openai.com/codex/cli/reference#codex-app) type: "path[,path...]",
271271 description:
272272Maturity "Attach images to the first message. Repeatable; supports comma-separated lists.",
273273 },
274274Stable {
275275 key: "--model, -m",
276276Details type: "string",
277277 description: "Override the configured model for this run.",
278278Launch the Codex desktop app on macOS, optionally opening a specific workspace path. },
279279 {
280280Key key: "--oss",
281281 type: "boolean",
282282[`codex app-server`](https://developers.openai.com/codex/cli/reference#codex-app-server) defaultValue: "false",
283283 description:
284284Maturity "Use the local open source provider (requires a running Ollama instance).",
285285 },
286286Experimental {
287287 key: "--sandbox, -s",
288288Details type: "read-only | workspace-write | danger-full-access",
289289 description:
290290Launch the Codex app server for local development or debugging. "Sandbox policy for model-generated commands. Defaults to configuration.",
291291 },
292292Key {
293293 key: "--profile, -p",
294294[`codex apply`](https://developers.openai.com/codex/cli/reference#codex-apply) type: "string",
295295 description: "Select a configuration profile defined in config.toml.",
296296Maturity },
297297 {
298298Stable key: "--full-auto",
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`. "Deprecated compatibility flag. Prefer `--sandbox workspace-write`; Codex prints a warning when this flag is used.",
303303 },
304304Key {
305305 key: "--dangerously-bypass-approvals-and-sandbox, --yolo",
306306[`codex cloud`](https://developers.openai.com/codex/cli/reference#codex-cloud) type: "boolean",
307307 defaultValue: "false",
308308Maturity description:
309309 "Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner.",
310310Experimental },
311311 {
312312Details key: "--cd, -C",
313313 type: "path",
314314Browse or execute Codex Cloud tasks from the terminal without opening the TUI. Alias: `codex cloud-tasks`. description: "Set the workspace root before executing the task.",
315315 },
316316Key {
317317 key: "--skip-git-repo-check",
318318[`codex completion`](https://developers.openai.com/codex/cli/reference#codex-completion) type: "boolean",
319319 defaultValue: "false",
320320Maturity description:
321321 "Allow running outside a Git repository (useful for one-off directories).",
322322Stable },
323323 {
324324Details key: "--ephemeral",
325325 type: "boolean",
326326Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell. defaultValue: "false",
327327 description: "Run without persisting session rollout files to disk.",
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-user-config",
331331 type: "boolean",
332332Maturity defaultValue: "false",
333333 description:
334334Experimental "Do not load `$CODEX_HOME/config.toml`. Authentication still uses `CODEX_HOME`.",
335335 },
336336Details {
337337 key: "--ignore-rules",
338338Debug app-server by sending a single V2 message through the built-in test client. type: "boolean",
339339 defaultValue: "false",
340340Key description:
341341 "Do not load user or project execpolicy `.rules` files for this run.",
342342[`codex exec`](https://developers.openai.com/codex/cli/reference#codex-exec) },
343343 {
344344Maturity key: "--output-schema",
345345 type: "path",
346346Stable description:
347347 "JSON Schema file describing the expected final response shape. Codex validates tool output against it.",
348348Details },
349349 {
350350Run Codex non-interactively. Alias: `codex e`. Stream results to stdout or JSONL and optionally resume previous sessions. key: "--color",
351351 type: "always | never | auto",
352352Key defaultValue: "auto",
353353 description: "Control ANSI color in stdout.",
354354[`codex execpolicy`](https://developers.openai.com/codex/cli/reference#codex-execpolicy) },
355355 {
356356Maturity key: "--json, --experimental-json",
357357 type: "boolean",
358358Experimental defaultValue: "false",
359359 description:
360360Details "Print newline-delimited JSON events instead of formatted text.",
361361 },
362362Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked. {
363363 key: "--output-last-message, -o",
364364Key type: "path",
365365 description:
366366[`codex features`](https://developers.openai.com/codex/cli/reference#codex-features) "Write the assistant’s final message to a file. Useful for downstream scripting.",
367367 },
368368Maturity {
369369 key: "Resume subcommand",
370370Stable type: "codex exec resume [SESSION_ID]",
371371 description:
372372Details "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 },
374374List feature flags and persistently enable or disable them in `config.toml`. {
375375 key: "-c, --config",
376376Key type: "key=value",
377377 description:
378378[`codex fork`](https://developers.openai.com/codex/cli/reference#codex-fork) "Inline configuration override for the non-interactive run (repeatable).",
379379 },
380380Maturity];
381381
382382Stableexport const appServerOptions = [
383383 {
384384Details key: "--listen",
385385 type: "stdio:// | ws://IP:PORT | unix:// | unix://PATH | off",
386386Fork a previous interactive session into a new thread, preserving the original transcript. defaultValue: "stdio://",
387387 description:
388388Key "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 },
390390[`codex login`](https://developers.openai.com/codex/cli/reference#codex-login) {
391391 key: "--ws-auth",
392392Maturity type: "capability-token | signed-bearer-token",
393393 description:
394394Stable "Authentication mode for app-server WebSocket clients. If omitted, WebSocket auth is disabled; non-local listeners warn during startup.",
395395 },
396396Details {
397397 key: "--ws-token-file",
398398Authenticate Codex using ChatGPT OAuth, device auth, or an API key piped over stdin. type: "absolute path",
399399 description:
400400Key "File containing the shared capability token. Required with `--ws-auth capability-token`.",
401401 },
402402[`codex logout`](https://developers.openai.com/codex/cli/reference#codex-logout) {
403403 key: "--ws-shared-secret-file",
404404Maturity type: "absolute path",
405405 description:
406406Stable "File containing the HMAC shared secret used to validate signed JWT bearer tokens. Required with `--ws-auth signed-bearer-token`.",
407407 },
408408Details {
409409 key: "--ws-issuer",
410410Remove stored authentication credentials. type: "string",
411411 description:
412412Key "Expected `iss` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`.",
413413 },
414414[`codex mcp`](https://developers.openai.com/codex/cli/reference#codex-mcp) {
415415 key: "--ws-audience",
416416Maturity type: "string",
417417 description:
418418Experimental "Expected `aud` claim for signed bearer tokens. Requires `--ws-auth signed-bearer-token`.",
419419 },
420420Details {
421421 key: "--ws-max-clock-skew-seconds",
422422Manage Model Context Protocol servers (list, add, remove, authenticate). type: "number",
423423 defaultValue: "30",
424424Key description:
425425 "Clock skew allowance when validating signed bearer token `exp` and `nbf` claims. Requires `--ws-auth signed-bearer-token`.",
426426[`codex mcp-server`](https://developers.openai.com/codex/cli/reference#codex-mcp-server) },
427427 {
428428Maturity key: "--analytics-default-enabled",
429429 type: "boolean",
430430Experimental defaultValue: "false",
431431 description:
432432Details "Defaults analytics to enabled for first-party app-server clients unless the user opts out in config.",
433433 },
434434Run Codex itself as an MCP server over stdio. Useful when another agent consumes Codex.];
435435
436436Keyexport const appOptions = [
437437 {
438438[`codex resume`](https://developers.openai.com/codex/cli/reference#codex-resume) key: "PATH",
439439 type: "path",
440440Maturity defaultValue: ".",
441441 description:
442442Stable "Workspace path for Codex Desktop. On macOS, Codex opens this path; on Windows, Codex prints the path.",
443443 },
444444Details {
445445 key: "--download-url",
446446Continue a previous interactive session by ID or resume the most recent conversation. type: "url",
447447 description:
448448Key "Advanced override for the Codex desktop installer URL used during install.",
449449 },
450450[`codex sandbox`](https://developers.openai.com/codex/cli/reference#codex-sandbox)];
451451
452452Maturityexport const debugAppServerSendMessageV2Options = [
453453 {
454454Experimental key: "USER_MESSAGE",
455455 type: "string",
456456Details description:
457457 "Message text sent to app-server through the built-in V2 test-client flow.",
458458Run arbitrary commands inside Codex-provided macOS seatbelt or Linux sandboxes (Landlock by default, optional bubblewrap pipeline). },
459459 ];
460460Expand to view all
461461 export const debugModelsOptions = [
462462## Command details {
463463 key: "--bundled",
464464### `codex` (interactive) type: "boolean",
465465 defaultValue: "false",
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. description:
467467 "Skip refresh and print only the model catalog bundled with the current Codex binary.",
468468### `codex app-server` },
469469 ];
470470Launch the Codex app server locally. This is primarily for development and debugging and may change without notice.
471471 export const resumeOptions = [
472472| Key | Type / Values | Details | {
473473| --- | --- | --- | key: "SESSION_ID",
474474| `--listen` | `stdio:// | ws://IP:PORT` | Transport listener URL. `ws://` is experimental and intended for development/testing. | type: "uuid",
475475 description:
476476Key "Resume the specified session. Omit and use `--last` to continue the most recent session.",
477477 },
478478`--listen` {
479479 key: "--last",
480480Type / Values type: "boolean",
481481 defaultValue: "false",
482482`stdio:// | ws://IP:PORT` description:
483483 "Skip the picker and resume the most recent conversation from the current working directory.",
484484Details },
485485 {
486486Transport listener URL. `ws://` is experimental and intended for development/testing. key: "--all",
487487 type: "boolean",
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. defaultValue: "false",
489489 description:
490490### `codex app` "Include sessions outside the current working directory when selecting the most recent session.",
491491 },
492492Launch Codex Desktop from the terminal on macOS and optionally open a specific workspace path.];
493493
494494| Key | Type / Values | Details |export const featuresOptions = [
495495| --- | --- | --- | {
496496| `--download-url` | `url` | Advanced override for the Codex desktop DMG download URL used during install. | key: "List subcommand",
497497| `PATH` | `path` | Workspace path to open in Codex Desktop (`codex app` is available on macOS only). | type: "codex features list",
498498 description:
499499Key "Show known feature flags, their maturity stage, and their effective state.",
500500 },
501501`--download-url` {
502502 key: "Enable subcommand",
503503Type / Values type: "codex features enable <feature>",
504504 description:
505505`url` "Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided.",
506506 },
507507Details {
508508 key: "Disable subcommand",
509509Advanced override for the Codex desktop DMG download URL used during install. type: "codex features disable <feature>",
510510 description:
511511Key "Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided.",
512512 },
513513`PATH`];
514514
515515Type / Valuesexport const execResumeOptions = [
516516 {
517517`path` key: "SESSION_ID",
518518 type: "uuid",
519519Details description:
520520 "Resume the specified session. Omit and use `--last` to continue 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: "--last",
524524 type: "boolean",
525525### `codex debug app-server send-message-v2` defaultValue: "false",
526526 description:
527527Send one message through app-server's V2 thread/turn flow using the built-in app-server test client. "Resume the most recent conversation from the current working directory.",
528528 },
529529| Key | Type / Values | Details | {
530530| --- | --- | --- | key: "--all",
531531| `USER_MESSAGE` | `string` | Message text sent to app-server through the built-in V2 test-client flow. | type: "boolean",
532532 defaultValue: "false",
533533Key description:
534534 "Include sessions outside the current working directory when selecting the most recent session.",
535535`USER_MESSAGE` },
536536 {
537537Type / Values key: "--image, -i",
538538 type: "path[,path...]",
539539`string` description:
540540 "Attach one or more images to the follow-up prompt. Separate multiple paths with commas or repeat the flag.",
541541Details },
542542 {
543543Message text sent to app-server through the built-in V2 test-client flow. key: "PROMPT",
544544 type: "string | - (read stdin)",
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. description:
546546 "Optional follow-up instruction sent immediately after resuming.",
547547### `codex apply` },
548548 ];
549549Apply the most recent diff from a Codex cloud task to your local repository. You must authenticate and have access to the task.
550550 export const forkOptions = [
551551| Key | Type / Values | Details | {
552552| --- | --- | --- | key: "SESSION_ID",
553553| `TASK_ID` | `string` | Identifier of the Codex Cloud task whose diff should be applied. | type: "uuid",
554554 description:
555555Key "Fork the specified session. Omit and use `--last` to fork the most recent session.",
556556 },
557557`TASK_ID` {
558558 key: "--last",
559559Type / Values type: "boolean",
560560 defaultValue: "false",
561561`string` description:
562562 "Skip the picker and fork the most recent conversation automatically.",
563563Details },
564564 {
565565Identifier of the Codex Cloud task whose diff should be applied. key: "--all",
566566 type: "boolean",
567567Codex prints the patched files and exits non-zero if `git apply` fails (for example, due to conflicts). defaultValue: "false",
568568 description:
569569### `codex cloud` "Show sessions beyond the current working directory in the picker.",
570570 },
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 |export const execpolicyOptions = [
574574| --- | --- | --- | {
575575| `--attempts` | `1-4` | Number of assistant attempts (best-of-N) Codex Cloud should run. | key: "--rules, -r",
576576| `--env` | `ENV_ID` | Target Codex Cloud environment identifier (required). Use `codex cloud` to list options. | type: "path (repeatable)",
577577| `QUERY` | `string` | Task prompt. If omitted, Codex prompts interactively for details. | description:
578578 "Path to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across files.",
579579Key },
580580 {
581581`--attempts` key: "--pretty",
582582 type: "boolean",
583583Type / Values defaultValue: "false",
584584 description: "Pretty-print the JSON result.",
585585`1-4` },
586586 {
587587Details key: "COMMAND...",
588588 type: "var-args",
589589Number of assistant attempts (best-of-N) Codex Cloud should run. description: "Command to be checked against the specified policies.",
590590 },
591591Key];
592592
593593`--env`export const loginOptions = [
594594 {
595595Type / Values key: "--with-api-key",
596596 type: "boolean",
597597`ENV_ID` description:
598598 "Read an API key from stdin (for example `printenv OPENAI_API_KEY | codex login --with-api-key`).",
599599Details },
600600 {
601601Target Codex Cloud environment identifier (required). Use `codex cloud` to list options. key: "--with-access-token",
602602 type: "boolean",
603603Key description:
604604 "Read an access token from stdin (for example `printenv CODEX_ACCESS_TOKEN | codex login --with-access-token`).",
605605`QUERY` },
606606 {
607607Type / Values key: "--device-auth",
608608 type: "boolean",
609609`string` description:
610610 "Use OAuth device code flow instead of launching a browser window.",
611611Details },
612612 {
613613Task prompt. If omitted, Codex prompts interactively for details. key: "status subcommand",
614614 type: "codex login status",
615615Authentication follows the same credentials as the main CLI. Codex exits non-zero if the task submission fails. description:
616616 "Print the active authentication mode and exit with 0 when logged in.",
617617#### `codex cloud list` },
618618 ];
619619List recent cloud tasks with optional filtering and pagination.
620620 export const applyOptions = [
621621| Key | Type / Values | Details | {
622622| --- | --- | --- | key: "TASK_ID",
623623| `--cursor` | `string` | Pagination cursor returned by a previous request. | type: "string",
624624| `--env` | `ENV_ID` | Filter tasks by environment identifier. | description:
625625| `--json` | `boolean` | Emit machine-readable JSON instead of plain text. | "Identifier of the Codex Cloud task whose diff should be applied.",
626626| `--limit` | `1-20` | Maximum number of tasks to return. | },
627627 ];
628628Key
629629 export const sandboxMacOptions = [
630630`--cursor` {
631631 key: "--permissions-profile",
632632Type / Values type: "NAME",
633633 description:
634634`string` "Apply a named permissions profile from the active configuration stack.",
635635 },
636636Details {
637637 key: "--cd, -C",
638638Pagination cursor returned by a previous request. type: "DIR",
639639 description:
640640Key "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
641641 },
642642`--env` {
643643 key: "--include-managed-config",
644644Type / Values type: "boolean",
645645 defaultValue: "false",
646646`ENV_ID` description:
647647 "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
648648Details },
649649 {
650650Filter tasks by environment identifier. key: "--allow-unix-socket",
651651 type: "path",
652652Key description:
653653 "Allow the sandboxed command to bind or connect Unix sockets rooted at this path. Repeat to allow multiple paths.",
654654`--json` },
655655 {
656656Type / Values key: "--log-denials",
657657 type: "boolean",
658658`boolean` defaultValue: "false",
659659 description:
660660Details "Capture macOS sandbox denials with `log stream` while the command runs and print them after exit.",
661661 },
662662Emit machine-readable JSON instead of plain text. {
663663 key: "--config, -c",
664664Key type: "key=value",
665665 description:
666666`--limit` "Pass configuration overrides into the sandboxed run (repeatable).",
667667 },
668668Type / Values {
669669 key: "COMMAND...",
670670`1-20` type: "var-args",
671671 description:
672672Details "Shell command to execute under macOS Seatbelt. Everything after `--` is forwarded.",
673673 },
674674Maximum number of tasks to return.];
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`.export const sandboxLinuxOptions = [
677677 {
678678### `codex completion` key: "--permissions-profile",
679679 type: "NAME",
680680Generate shell completion scripts and redirect the output to the appropriate location, for example `codex completion zsh > "${fpath[1]}/_codex"`. description:
681681 "Apply a named permissions profile from the active configuration stack.",
682682| Key | Type / Values | Details | },
683683| --- | --- | --- | {
684684| `SHELL` | `bash | zsh | fish | power-shell | elvish` | Shell to generate completions for. Output prints to stdout. | key: "--cd, -C",
685685 type: "DIR",
686686Key description:
687687 "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
688688`SHELL` },
689689 {
690690Type / Values key: "--include-managed-config",
691691 type: "boolean",
692692`bash | zsh | fish | power-shell | elvish` defaultValue: "false",
693693 description:
694694Details "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
695695 },
696696Shell to generate completions for. Output prints to stdout. {
697697 key: "--config, -c",
698698### `codex features` type: "key=value",
699699 description:
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. "Configuration overrides applied before launching the sandbox (repeatable).",
701701 },
702702| Key | Type / Values | Details | {
703703| --- | --- | --- | key: "COMMAND...",
704704| `Disable subcommand` | `codex features disable <feature>` | Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided. | type: "var-args",
705705| `Enable subcommand` | `codex features enable <feature>` | Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided. | description:
706706| `List subcommand` | `codex features list` | Show known feature flags, their maturity stage, and their effective state. | "Command to execute under Landlock + seccomp. Provide the executable after `--`.",
707707 },
708708Key];
709709
710710`Disable subcommand`export const sandboxWindowsOptions = [
711711 {
712712Type / Values key: "--permissions-profile",
713713 type: "NAME",
714714`codex features disable <feature>` description:
715715 "Apply a named permissions profile from the active configuration stack.",
716716Details },
717717 {
718718Persistently disable a feature flag in `config.toml`. Respects the active `--profile` when provided. key: "--cd, -C",
719719 type: "DIR",
720720Key description:
721721 "Working directory used for profile resolution and command execution. Requires `--permissions-profile`.",
722722`Enable subcommand` },
723723 {
724724Type / Values key: "--include-managed-config",
725725 type: "boolean",
726726`codex features enable <feature>` defaultValue: "false",
727727 description:
728728Details "Include managed requirements while resolving an explicit permissions profile. Requires `--permissions-profile`.",
729729 },
730730Persistently enable a feature flag in `config.toml`. Respects the active `--profile` when provided. {
731731 key: "--config, -c",
732732Key type: "key=value",
733733 description:
734734`List subcommand` "Configuration overrides applied before launching the sandbox (repeatable).",
735735 },
736736Type / Values {
737737 key: "COMMAND...",
738738`codex features list` type: "var-args",
739739 description:
740740Details "Command to execute under the native Windows sandbox. Provide the executable after `--`.",
741741 },
742742Show known feature flags, their maturity stage, and their effective state.];
743743
744744### `codex exec`export const completionOptions = [
745745 {
746746Use `codex exec` (or the short form `codex e`) for scripted or CI-style runs that should finish without human interaction. key: "SHELL",
747747 type: "bash | zsh | fish | power-shell | elvish",
748748| Key | Type / Values | Details | defaultValue: "bash",
749749| --- | --- | --- | description: "Shell to generate completions for. Output prints to stdout.",
750750| `--cd, -C` | `path` | Set the workspace root before executing the task. | },
751751| `--color` | `always | never | auto` | Control ANSI color in stdout. |];
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. |export const cloudExecOptions = [
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. | key: "QUERY",
756756| `--json, --experimental-json` | `boolean` | Print newline-delimited JSON events instead of formatted text. | type: "string",
757757| `--model, -m` | `string` | Override the configured model for this run. | description:
758758| `--oss` | `boolean` | Use the local open source provider (requires a running Ollama instance). | "Task prompt. If omitted, Codex prompts interactively for details.",
759759| `--output-last-message, -o` | `path` | Write the assistant’s final message to a file. Useful for downstream scripting. | },
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. | key: "--env",
762762| `--sandbox, -s` | `read-only | workspace-write | danger-full-access` | Sandbox policy for model-generated commands. Defaults to configuration. | type: "ENV_ID",
763763| `--skip-git-repo-check` | `boolean` | Allow running outside a Git repository (useful for one-off directories). | description:
764764| `-c, --config` | `key=value` | Inline configuration override for the non-interactive run (repeatable). | "Target Codex Cloud environment identifier (required). Use `codex cloud` to list options.",
765765| `PROMPT` | `string | - (read stdin)` | Initial instruction for the task. Use `-` to pipe the prompt from stdin. | },
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 key: "--attempts",
768768Key type: "1-4",
769769 defaultValue: "1",
770770`--cd, -C` description:
771771 "Number of assistant attempts (best-of-N) Codex Cloud should run.",
772772Type / Values },
773773 ];
774774`path`
775775 export const cloudListOptions = [
776776Details {
777777 key: "--env",
778778Set the workspace root before executing the task. type: "ENV_ID",
779779 description: "Filter tasks by environment identifier.",
780780Key },
781781 {
782782`--color` key: "--limit",
783783 type: "1-20",
784784Type / Values defaultValue: "20",
785785 description: "Maximum number of tasks to return.",
786786`always | never | auto` },
787787 {
788788Details key: "--cursor",
789789 type: "string",
790790Control ANSI color in stdout. description: "Pagination cursor returned by a previous request.",
791791 },
792792Key {
793793 key: "--json",
794794`--dangerously-bypass-approvals-and-sandbox, --yolo` type: "boolean",
795795 defaultValue: "false",
796796Type / Values description: "Emit machine-readable JSON instead of plain text.",
797797 },
798798`boolean`];
799799
800800Detailsexport const mcpCommands = [
801801 {
802802Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner. key: "list",
803803 type: "--json",
804804Key description:
805 "List configured MCP servers. Add `--json` for machine-readable output.",
806 },
807 {
808 key: "get <name>",
809 type: "--json",
810 description:
811 "Show a specific server configuration. `--json` prints the raw config entry.",
812 },
813 {
814 key: "add <name>",
815 type: "-- <command...> | --url <value>",
816 description:
817 "Register a server using a stdio launcher command or a streamable HTTP URL. Supports `--env KEY=VALUE` for stdio transports.",
818 },
819 {
820 key: "remove <name>",
821 description: "Delete a stored MCP server definition.",
822 },
823 {
824 key: "login <name>",
825 type: "--scopes scope1,scope2",
826 description:
827 "Start an OAuth login for a streamable HTTP server (servers that support OAuth only).",
828 },
829 {
830 key: "logout <name>",
831 description:
832 "Remove stored OAuth credentials for a streamable HTTP server.",
833 },
834];
835
836export const mcpAddOptions = [
837 {
838 key: "COMMAND...",
839 type: "stdio transport",
840 description:
841 "Executable plus arguments to launch the MCP server. Provide after `--`.",
842 },
843 {
844 key: "--env KEY=VALUE",
845 type: "repeatable",
846 description:
847 "Environment variable assignments applied when launching a stdio server.",
848 },
849 {
850 key: "--url",
851 type: "https://…",
852 description:
853 "Register a streamable HTTP server instead of stdio. Mutually exclusive with `COMMAND...`.",
854 },
855 {
856 key: "--bearer-token-env-var",
857 type: "ENV_VAR",
858 description:
859 "Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server.",
860 },
861];
862
863export const marketplaceCommands = [
864 {
865 key: "add <source>",
866 type: "[--ref REF] [--sparse PATH]",
867 description:
868 "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.",
869 },
870 {
871 key: "upgrade [marketplace-name]",
872 description:
873 "Refresh one configured Git marketplace, or all configured Git marketplaces when no name is provided.",
874 },
875 {
876 key: "remove <marketplace-name>",
877 description: "Remove a configured plugin marketplace.",
878 },
879];
805 880
806881`--ephemeral`## How to read this reference
807
808Type / Values
809
810`boolean`
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 882
872883DetailsThis 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.
873 884
874885Use 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.
875 889
876890Key## Global flags
877 891
878892`--output-last-message, -o`<ConfigTable client:load options={globalFlagOptions} />
879 893
880894Type / 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.
881 896
882897`path`## Command overview
883 898
884899DetailsThe 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.
885 902
886903Write 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/>
887 909
888910Key## Command details
889 911
890912`--output-schema`### `codex` (interactive)
891 913
892914Type / 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`.
893 915
894916`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.
895 917
896918Details### `codex app-server`
897 919
898920JSON 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.
899 921
900922Key<ConfigTable client:load options={appServerOptions} />
901 923
902924`--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.
903 925
904926Type / Values### `codex remote-control`
905 927
906928`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.
907 932
908933Details### `codex app`
909 934
910935Select 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 936
912937Key<ConfigTable client:load options={appOptions} />
913 938
914939`--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.
915 942
916943Type / Values### `codex debug app-server send-message-v2`
917 944
918945`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 946
920947Details<ConfigTable client:load options={debugAppServerSendMessageV2Options} />
921 948
922949Sandbox 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 950
924951Key### `codex debug models`
925 952
926953`--skip-git-repo-check`Print the raw model catalog Codex sees as JSON.
927 954
928955Type / Values<ConfigTable client:load options={debugModelsOptions} />
929 956
930957`boolean`Use `--bundled` when you want to inspect only the catalog bundled with the current binary, without refreshing from the remote models endpoint.
931 958
932959Details### `codex apply`
933 960
934961Allow 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 962
936963Key<ConfigTable client:load options={applyOptions} />
937 964
938965`-c, --config`Codex prints the patched files and exits non-zero if `git apply` fails (for example, due to conflicts).
939 966
940967Type / Values### `codex cloud`
941 968
942969`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 970
944971Details<ConfigTable client:load options={cloudExecOptions} />
945 972
946973Inline 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 974
948975Key#### `codex cloud list`
949 976
950977`PROMPT`List recent cloud tasks with optional filtering and pagination.
951 978
952979Type / Values<ConfigTable client:load options={cloudListOptions} />
953 980
954981`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 982
956983Details### `codex completion`
957 984
958985Initial 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 986
960987Key<ConfigTable client:load options={completionOptions} />
961 988
962989`Resume subcommand`### `codex features`
963 990
964991Type / 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 992
966993`codex exec resume [SESSION_ID]`<ConfigTable client:load options={featuresOptions} />
967 994
968995Details### `codex exec`
969 996
970997Resume 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 998
972999Expand to view all<ConfigTable client:load options={execOptions} />
973 1000
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: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:
975 1002
9761003| 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 1004
1044### `codex execpolicy`1005### `codex execpolicy`
1045 1006
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.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.
1047 1008
10481009| 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 1010
1090### `codex login`1011### `codex login`
1091 1012
10921013Authenticate 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.
1093
1094| Key | Type / Values | Details |
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 1014
11221015Read an API key from stdin (for example `printenv OPENAI_API_KEY | codex login --with-api-key`).<ConfigTable client:load options={loginOptions} />
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 1016
1136`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.
1137 1018
1143 1024
1144Manage Model Context Protocol server entries stored in `~/.codex/config.toml`.1025Manage Model Context Protocol server entries stored in `~/.codex/config.toml`.
1145 1026
11461027| 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 1028
1219The `add` subcommand supports both stdio and streamable HTTP transports:1029The `add` subcommand supports both stdio and streamable HTTP transports:
1220 1030
12211031| 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 1032
12481033DetailsOAuth 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 1034
12701035`stdio transport`### `codex plugin marketplace`
1271 1036
12721037DetailsManage plugin marketplace sources that Codex can browse and install from.
1273 1038
12741039Executable plus arguments to launch the MCP server. Provide after `--`.<ConfigTable client:load options={marketplaceCommands} />
1275 1040
12761041OAuth 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.
1277 1045
1278### `codex mcp-server`1046### `codex mcp-server`
1279 1047
1283 1051
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.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.
1285 1053
12861054| 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 1055
1328### `codex fork`1056### `codex fork`
1329 1057
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.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.
1331 1059
13321060| 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 1061
1374### `codex sandbox`1062### `codex sandbox`
1375 1063
1377 1065
1378#### macOS seatbelt1066#### macOS seatbelt
1379 1067
13801068| 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 1069
1422#### Linux Landlock1070#### Linux Landlock
1423 1071
14241072| 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 1073
14581074Type / Values#### Windows
1459 1075
14601076`var-args`<ConfigTable client:load options={sandboxWindowsOptions} />
1461 1077
14621078Details### `codex update`
1463 1079
14641080Command 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 1081
1466## Flag combinations and safety tips1082## Flag combinations and safety tips
1467 1083
14681084- 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`.1085- 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.1086- Pair `--json` with `--output-last-message` in CI to capture machine-readable progress and a final natural-language summary.
1471 1087