CDX-101 · Module 5
Complete Command & Slash Command Reference
12 min read
This lesson is a comprehensive reference for every Codex CLI flag, configuration key, and slash command. Bookmark it and return as needed — this is not meant to be memorized, but to be consulted when you need the exact syntax or option name.
CLI Flags — Launch Options
These flags are passed when starting Codex from the terminal. They control the session's initial configuration.
codex [prompt] Start interactive session (optional initial prompt)
codex --suggest [prompt] Suggest mode — ask permission for everything (default)
codex --auto-edit [prompt] Auto-edit mode — auto-apply file edits, ask for commands
codex --full-auto [prompt] Full-auto mode — execute everything without asking
codex exec [prompt] One-shot execution — run task and exit
codex resume Resume the most recent session
codex fork Fork from a previous session into a new one
codex cloud [prompt] Delegate task to a Codex Cloud sandbox
codex cloud exec [prompt] One-shot cloud execution
codex cloud status Check status of cloud tasks
codex cloud diff <id> View diff from a cloud task
codex review --base <branch> Code review against a base branch
codex review --json Output review results as JSON
codex mcp list List installed MCP servers
codex mcp add <name> <cmd> Add an MCP server
codex mcp remove <name> Remove an MCP server
codex features list List feature flags
codex features enable <flag> Enable a feature flag
codex features disable <flag> Disable a feature flag
codex --login Authenticate via ChatGPT OAuth
codex --model <model> Set model for the session
codex --reasoning-effort <lvl> Set reasoning effort (low/medium/high/xhigh)
codex -i <path> Attach an image file for multimodal input
codex --mcp-server Run Codex as an MCP server
codex --version Print version
Slash Commands — In-Session Actions
These commands are typed inside an active Codex session. They control the session state and trigger built-in workflows.
/model [name] Switch model mid-session (e.g., /model o3)
/plan Enter plan mode — analyze and propose before executing
/compact Compress context — summarize conversation history
/diff Show the current diff of all uncommitted changes
/review [file] Review current changes or a specific file for issues
/mention <file> Add a file to context without modifying it
/copy Copy the last response to clipboard
/clear Clear conversation history and start fresh
/fork Branch into a new session from the current point
/status Show session info: model, tokens used, approval mode
/help Show all available commands and shortcuts
Approval Modes
The three approval modes control Codex's autonomy level. Choose based on trust and task risk.
suggest (default) Ask permission for file edits AND shell commands
Safest mode. You see every change before it happens.
Best for: unfamiliar codebases, high-risk changes, learning.
auto-edit Auto-apply file edits, ask permission for shell commands
Good balance of speed and safety.
Best for: routine coding in a familiar codebase.
full-auto Execute everything without asking
Maximum speed, requires trust in the sandbox.
Best for: well-scoped tasks with clean git state.
Sandbox Settings
Sandbox configuration controls what Codex can access at the OS level.
Sandbox Mode Description
─────────────────────────────────────────────────────────────
workspace-write Can write to project directory only (default)
read-only Can only read files, no writes allowed
no-sandbox Disable sandbox entirely (not recommended)
Execpolicy Rules (in config.toml)
─────────────────────────────────────────────────────────────
"command" = "allow" Allow the command in sandbox
"command" = "allow-network" Allow with network access
"command" = "deny" Block the command entirely
config.toml Reference
The configuration file lives at ~/.codex/config.toml and controls default behavior.
# Model defaults
[profile.default]
model = "codex-1" # Default model
approval = "suggest" # Default approval mode
reasoning_effort = "medium" # For o-series models
# Project-doc size limit
project_doc_max_bytes = 100000 # Max AGENTS.md size before truncation
# MCP servers
[mcp.github]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-github"]
env = { GITHUB_TOKEN = "ghp_..." }
# Sub-agent definitions
[agents.test-writer]
model = "gpt-4.1"
description = "Writes test suites"
# Exec policy
[execpolicy]
"npm install" = "allow-network"
"git *" = "allow-network"
"curl *" = "allow-network"