OpenAI Codex has grown from a simple terminal coding assistant into a full workflow tool with terminal UI commands, desktop-app commands, IDE commands, cloud tasks, MCP support, plugins, custom prompts, skills, and automation-friendly CLI flags. This guide explains what appears when you type / inside Codex, what each command does, and which related codex terminal options are worth knowing.
1. What happens when you type / in Codex?
In the Codex CLI, typing / in the composer opens the slash-command popup. You can keep typing to filter commands. If Codex is already running a task, you can type a slash command and press Tab to queue it for the next turn. (OpenAI Developers)
Slash commands are not the same as shell commands. They control the Codex session itself: model selection, approvals, review mode, conversation reset, session status, MCP tools, plugins, agent threads, and more.
2. Master list: Codex CLI slash commands
| Command | Purpose | Best use case |
|---|---|---|
/permissions | Change what Codex can do without asking first. | Switch between safer and more autonomous modes mid-session. |
/sandbox-add-read-dir | Add sandbox read access to another directory. | Windows-only; useful when Codex needs to read an absolute path outside current roots. |
/agent | Switch active agent thread. | Inspect or continue work in a spawned subagent thread. |
/apps | Browse apps/connectors and insert them into the prompt. | Attach an app as $app-slug before asking Codex to use it. |
/plugins | Browse installed and discoverable plugins. | Inspect, install, or manage plugin tools. |
/clear | Clear terminal and start a fresh chat. | Reset the visible UI and conversation together. |
/compact | Summarize the visible conversation to free context. | Use during long sessions to preserve essentials while reducing context usage. |
/copy | Copy the latest completed Codex output. | Grab the latest finished answer or plan; Ctrl+O also works. |
/diff | Show Git diff, including untracked files. | Review Codex’s local edits before committing. |
/exit | Exit the CLI. | Same as /quit. |
/experimental | Toggle experimental features. | Enable optional workflows such as subagents where available. |
/feedback | Send feedback/logs to Codex maintainers. | Report issues or diagnostics. |
/init | Generate an AGENTS.md scaffold. | Create persistent repository instructions for Codex. |
/logout | Sign out of Codex. | Clear local credentials on a shared machine. |
/mcp | List configured MCP tools. | Check which external MCP tools Codex can call. |
/mention | Attach a file or folder to the conversation. | Point Codex at specific code or context. |
/model | Choose active model and reasoning effort where available. | Switch models before a task. |
/fast | Toggle/check Fast mode for supported models. | Use when speed matters more than deeper reasoning. |
/plan | Switch to plan mode, optionally with a prompt. | Ask Codex for a plan before implementation. |
/personality | Choose response style. | Pick friendly, pragmatic, or none. |
/ps | Show experimental background terminals and recent output. | Check long-running background work. |
/stop | Stop all background terminals. | Cancel background commands from the session. |
/fork | Fork the current conversation into a new thread. | Explore another approach without losing the original thread. |
/resume | Resume a saved conversation. | Continue a previous CLI session. |
/new | Start a new conversation in the same CLI session. | Reset chat context without quitting Codex. |
/quit | Exit the CLI. | Same as /exit. |
/review | Ask Codex to review the working tree. | Review local changes before commit or PR. |
/status | Show session configuration and token usage. | Confirm model, approvals, writable roots, and context capacity. |
/debug-config | Print config layer and requirements diagnostics. | Debug config precedence and policy requirements. |
/statusline | Configure TUI status-line fields. | Choose footer items such as model, context, git, tokens, limits, session. |
/title | Configure terminal window/tab title fields. | Customize title fields such as project, branch, model, task progress. |
/theme | Preview and save a TUI theme. | Documented in the CLI features guide; may depend on version/build. |
The official slash-command page also notes that /approvals still works as an alias, but it no longer appears in the slash popup list. (OpenAI Developers) The CLI features page separately documents /theme for previewing and saving a preferred theme. (OpenAI Developers)
3. Commands you may see outside CLI: Codex app and IDE
The Codex desktop app has a smaller slash list, and OpenAI notes that available commands vary by environment and access. The documented app slash commands are /feedback, /mcp, /plan-mode, /review, and /status; enabled skills can also appear in the slash list, and skills can be explicitly invoked with $. (OpenAI Developers)
The Codex IDE extension has its own slash-command set: /auto-context, /cloud, /cloud-environment, /feedback, /local, /review, and /status. These are aimed at switching between local/cloud execution, selecting cloud environments, controlling automatic context, and reviewing code from inside the IDE. (OpenAI Developers)
4. Custom slash commands: /prompts:name
Codex also supports custom prompt commands, but OpenAI now marks custom prompts as deprecated and recommends skills for reusable instructions. Existing custom prompts still let you create Markdown files under ~/.codex/prompts and invoke them from the slash menu, for example /prompts:draftpr. Custom prompt files can include YAML front matter such as description and argument-hint, plus placeholders like $1, $ARGUMENTS, $FILE, or $TICKET_ID. (OpenAI Developers)
Example:
mkdir -p ~/.codex/prompts
Create:
~/.codex/prompts/draftpr.md
Example command after restart:
/prompts:draftpr FILES="src/app.ts src/api.ts" PR_TITLE="Add API loading state"
Codex expands the prompt file, replaces placeholders, and sends the expanded instruction into the current session.
5. Most useful slash-command workflows
Switch model before a difficult task
Use:
/model
Pick a stronger reasoning model for complex architecture, debugging, or refactoring. Then run:
/status
to verify the active model and session settings. (OpenAI Developers)
Ask for a plan before coding
Use:
/plan
Or inline:
/plan Propose a migration plan for this service
This is best before multi-file changes, migrations, refactors, or anything that may require review before implementation. (OpenAI Developers)
Review changes before committing
Use:
/diff
Then:
/review
/diff shows the local Git diff, while /review asks a dedicated Codex reviewer to inspect the working tree and return prioritized findings. (OpenAI Developers)
Recover context in long sessions
Use:
/compact
This summarizes the visible conversation to free context while preserving the key decisions and instructions. Use it before a long follow-up task rather than waiting until the session feels overloaded. (OpenAI Developers)
Start fresh without quitting
Use:
/clear
This is different from Ctrl+L: /clear starts a new conversation, while Ctrl+L only clears the terminal view. (OpenAI Developers)
6. Master list: important codex CLI flags
The base codex command accepts global flags, and most defaults come from ~/.codex/config.toml. Command-line -c key=value overrides take precedence for that invocation. (OpenAI Developers)
| Flag | Meaning |
|---|---|
--add-dir path | Grant additional directories write access alongside the main workspace. |
--ask-for-approval, -a untrusted|on-request|never | Control when Codex pauses for approval. |
--cd, -C path | Set working directory before Codex starts. |
--config, -c key=value | Override config values for this run. |
--dangerously-bypass-approvals-and-sandbox, --yolo | Run without approvals or sandboxing; use only in hardened environments. |
--disable feature | Force-disable a feature flag. |
--enable feature | Force-enable a feature flag. |
--full-auto | Low-friction preset using on-request approvals and workspace-write sandbox. |
--image, -i path[,path...] | Attach one or more image files to the initial prompt. |
--model, -m string | Override configured model. |
--no-alt-screen | Disable alternate-screen mode for the TUI. |
--oss | Use the local open-source model provider; requires Ollama. |
--profile, -p string | Load a named config profile. |
--remote ws://host:port or wss://host:port | Connect TUI to a remote app-server endpoint. |
--remote-auth-token-env ENV_VAR | Send bearer token from an environment variable for remote mode. |
--sandbox, -s read-only|workspace-write|danger-full-access | Select sandbox policy. |
--search | Enable live web search instead of cached web search. |
PROMPT | Start Codex with an initial instruction. |
Example:
codex --cd apps/frontend --model gpt-5.4 --sandbox workspace-write "Review this app structure"
7. Master list: codex subcommands
| Command | Status | Purpose |
|---|---|---|
codex | Stable | Launch the interactive terminal UI. |
codex app | Stable | Launch Codex desktop app on macOS or Windows. |
codex app-server | Experimental | Launch local Codex app server for development/debugging. |
codex apply / codex a | Stable | Apply the latest diff from a Codex Cloud task. |
codex cloud / codex cloud-tasks | Experimental | Browse or execute Codex Cloud tasks from terminal. |
codex completion | Stable | Generate shell completions. |
codex debug app-server send-message-v2 | Experimental | Debug app-server by sending one V2 message. |
codex exec / codex e | Stable | Run Codex non-interactively for scripts/CI. |
codex execpolicy | Experimental | Evaluate execpolicy rules. |
codex features | Stable | List, enable, or disable feature flags. |
codex fork | Stable | Fork a previous interactive session. |
codex login | Stable | Authenticate with ChatGPT OAuth, device auth, or API key. |
codex logout | Stable | Remove saved credentials. |
codex mcp | Experimental | Manage MCP servers. |
codex mcp-server | Experimental | Run Codex itself as an MCP server over stdio. |
codex plugin marketplace | Experimental | Add, upgrade, or remove plugin marketplaces. |
codex resume | Stable | Resume an earlier interactive session. |
codex sandbox | Experimental | Run commands inside Codex-provided sandboxes. |
OpenAI’s command reference says the maturity labels help distinguish Stable from Experimental/Beta functionality, and the command reference catalogs the documented commands and flags. (OpenAI Developers)
8. Non-interactive automation with codex exec
For CI-style or scripted usage, use:
codex exec "Find and fix failing tests"
Useful options include:
| Option | Purpose |
|---|---|
--json / --experimental-json | Output newline-delimited JSON events. |
--output-last-message, -o path | Write final assistant message to a file. |
--output-schema path | Validate final response against a JSON schema. |
--ephemeral | Avoid persisting session rollout files. |
--skip-git-repo-check | Allow running outside a Git repo. |
codex exec resume [SESSION_ID] | Resume a previous non-interactive session. |
--last | Resume most recent session. |
--all | Search sessions outside current working directory. |
OpenAI documents codex exec as the automation-friendly command and notes that it can stream formatted text or JSONL and resume previous sessions. (OpenAI Developers)
9. Cloud task commands
Codex Cloud can be controlled from the terminal:
codex cloud
Start a task directly:
codex cloud exec --env ENV_ID --attempts 3 "Summarize open bugs"
List recent tasks:
codex cloud list --env ENV_ID --limit 10 --json
Key options:
| Option | Purpose |
|---|---|
--env ENV_ID | Target cloud environment. |
--attempts 1-4 | Run best-of-N attempts. |
--limit 1-20 | Limit task list output. |
--cursor string | Paginate cloud task list. |
--json | Emit machine-readable JSON. |
The CLI features page says codex cloud opens an interactive task picker, while codex cloud exec submits a cloud task directly. (OpenAI Developers)
10. MCP commands
Codex can manage Model Context Protocol servers through:
codex mcp
Common commands:
| Command | Purpose |
|---|---|
codex mcp list | List configured MCP servers. |
codex mcp list --json | List servers as JSON. |
codex mcp get <name> | Show one server config. |
codex mcp add <name> -- <command...> | Add a stdio MCP server. |
codex mcp add <name> --url <value> | Add a streamable HTTP MCP server. |
codex mcp login <name> | Start OAuth login for supported HTTP servers. |
codex mcp logout <name> | Remove OAuth credentials. |
codex mcp remove <name> | Delete stored MCP server definition. |
codex mcp-server is separate: it runs Codex itself as an MCP server over stdio so another tool can connect to Codex. (OpenAI Developers)
11. Resume, fork, and session management
Use:
codex resume
codex resume --last
codex resume --all
codex resume <SESSION_ID>
Use:
codex fork
codex fork --last
codex fork <SESSION_ID>
resume continues a saved conversation; fork branches a previous session into a new thread while preserving the original transcript. (OpenAI Developers)
12. Suggested beginner workflow
For daily coding:
codex --cd path/to/repo
Inside Codex:
/status
/model
/plan
/diff
/review
/compact
For automation:
codex exec --cd path/to/repo --json "Run tests and summarize failures"
For safer work, prefer read-only or workspace-write sandboxing. Use danger-full-access, --yolo, or approval bypassing only in isolated environments because OpenAI explicitly warns those modes bypass approval and sandbox protections. (OpenAI Developers)
13. Final cheat sheet
Use /model before complex tasks.
Use /plan before multi-file edits.
Use /diff and /review before commits.
Use /compact during long sessions.
Use /clear to start a new chat without quitting.
Use /status whenever you are unsure what model, permissions, or context state you are in.
Use codex exec for scripting and CI.
Use codex cloud for remote cloud tasks.
Use codex mcp when Codex needs external tools.
Use skills instead of deprecated custom prompts for reusable workflows where possible.