Codex CLI Cheat Sheet

Codex CLI v0.118.0 Last updated: April 2, 2026
⌨️ Keyboard Shortcuts
General Controls
CtrlC Cancel input / interrupt
CtrlL Clear screen
CtrlG Open prompt in $EDITOR
EscEsc Undo last action
Navigate prompt history
While Running
Enter / Tab Approve pending action
Prefixes
@ File mention + autocomplete
! Direct shell command
/ Slash command
⚡ Slash Commands
Model & Mode
/model Switch model
/fast Toggle fast mode
/plan Plan mode (read-only)
/review Review current changes
/diff Show diff of changes
/permissions View/update permissions
/theme Change color theme
Session
/clear Clear conversation
/compact Compact context
/copy Copy last response
/status Show session status
/fork Fork session
/resume Resume session
/new New session
/exit Close interactive session
Project & Config
/init Create AGENTS.md
/mention Mention file/context
/agent Switch/manage agent
/apps Manage apps
/personality Set personality
/experimental Toggle experimental features
Tools & Misc
/mcp MCP server management
/ps List running processes
/statusline Toggle status line
/debug-config Debug configuration
/skills List available skills
/feedback Submit feedback
/logout Log out
🖥️ CLI Flags
Basic Usage
codex "prompt" Start with initial prompt
--model Set model (e.g. gpt-5.4)
-i <file> Attach image file(s)
Directory & Profile
--cd <dir> Change working directory
--add-dir <dir> Add additional directory
--profile <name> Use named profile
Search & Automation
--search Enable live web search
--full-auto Full auto-approval mode
Local & OSS
--oss Use open-source models
--local-provider Use local model provider
Feature Control
--enable <flag> Enable feature flag
--disable <flag> Disable feature flag
--config key=val Override config values
Session
-c Continue last session
--sandbox Set sandbox mode
--json JSON output format
🚀 Exec & Scripting
Exec Mode
codex exec "prompt" Non-interactive execution
codex e "prompt" Short alias for exec
--full-auto Skip all approval prompts
--sandbox Run in sandbox
cat f | codex exec Pipe stdin + promptNEW
Output
--json JSON output format
--ephemeral No session persistence
-o <file> Write output to file
--output-schema JSON schema for output
--output-last-message Final NL summary (CI)
Session Management
codex resume Resume a session (picker)
codex resume --last Resume most recent
codex resume --all All sessions (any dir)
codex fork Fork a session
codex exec resume Resume non-interactive
Environment
CODEX_API_KEY API key env var
🤖 Models & Config
Available Models
gpt-5.4 Most capable (recommended)
gpt-5.3-codex Coding-optimized
spark Fast lightweight (Pro only)
4.1-mini Small & efficient
Config Locations
~/.codex/config.toml User config (global)
.codex/config.toml Project config (local)
Config Settings
model Default model
approval_policy Approval behavior
sandbox_mode Sandbox type
web_search "cached" | "live" | "disabled"
personality Agent personality
reasoning_effort Thinking depth
log_dir Log directory path
review_model Override model for /review
tui.theme TUI color theme
🔓 Features & Approval
Feature Flags
codex features list Show all flags
codex features enable Persist enable in config
codex features disable Persist disable in config
apps Enable apps
codex_hooks Lifecycle hooks
fast_mode Quick responses
multi_agent Multiple agents
shell_snapshot Shell state capture
unified_exec Unified execution
undo Undo operations
Approval Modes
Auto Read, edit, run in workdir
Read-only Browse files, no changes
Full Access All access incl. network ⚠️
Sandbox Modes
macOS seatbelt Built-in sandbox
Linux Landlock Kernel-level sandbox
codex sandbox Run cmd under sandbox
🔌 MCP
CLI Commands
codex mcp list List MCP servers
codex mcp show <name> Show server details
codex mcp add <name> Add MCP server
codex mcp remove <name> Remove MCP server
codex mcp login OAuth login (HTTP only)
codex mcp logout Remove OAuth credentials
Transports
--url <url> Streamable HTTP (recommended)
-- <cmd> Stdio launcher command
Server Mode
codex mcp-server Run Codex as MCP server
Interactive
/mcp MCP management UI
☁️ Cloud & Agents
Cloud Commands
codex cloud Cloud task picker
codex cloud exec Run task in cloud
codex cloud list List cloud tasks (--json)
--attempts N Best-of-N runs (1–4)
Apply
codex apply Apply cloud diff locally
AGENTS.md
AGENTS.md Project agent config file
/init Create AGENTS.md
/agent Switch agent
Subagents
Subagents Spawn child agents
[agents] config Agent settings in config.toml
Other Commands
codex login Auth (ChatGPT or API key)
codex login status Check auth (for CI)
codex logout Remove credentials
codex completion Shell completions (bash/zsh/fish)
codex app Launch Desktop app (macOS)
codex execpolicy Check execpolicy rules