OpenAI Codex CLI Commands

Complete OpenAI Codex CLI commands reference — 172 commands across 16 categories. Quick reference cheat sheet for Cross-platform.

Global Flags (20)

ShortcutAction
--add-dirGrant additional directories write access alongside the main workspace. Repeat for multiple
--ask-for-approval, -aControl when Codex pauses for human approval before running a command
--cd, -CSet the working directory for the agent before it starts processing your request
--config, -cOverride configuration values. Values parse as TOML if possible; otherwise the literal string
--dangerously-bypass-approvals-and-sandbox, --yoloRun every command without approvals or sandboxing. Only use inside an externally hardened
--dangerously-bypass-hook-trustRun enabled hooks without requiring persisted hook trust for this invocation. Intended only
--disableForce-disable a feature flag (translates to -c features.<name>=false). Repeatable
--enableForce-enable a feature flag (translates to -c features.<name>=true). Repeatable
--image, -iAttach one or more image files to the initial prompt. Separate multiple paths with commas
--local-providerChoose the local provider used with --oss, overriding oss_provider for this run
--model, -mOverride the model set in configuration (for example gpt-5.4)
--no-alt-screenDisable alternate screen mode for the TUI (overrides tui.alternate_screen for this run)
--ossUse a local open source model provider. Codex uses --local-provider, your configured
--profile, -pLayer $CODEX_HOME/profile-name.config.toml on top of the base user config
--remoteConnect to a remote app-server endpoint over WebSocket or a Unix socket. Supported for codex
--remote-auth-token-envRead a bearer token from this environment variable and send it when connecting with --remote.
--sandbox, -sSelect the sandbox policy for model-generated shell commands
--searchEnable live web search (sets web_search = "live" instead of the default "cached")
--strict-configError when config.toml contains fields this Codex version does not recognize. Supported
PROMPTOptional text instruction to start the session. Omit to launch the TUI without a pre-filled

Commands (28)

ShortcutAction
codexLaunch the terminal UI. Accepts the global flags above plus an optional prompt or image
codex appLaunch the ChatGPT desktop app on macOS or Windows. On macOS, Codex can open a workspace path
codex app-serverLaunch the Codex app server for local development or debugging over stdio, WebSocket, or a Unix
codex applyApply the latest diff generated by a Codex cloud chat to your local working tree. Alias: codex
codex archiveArchive a saved interactive session by session ID or session name
codex cloudBrowse or execute Codex cloud chats from the terminal without opening the TUI. Alias: codex
codex completionGenerate shell completion scripts for Bash, Zsh, Fish, or PowerShell
codex debug app-server send-message-v2Debug app-server by sending a single V2 message through the built-in test client
codex debug modelsPrint the raw model catalog Codex sees, including an option to inspect only the bundled catalog
codex debug prompt-inputRender the model-visible prompt input list as JSON, optionally with a prompt and images
codex deletePermanently delete a saved interactive session by session ID or session name
codex doctorGenerate a diagnostic report for local installation, config, auth, runtime, Git, terminal
codex execRun Codex non-interactively. Alias: codex e. Stream results to stdout or JSONL and optionally
codex execpolicyEvaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked
codex featuresList feature flags and persistently enable or disable them in config.toml
codex forkFork a previous interactive session into a new chat, preserving the original transcript
codex loginAuthenticate Codex using ChatGPT OAuth, device auth, an API key, or an access token piped over
codex logoutRemove stored authentication credentials
codex mcpManage Model Context Protocol servers (list, add, remove, authenticate)
codex mcp-serverRun Codex itself as an MCP server over stdio. Useful when another agent consumes Codex
codex pluginInstall, list, and remove plugins from configured marketplace sources
codex plugin marketplaceAdd, list, upgrade, or remove plugin marketplaces from Git or local sources
codex remote-controlRun or manage remote control for the local app-server, or create a short-lived pairing code
codex resumeContinue a previous interactive session by ID or resume the most recent chat
codex reviewRun a non-interactive review of uncommitted changes, a base branch diff, a commit, or custom
codex sandboxRun arbitrary commands inside Codex-provided macOS, Linux, or Windows sandboxes
codex unarchiveRestore an archived interactive session by session ID or session name
codex updateCheck for and apply a Codex CLI update when the installed release supports self-update

codex app-server (10)

ShortcutAction
--analytics-default-enabledDefaults analytics to enabled for first-party app-server clients unless the user opts out
--listenTransport listener URL. Use stdio:// for JSONL, ws://IP:PORT for a TCP WebSocket endpoint
--stdioUse stdio transport. Equivalent to --listen stdio:// and mutually exclusive with --listen
--ws-audienceExpected aud claim for signed bearer tokens. Requires --ws-auth signed-bearer-token
--ws-authAuthentication mode for app-server WebSocket clients. If omitted, WebSocket auth is disabled
--ws-issuerExpected iss claim for signed bearer tokens. Requires --ws-auth signed-bearer-token
--ws-max-clock-skew-secondsClock skew allowance when validating signed bearer token exp and nbf claims. Requires --ws-auth
--ws-shared-secret-fileFile containing the HMAC shared secret used to validate signed JWT bearer tokens. Required
--ws-token-fileFile containing the shared capability token. Use with --ws-auth capability-token unless you
--ws-token-sha256Expected SHA-256 digest for capability-token authentication. Use instead of --ws-token-file

codex app (2)

ShortcutAction
--download-urlAdvanced override for the ChatGPT desktop app installer URL used during install
PATHWorkspace path for the ChatGPT desktop app. On macOS, Codex opens this path; on Windows, Codex

codex review (4)

ShortcutAction
--baseReview changes against the specified base branch
--commitReview the changes introduced by the specified commit
--titleSet the commit title shown in the review summary. Requires --commit
--uncommittedReview staged, unstaged, and untracked changes

codex cloud (3)

ShortcutAction
--attemptsNumber of assistant attempts (best-of-N) Codex cloud should run
--envTarget Codex cloud environment identifier (required). Use codex cloud to list options
QUERYTask prompt. If omitted, Codex prompts interactively for details

codex cloud list (3)

ShortcutAction
--cursorPagination cursor returned by a previous request
--jsonEmit machine-readable JSON instead of plain text
--limitMaximum number of tasks to return

codex doctor (4)

ShortcutAction
--allExpand long lists in the detailed human-readable report
--asciiUse ASCII status labels and separators in human-readable output
--no-colorDisable ANSI color in human-readable output
--summaryShow grouped check rows and the final count summary only

codex exec (12)

ShortcutAction
--colorControl ANSI color in stdout
--ephemeralRun without persisting session rollout files to disk
--full-autoDeprecated compatibility flag. Prefer --sandbox workspace-write; Codex prints a warning when
--ignore-rulesDo not load user or project execpolicy .rules files for this run
--ignore-user-configDo not load $CODEX_HOME/config.toml. Authentication still uses CODEX_HOME
--json, --experimental-jsonPrint newline-delimited JSON events instead of formatted text
--output-last-message, -oWrite the assistant's final message to a file. Useful for downstream scripting
--output-schemaJSON Schema file describing the expected final response shape. Codex validates tool output
--skip-git-repo-checkAllow running outside a Git repository (useful for one-off directories)
-c, --configInline configuration override for the non-interactive run (repeatable)
--lastResume the most recent chat from the current working directory
SESSION_IDResume the specified session. Omit and use --last to continue the most recent session

codex execpolicy (3)

ShortcutAction
--prettyPretty-print the JSON result
--rules, -rPath to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across
COMMAND...Command to be checked against the specified policies

codex login (3)

ShortcutAction
--device-authUse OAuth device code flow instead of launching a browser window
--with-access-tokenRead an access token from stdin
--with-api-keyRead an API key from stdin (for example printenv OPENAI_API_KEY | codex login --with-api-key)

codex mcp (6)

ShortcutAction
listList configured MCP servers. Add --json for machine-readable output
--bearer-token-env-varEnvironment variable whose value is sent as a bearer token when connecting to a streamable HTTP
--env KEY=VALUEEnvironment variable assignments applied when launching a stdio server
--oauth-client-idOAuth client identifier for a streamable HTTP MCP server. Requires --url
--oauth-resourceOAuth resource parameter to include during login for a streamable HTTP MCP server. Requires
--urlRegister a streamable HTTP server instead of stdio. Mutually exclusive with COMMAND

Sandbox (4)

ShortcutAction
--allow-unix-socketAllow the sandboxed command to bind or connect Unix sockets rooted at this path. Repeat
--include-managed-configInclude managed requirements while resolving an explicit permissions profile. Requires
--log-denialsCapture macOS sandbox denials with log stream while the command runs and print them after exit
--permission-profile, -PApply a named permissions profile from the active configuration stack

Slash Commands (58)

ShortcutAction
/permissionsRelax or tighten approval requirements mid-session, such as switching between Auto and Read
/idePull editor context into the next prompt without re-explaining what's open in your IDE
/keymapInspect and persist custom shortcut bindings in config.toml
/vimSwitch between Vim normal/insert behavior and the default composer editing mode
/setup-default-sandboxReplace the degraded Windows sandbox after Codex offers the elevated setup
/sandbox-add-read-dirUnblock commands that need to read an absolute directory path outside the current readable
/agent, /subagentsInspect or continue work in a spawned subagent thread
/appsAttach an app as $app-slug before asking Codex to use it
/pluginsInspect plugin tools, install suggested plugins, or manage plugin availability
/hooksInspect configured hooks, trust new or changed hooks, or disable non-managed hooks before they
/clearReset the visible UI and chat context together when you want a fresh start
/renameGive a saved session a recognizable name without leaving the TUI
/archiveRemove the current session from active session lists without deleting its transcript
/deleteRemove the transcript and descendant sessions when archiving isn't enough
/compactUse after long runs so Codex retains key points without blowing the context window
/copyGrab the latest finished response or plan text without manually selecting it. You can also
/diffReview Codex's edits before you commit or run tests
/exitAlternative spelling; both commands exit the session
/experimentalEnable options such as Network proxy or Prevent sleep while running
/approveRetry a command or action that the auto reviewer denied
/memoriesTurn memory injection or memory generation on or off without leaving the TUI
/skillsImprove task-specific behavior by selecting a relevant local skill
/importMigrate supported external-agent artifacts into Codex configuration and local files
/feedbackReport issues or share diagnostics with support
/initCapture persistent instructions for the repository or subdirectory you're working
/logoutClear local credentials when using a shared machine
/mcpCheck which external tools Codex can call during the session; add verbose for server details
/mentionPoint Codex at specific files or folders you want it to inspect next
/modelSwitch between models such as gpt-5.4-mini and gpt-5.5 before running a task
/fastTurn the current model's Fast tier on or off and persist the selection
/planAsk Codex to propose an execution plan before implementation work starts
/goalGive Codex a persistent target to track while a larger task runs
/personalityMake Codex more concise, more explanatory, or more collaborative without changing your
/psCheck long-running commands without leaving the main transcript
/stopCancel background terminal work started by the current session
/forkBranch the active session to explore a new approach without losing the current transcript
/appMove from the TUI to the desktop app on macOS or Windows
/side, /btwAsk a focused follow-up without disrupting the main chat's transcript
/rawMake terminal selection and copying less formatted while reviewing long output
/resumeContinue work from a previous CLI session without starting over
/newReset the chat context without leaving the CLI when you want a fresh prompt in the same repo
/quitLeave the session immediately
/reviewRun after Codex completes work or when you want a second set of eyes on local changes
/statusConfirm the active model, approval policy, writable roots, and remaining context capacity
/usageInspect daily, weekly, or cumulative ChatGPT token activity from inside the TUI
/debug-configDebug precedence and policy requirements, including experimental network constraints
/statuslinePick and reorder footer items (model/context/limits/git/tokens/session) and persist
/titlePick and reorder title items such as project, status, thread, branch, model, and task progress
/themePreview and persist a terminal syntax-highlighting theme
/pets, /petPersonalize the TUI with a built-in or custom ambient pet
/cloudRun the chat in the cloud, when cloud execution is available
/cloud-environmentChoose the cloud environment for the chat
/ide-contextTurn automatic IDE context on or off
/localRun the chat in your local workspace
/projectChoose a project for new chats
/reasoningChoose the reasoning effort for the current chat
/sideStart a temporary side chat without interrupting the main chat
/worktreeRun the chat in a new Git worktree

Extension Commands (6)

ShortcutAction
chatgpt.addToThreadAdd selected text range as context for the current chat
chatgpt.addFileToThreadAdd the entire file as context for the current chat
chatgpt.newChatCreate a new chat
chatgpt.newCodexPanelCreate a new Codex panel
chatgpt.openCommandMenuOpen the Codex command menu
chatgpt.openSidebarOpen the Codex sidebar panel

Additional Commands (6)

ShortcutAction
EscStop response
Up / DownBrowse history
TabAutocomplete
Ctrl + CCancel
Ctrl + LClear screen
Ctrl + DExit
📄 View Printable Cheat Sheet — Download as PDF or print · 🧩 Combine with other tools

Related Shortcut Pages

Claude Code Aider Cursor AI GitHub Copilot Gemini CLI Warp Terminal

Search 13,500+ shortcuts across 269 platforms

Explore All Platforms Practice Shortcuts

🤖 Ask AI about OpenAI Codex CLI shortcuts

Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"

ChatGPT Claude Perplexity Gemini Grok
📜 Every shortcut on this page is taken from the official OpenAI Codex CLI documentation — developers.openai.com
🔧 Spotted an error or a missing shortcut? Suggest an edit on GitHub — every accepted fix goes live on this page, the API and the CLI.