Complete Codex / Slash Commands and CLI Options Guide — Updated April 2026

Uncategorized

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

CommandPurposeBest use case
/permissionsChange what Codex can do without asking first.Switch between safer and more autonomous modes mid-session.
/sandbox-add-read-dirAdd sandbox read access to another directory.Windows-only; useful when Codex needs to read an absolute path outside current roots.
/agentSwitch active agent thread.Inspect or continue work in a spawned subagent thread.
/appsBrowse apps/connectors and insert them into the prompt.Attach an app as $app-slug before asking Codex to use it.
/pluginsBrowse installed and discoverable plugins.Inspect, install, or manage plugin tools.
/clearClear terminal and start a fresh chat.Reset the visible UI and conversation together.
/compactSummarize the visible conversation to free context.Use during long sessions to preserve essentials while reducing context usage.
/copyCopy the latest completed Codex output.Grab the latest finished answer or plan; Ctrl+O also works.
/diffShow Git diff, including untracked files.Review Codex’s local edits before committing.
/exitExit the CLI.Same as /quit.
/experimentalToggle experimental features.Enable optional workflows such as subagents where available.
/feedbackSend feedback/logs to Codex maintainers.Report issues or diagnostics.
/initGenerate an AGENTS.md scaffold.Create persistent repository instructions for Codex.
/logoutSign out of Codex.Clear local credentials on a shared machine.
/mcpList configured MCP tools.Check which external MCP tools Codex can call.
/mentionAttach a file or folder to the conversation.Point Codex at specific code or context.
/modelChoose active model and reasoning effort where available.Switch models before a task.
/fastToggle/check Fast mode for supported models.Use when speed matters more than deeper reasoning.
/planSwitch to plan mode, optionally with a prompt.Ask Codex for a plan before implementation.
/personalityChoose response style.Pick friendly, pragmatic, or none.
/psShow experimental background terminals and recent output.Check long-running background work.
/stopStop all background terminals.Cancel background commands from the session.
/forkFork the current conversation into a new thread.Explore another approach without losing the original thread.
/resumeResume a saved conversation.Continue a previous CLI session.
/newStart a new conversation in the same CLI session.Reset chat context without quitting Codex.
/quitExit the CLI.Same as /exit.
/reviewAsk Codex to review the working tree.Review local changes before commit or PR.
/statusShow session configuration and token usage.Confirm model, approvals, writable roots, and context capacity.
/debug-configPrint config layer and requirements diagnostics.Debug config precedence and policy requirements.
/statuslineConfigure TUI status-line fields.Choose footer items such as model, context, git, tokens, limits, session.
/titleConfigure terminal window/tab title fields.Customize title fields such as project, branch, model, task progress.
/themePreview 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)

FlagMeaning
--add-dir pathGrant additional directories write access alongside the main workspace.
--ask-for-approval, -a untrusted|on-request|neverControl when Codex pauses for approval.
--cd, -C pathSet working directory before Codex starts.
--config, -c key=valueOverride config values for this run.
--dangerously-bypass-approvals-and-sandbox, --yoloRun without approvals or sandboxing; use only in hardened environments.
--disable featureForce-disable a feature flag.
--enable featureForce-enable a feature flag.
--full-autoLow-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 stringOverride configured model.
--no-alt-screenDisable alternate-screen mode for the TUI.
--ossUse the local open-source model provider; requires Ollama.
--profile, -p stringLoad a named config profile.
--remote ws://host:port or wss://host:portConnect TUI to a remote app-server endpoint.
--remote-auth-token-env ENV_VARSend bearer token from an environment variable for remote mode.
--sandbox, -s read-only|workspace-write|danger-full-accessSelect sandbox policy.
--searchEnable live web search instead of cached web search.
PROMPTStart 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

CommandStatusPurpose
codexStableLaunch the interactive terminal UI.
codex appStableLaunch Codex desktop app on macOS or Windows.
codex app-serverExperimentalLaunch local Codex app server for development/debugging.
codex apply / codex aStableApply the latest diff from a Codex Cloud task.
codex cloud / codex cloud-tasksExperimentalBrowse or execute Codex Cloud tasks from terminal.
codex completionStableGenerate shell completions.
codex debug app-server send-message-v2ExperimentalDebug app-server by sending one V2 message.
codex exec / codex eStableRun Codex non-interactively for scripts/CI.
codex execpolicyExperimentalEvaluate execpolicy rules.
codex featuresStableList, enable, or disable feature flags.
codex forkStableFork a previous interactive session.
codex loginStableAuthenticate with ChatGPT OAuth, device auth, or API key.
codex logoutStableRemove saved credentials.
codex mcpExperimentalManage MCP servers.
codex mcp-serverExperimentalRun Codex itself as an MCP server over stdio.
codex plugin marketplaceExperimentalAdd, upgrade, or remove plugin marketplaces.
codex resumeStableResume an earlier interactive session.
codex sandboxExperimentalRun 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:

OptionPurpose
--json / --experimental-jsonOutput newline-delimited JSON events.
--output-last-message, -o pathWrite final assistant message to a file.
--output-schema pathValidate final response against a JSON schema.
--ephemeralAvoid persisting session rollout files.
--skip-git-repo-checkAllow running outside a Git repo.
codex exec resume [SESSION_ID]Resume a previous non-interactive session.
--lastResume most recent session.
--allSearch 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:

OptionPurpose
--env ENV_IDTarget cloud environment.
--attempts 1-4Run best-of-N attempts.
--limit 1-20Limit task list output.
--cursor stringPaginate cloud task list.
--jsonEmit 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:

CommandPurpose
codex mcp listList configured MCP servers.
codex mcp list --jsonList 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.

Leave a Reply