Complete OpenAI Codex CLI commands reference — 172 commands across 16 categories. Quick reference cheat sheet for Cross-platform.
| Shortcut | Action |
|---|---|
| --add-dir | Grant additional directories write access alongside the main workspace. Repeat for multiple |
| --ask-for-approval, -a | Control when Codex pauses for human approval before running a command |
| --cd, -C | Set the working directory for the agent before it starts processing your request |
| --config, -c | Override configuration values. Values parse as TOML if possible; otherwise the literal string |
| --dangerously-bypass-approvals-and-sandbox, --yolo | Run every command without approvals or sandboxing. Only use inside an externally hardened |
| --dangerously-bypass-hook-trust | Run enabled hooks without requiring persisted hook trust for this invocation. Intended only |
| --disable | Force-disable a feature flag (translates to -c features.<name>=false). Repeatable |
| --enable | Force-enable a feature flag (translates to -c features.<name>=true). Repeatable |
| --image, -i | Attach one or more image files to the initial prompt. Separate multiple paths with commas |
| --local-provider | Choose the local provider used with --oss, overriding oss_provider for this run |
| --model, -m | Override the model set in configuration (for example gpt-5.4) |
| --no-alt-screen | Disable alternate screen mode for the TUI (overrides tui.alternate_screen for this run) |
| --oss | Use a local open source model provider. Codex uses --local-provider, your configured |
| --profile, -p | Layer $CODEX_HOME/profile-name.config.toml on top of the base user config |
| --remote | Connect to a remote app-server endpoint over WebSocket or a Unix socket. Supported for codex |
| --remote-auth-token-env | Read a bearer token from this environment variable and send it when connecting with --remote. |
| --sandbox, -s | Select the sandbox policy for model-generated shell commands |
| --search | Enable live web search (sets web_search = "live" instead of the default "cached") |
| --strict-config | Error when config.toml contains fields this Codex version does not recognize. Supported |
| PROMPT | Optional text instruction to start the session. Omit to launch the TUI without a pre-filled |
| Shortcut | Action |
|---|---|
| codex | Launch the terminal UI. Accepts the global flags above plus an optional prompt or image |
| codex app | Launch the ChatGPT desktop app on macOS or Windows. On macOS, Codex can open a workspace path |
| codex app-server | Launch the Codex app server for local development or debugging over stdio, WebSocket, or a Unix |
| codex apply | Apply the latest diff generated by a Codex cloud chat to your local working tree. Alias: codex |
| codex archive | Archive a saved interactive session by session ID or session name |
| codex cloud | Browse or execute Codex cloud chats from the terminal without opening the TUI. Alias: codex |
| codex completion | Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell |
| codex debug app-server send-message-v2 | Debug app-server by sending a single V2 message through the built-in test client |
| codex debug models | Print the raw model catalog Codex sees, including an option to inspect only the bundled catalog |
| codex debug prompt-input | Render the model-visible prompt input list as JSON, optionally with a prompt and images |
| codex delete | Permanently delete a saved interactive session by session ID or session name |
| codex doctor | Generate a diagnostic report for local installation, config, auth, runtime, Git, terminal |
| codex exec | Run Codex non-interactively. Alias: codex e. Stream results to stdout or JSONL and optionally |
| codex execpolicy | Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked |
| codex features | List feature flags and persistently enable or disable them in config.toml |
| codex fork | Fork a previous interactive session into a new chat, preserving the original transcript |
| codex login | Authenticate Codex using ChatGPT OAuth, device auth, an API key, or an access token piped over |
| codex logout | Remove stored authentication credentials |
| codex mcp | Manage Model Context Protocol servers (list, add, remove, authenticate) |
| codex mcp-server | Run Codex itself as an MCP server over stdio. Useful when another agent consumes Codex |
| codex plugin | Install, list, and remove plugins from configured marketplace sources |
| codex plugin marketplace | Add, list, upgrade, or remove plugin marketplaces from Git or local sources |
| codex remote-control | Run or manage remote control for the local app-server, or create a short-lived pairing code |
| codex resume | Continue a previous interactive session by ID or resume the most recent chat |
| codex review | Run a non-interactive review of uncommitted changes, a base branch diff, a commit, or custom |
| codex sandbox | Run arbitrary commands inside Codex-provided macOS, Linux, or Windows sandboxes |
| codex unarchive | Restore an archived interactive session by session ID or session name |
| codex update | Check for and apply a Codex CLI update when the installed release supports self-update |
| Shortcut | Action |
|---|---|
| --analytics-default-enabled | Defaults analytics to enabled for first-party app-server clients unless the user opts out |
| --listen | Transport listener URL. Use stdio:// for JSONL, ws://IP:PORT for a TCP WebSocket endpoint |
| --stdio | Use stdio transport. Equivalent to --listen stdio:// and mutually exclusive with --listen |
| --ws-audience | Expected aud claim for signed bearer tokens. Requires --ws-auth signed-bearer-token |
| --ws-auth | Authentication mode for app-server WebSocket clients. If omitted, WebSocket auth is disabled |
| --ws-issuer | Expected iss claim for signed bearer tokens. Requires --ws-auth signed-bearer-token |
| --ws-max-clock-skew-seconds | Clock skew allowance when validating signed bearer token exp and nbf claims. Requires --ws-auth |
| --ws-shared-secret-file | File containing the HMAC shared secret used to validate signed JWT bearer tokens. Required |
| --ws-token-file | File containing the shared capability token. Use with --ws-auth capability-token unless you |
| --ws-token-sha256 | Expected SHA-256 digest for capability-token authentication. Use instead of --ws-token-file |
| Shortcut | Action |
|---|---|
| --download-url | Advanced override for the ChatGPT desktop app installer URL used during install |
| PATH | Workspace path for the ChatGPT desktop app. On macOS, Codex opens this path; on Windows, Codex |
| Shortcut | Action |
|---|---|
| --base | Review changes against the specified base branch |
| --commit | Review the changes introduced by the specified commit |
| --title | Set the commit title shown in the review summary. Requires --commit |
| --uncommitted | Review staged, unstaged, and untracked changes |
| Shortcut | Action |
|---|---|
| --attempts | Number of assistant attempts (best-of-N) Codex cloud should run |
| --env | Target Codex cloud environment identifier (required). Use codex cloud to list options |
| QUERY | Task prompt. If omitted, Codex prompts interactively for details |
| Shortcut | Action |
|---|---|
| --cursor | Pagination cursor returned by a previous request |
| --json | Emit machine-readable JSON instead of plain text |
| --limit | Maximum number of tasks to return |
| Shortcut | Action |
|---|---|
| --all | Expand long lists in the detailed human-readable report |
| --ascii | Use ASCII status labels and separators in human-readable output |
| --no-color | Disable ANSI color in human-readable output |
| --summary | Show grouped check rows and the final count summary only |
| Shortcut | Action |
|---|---|
| --color | Control ANSI color in stdout |
| --ephemeral | Run without persisting session rollout files to disk |
| --full-auto | Deprecated compatibility flag. Prefer --sandbox workspace-write; Codex prints a warning when |
| --ignore-rules | Do not load user or project execpolicy .rules files for this run |
| --ignore-user-config | Do not load $CODEX_HOME/config.toml. Authentication still uses CODEX_HOME |
| --json, --experimental-json | Print newline-delimited JSON events instead of formatted text |
| --output-last-message, -o | Write the assistant's final message to a file. Useful for downstream scripting |
| --output-schema | JSON Schema file describing the expected final response shape. Codex validates tool output |
| --skip-git-repo-check | Allow running outside a Git repository (useful for one-off directories) |
| -c, --config | Inline configuration override for the non-interactive run (repeatable) |
| --last | Resume the most recent chat from the current working directory |
| SESSION_ID | Resume the specified session. Omit and use --last to continue the most recent session |
| Shortcut | Action |
|---|---|
| --pretty | Pretty-print the JSON result |
| --rules, -r | Path to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across |
| COMMAND... | Command to be checked against the specified policies |
| Shortcut | Action |
|---|---|
| --device-auth | Use OAuth device code flow instead of launching a browser window |
| --with-access-token | Read an access token from stdin |
| --with-api-key | Read an API key from stdin (for example printenv OPENAI_API_KEY | codex login --with-api-key) |
| Shortcut | Action |
|---|---|
| list | List configured MCP servers. Add --json for machine-readable output |
| --bearer-token-env-var | Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP |
| --env KEY=VALUE | Environment variable assignments applied when launching a stdio server |
| --oauth-client-id | OAuth client identifier for a streamable HTTP MCP server. Requires --url |
| --oauth-resource | OAuth resource parameter to include during login for a streamable HTTP MCP server. Requires |
| --url | Register a streamable HTTP server instead of stdio. Mutually exclusive with COMMAND |
| Shortcut | Action |
|---|---|
| --allow-unix-socket | Allow the sandboxed command to bind or connect Unix sockets rooted at this path. Repeat |
| --include-managed-config | Include managed requirements while resolving an explicit permissions profile. Requires |
| --log-denials | Capture macOS sandbox denials with log stream while the command runs and print them after exit |
| --permission-profile, -P | Apply a named permissions profile from the active configuration stack |
| Shortcut | Action |
|---|---|
| /permissions | Relax or tighten approval requirements mid-session, such as switching between Auto and Read |
| /ide | Pull editor context into the next prompt without re-explaining what's open in your IDE |
| /keymap | Inspect and persist custom shortcut bindings in config.toml |
| /vim | Switch between Vim normal/insert behavior and the default composer editing mode |
| /setup-default-sandbox | Replace the degraded Windows sandbox after Codex offers the elevated setup |
| /sandbox-add-read-dir | Unblock commands that need to read an absolute directory path outside the current readable |
| /agent, /subagents | Inspect or continue work in a spawned subagent thread |
| /apps | Attach an app as $app-slug before asking Codex to use it |
| /plugins | Inspect plugin tools, install suggested plugins, or manage plugin availability |
| /hooks | Inspect configured hooks, trust new or changed hooks, or disable non-managed hooks before they |
| /clear | Reset the visible UI and chat context together when you want a fresh start |
| /rename | Give a saved session a recognizable name without leaving the TUI |
| /archive | Remove the current session from active session lists without deleting its transcript |
| /delete | Remove the transcript and descendant sessions when archiving isn't enough |
| /compact | Use after long runs so Codex retains key points without blowing the context window |
| /copy | Grab the latest finished response or plan text without manually selecting it. You can also |
| /diff | Review Codex's edits before you commit or run tests |
| /exit | Alternative spelling; both commands exit the session |
| /experimental | Enable options such as Network proxy or Prevent sleep while running |
| /approve | Retry a command or action that the auto reviewer denied |
| /memories | Turn memory injection or memory generation on or off without leaving the TUI |
| /skills | Improve task-specific behavior by selecting a relevant local skill |
| /import | Migrate supported external-agent artifacts into Codex configuration and local files |
| /feedback | Report issues or share diagnostics with support |
| /init | Capture persistent instructions for the repository or subdirectory you're working |
| /logout | Clear local credentials when using a shared machine |
| /mcp | Check which external tools Codex can call during the session; add verbose for server details |
| /mention | Point Codex at specific files or folders you want it to inspect next |
| /model | Switch between models such as gpt-5.4-mini and gpt-5.5 before running a task |
| /fast | Turn the current model's Fast tier on or off and persist the selection |
| /plan | Ask Codex to propose an execution plan before implementation work starts |
| /goal | Give Codex a persistent target to track while a larger task runs |
| /personality | Make Codex more concise, more explanatory, or more collaborative without changing your |
| /ps | Check long-running commands without leaving the main transcript |
| /stop | Cancel background terminal work started by the current session |
| /fork | Branch the active session to explore a new approach without losing the current transcript |
| /app | Move from the TUI to the desktop app on macOS or Windows |
| /side, /btw | Ask a focused follow-up without disrupting the main chat's transcript |
| /raw | Make terminal selection and copying less formatted while reviewing long output |
| /resume | Continue work from a previous CLI session without starting over |
| /new | Reset the chat context without leaving the CLI when you want a fresh prompt in the same repo |
| /quit | Leave the session immediately |
| /review | Run after Codex completes work or when you want a second set of eyes on local changes |
| /status | Confirm the active model, approval policy, writable roots, and remaining context capacity |
| /usage | Inspect daily, weekly, or cumulative ChatGPT token activity from inside the TUI |
| /debug-config | Debug precedence and policy requirements, including experimental network constraints |
| /statusline | Pick and reorder footer items (model/context/limits/git/tokens/session) and persist |
| /title | Pick and reorder title items such as project, status, thread, branch, model, and task progress |
| /theme | Preview and persist a terminal syntax-highlighting theme |
| /pets, /pet | Personalize the TUI with a built-in or custom ambient pet |
| /cloud | Run the chat in the cloud, when cloud execution is available |
| /cloud-environment | Choose the cloud environment for the chat |
| /ide-context | Turn automatic IDE context on or off |
| /local | Run the chat in your local workspace |
| /project | Choose a project for new chats |
| /reasoning | Choose the reasoning effort for the current chat |
| /side | Start a temporary side chat without interrupting the main chat |
| /worktree | Run the chat in a new Git worktree |
| Shortcut | Action |
|---|---|
| chatgpt.addToThread | Add selected text range as context for the current chat |
| chatgpt.addFileToThread | Add the entire file as context for the current chat |
| chatgpt.newChat | Create a new chat |
| chatgpt.newCodexPanel | Create a new Codex panel |
| chatgpt.openCommandMenu | Open the Codex command menu |
| chatgpt.openSidebar | Open the Codex sidebar panel |
| Shortcut | Action |
|---|---|
| Esc | Stop response |
| Up / Down | Browse history |
| Tab | Autocomplete |
| Ctrl + C | Cancel |
| Ctrl + L | Clear screen |
| Ctrl + D | Exit |
Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"