Codex CLI Cheat Sheet

Codex CLI v0.154.0 Last updated: Sep 9, 2026
⌨️ Keyboard Shortcuts
General Controls
CtrlC Cancel input / interrupt
CtrlL Clear screen
CtrlG Open prompt in $EDITOR
CtrlO Copy latest agent responseNEW
EscEsc Undo last action
F13F24 Extended function keys now recognized in TUINEW
Prompt History
Navigate prompt history
CtrlR Reverse search history + recall accepted slash commandsNEW
While Running
Enter / Tab Enter injects instructions now; Tab queues follow-up for next turn
Alt, / Alt. Decrease / increase reasoning levelNEW
Inline Q&A Ask questions inline while Codex continues working in parallelNEW
Prefixes
@ Mention files, dirs, tasks, plugins & skills; tasks support read/create/messageNEW
! Direct shell command
/ Slash command
/vim search Vim mode: / and ? searches with n/N navigationNEW
/vim undo/redo Vim mode: u = undo, Ctrl+R = redoNEW
/vim replace Vim replace mode: R enters replace; improved Esc handlingNEW
⚡ 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; picker selects code blocks or quotesNEW
/status Show session status
/fork Fork session with paginated history; temp forks stay privateNEW
/resume Resume session (picker / ID)NEW
/archive Archive current sessionNEW
/export Export conversation to Markdown fileNEW
/usage Daily, weekly and cumulative token usage dashboardNEW
/new [name] New session (optional name for thread)NEW
/exit Close interactive session
/cd [dir] Change TUI working directoryNEW
/pwd, /cwd Print current working directoryNEW
Project & Config
/goal Create/manage persistent goal workflow; enabled by defaultNEW
/init Create AGENTS.md
/import Selectively import setup and config from Claude Code or CursorNEW
/mention Mention file/context
/agent Switch/manage agent
/apps Manage apps
Tools & Misc
/vim Toggle modal Vim editing in composer (customizable keymaps)NEW
/ide Inject IDE context into sessionNEW
/hooks Browse and manage hooks (pre/post-compaction)NEW
/app Handoff session to desktop app (macOS/Windows)NEW
/mcp List MCP tools / servers
/ps Show background terminals
/logout Log out
🖥️ CLI Flags
Basic Usage
codex "prompt" Start with initial prompt
--model Set model (e.g. gpt-5.4)
-i, --image <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 Sandboxed low-friction auto mode
-a, --ask-for-approval Set approval policy
--approve-for-me Auto-approve all actions (non-interactive)NEW
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
Remote
--remote <ws://url> Connect to remote app-server (ws:// or wss://)NEW
--remote-auth-token-env <ENV> Bearer token env var for WebSocket authNEW
Noise relay Remote executors use E2E-encrypted Noise channels; native cwd + shell preserved cross-platformNEW
Session
codex resume --last Continue most recent interactive session
--sandbox Set sandbox mode
--no-alt-screen Inline TUI, keep scrollback
🚀 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 "prompt" Pipe stdin + separate CLI promptNEW
Output
--json JSONL event stream (incl. reasoning-token usage)NEW
-o, --output-last-message Write final message to file
--output-schema JSON schema for final response
--skip-git-repo-check Allow exec outside Git repo
Session Management
codex resume Resume a session (picker / ID)
codex resume --last Resume most recent
codex resume --all Show all sessions across directoriesNEW
codex fork Fork a session
codex delete Permanently delete a session (with confirmation)NEW
codex exec resume [--output-schema] Resume non-interactive; supports structured output schemaNEW
codex queue [session-id] [msg] Send a message to an existing running sessionNEW
Environment
CODEX_API_KEY API key env var
🤖 Models & Config
Available Models
gpt-5.4 Most capable (recommended)
gpt-5.3-codex Coding-optimized
gpt-5.4-mini Fast & cost-effective mini
gpt-5.3-codex-spark Near-instant coding (Pro only)
gpt-6-astra GPT-6-Astra; default when model unconfigured in bundled pickerNEW
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"; works in code mode, nested JS calls; standalone for custom model providersNEW
personality Agent personality
reasoning_effort Thinking depth
log_dir Log directory path
review_model Override model for /review
tui.theme TUI color theme
tui.keymaps Configurable TUI key bindingsNEW
notify TUI notification preferencesNEW
tui.status_line Custom status line (can include thread title)NEW
hooks.session_start.source Detect /clear vs fresh startup in hooksNEW
provider = "amazon-bedrock" Built-in AWS Bedrock provider with AWS profile supportNEW
bedrock console-login AWS Bedrock auth now accepts console-login credentialsNEW
bedrock managed-auth Encrypted local API-key auth for Amazon BedrockNEW
Bedrock credential refresh Credential refresh progress shown when connecting to Amazon BedrockNEW
System proxy (macOS/Win) Honors OS proxy settings incl. PAC/WPAD; covers auth + Responses API trafficNEW
[hooks] inline config Hooks stable — define inline in config.toml, observe MCP tools + apply_patchNEW
hooks async MCP Command hooks run async; can invoke MCP tools directlyNEW
hooks: Interrupt New hook event for command execution during an active turn interruptionNEW
🔓 Features & Approval
Feature Flags
codex features list List known flags + maturity
undo Undo operations
shell_tool Shell tool support
web_search_request Live web search requests
web_search_cached Cached web search mode
unified_exec Unified background execution
shell_snapshot Shell state capture
child_agents_md Subagent instructions support
exec_policy Exec policy rules
experimental_windows_sandbox Windows-only sandbox feature flag
elevated_windows_sandbox Windows proxy-only networking / elevated sandbox supportNEW
steer Steer running agent threads
worktree Experimental isolated git worktree checkout supportNEW
Approval Modes
Auto Read, edit, run in workdir
Read-only Browse files, no changes
Writes Read-only actions auto-approved; prompts only for writesNEW
Full Access All access incl. network ⚠️
Permission profiles Persist across TUI sessions and MCP sandbox statesNEW
Sandbox Modes
read-only Read-only shell sandbox (no file writes)
workspace-write Write inside working roots
danger-full-access Unsandboxed local access ⚠️
codex sandbox Run command under Codex sandbox
Dangerous-cmd detection Detects more forced rm forms; clearer rejection reasonsNEW
Secret redaction Secrets stripped from displayed commands and session historyNEW
Memory ControlsNEW
--memory Set memory mode (on/off/sync)NEW
--memory-reset Clear session memoryNEW
--memory-cleanup Run memory extension cleanupNEW
🔌 MCP
CLI Commands
codex mcp list List MCP servers
codex mcp get <name> --json Show server config (--json = raw entry)
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 URL (recommended)
-- <cmd> Stdio launcher command
--env KEY=VAL Env vars for stdio transport (mcp add only)NEW
Server Mode
codex mcp-server Run Codex as MCP server
Advanced
resource reads MCP resource content in tool resultsNEW
server elicitations MCP server-driven prompts/confirmationsNEW
file uploads File parameter uploads to MCP toolsNEW
tool search default MCP tools use tool search by default when supportedNEW
MCP 2026-07-28 protocol Full protocol support with paginated tool/resource discoveryNEW
MCP grace period Configurable grace period for MCP server tool discoveryNEW
MCP tool result hooks Extensions can inspect or modify MCP tool results before they reach the modelNEW
MCP package-style names MCP server names support package-style naming conventionsNEW
MCP tool output limits Individual MCP tools can configure max output token limitsNEW
MCP OAuth coordination Plugin tool refresh and MCP OAuth recoordination on reconnectNEW
Interactive
/mcp MCP management UI
/mcp verbose Full MCP diagnostics, resources, and templatesNEW
interactive auth MCP tools request OAuth without experimental opt-inNEW
☁️ Cloud & Agents
Cloud Commands
codex cloud Cloud task picker
codex cloud exec --env ID Submit task to cloud
codex cloud status Show task status
codex cloud list List cloud tasks
codex remote-control Headless app-server operationNEW
codex remote-control pair Generate manual pairing code from a running daemonNEW
codex cloud apply <task_id> Apply cloud task diff locallyNEW
codex cloud diff Show task diff
--attempts N Best-of-N runs (1–4)
codex apply <task_id> Top-level apply helper
AGENTS.md
AGENTS.md Project agent config file
/init Create AGENTS.md
/agent Switch agent
Subagents
Subagents Spawn child agents on request
~/.codex/agents/ Custom agent definitionsNEW
agents.max_threads Concurrent agent cap (def: 6)NEW
agents.max_depth Nesting depth (def: 1)NEW
Multi-agent v2 Preserves runtime choices (model/reasoning/mode) across agent threadsNEW
Other Commands
Remote plugins Enabled by default; npm marketplace source; remote/local version shown in catalogNEW
Agent Plugin manifests Workspace plugin publishing; extra marketplaces (Amazon Bedrock, Claude Code)NEW
Portable Agent Plugins Installable plugins with search across multiple plugin catalogsNEW
codex marketplace add Install plugin marketplaces (GitHub, git URLs, local dirs, marketplace.json)NEW
marketplace catalogs Discovery shows "created-by-me" + auth-specific curated catalogsNEW
devcontainer --secure Secure devcontainer profile with bubblewrap (Linux); macOS sandbox Unix socket allowlistsNEW
codex update Update Codex CLI to latest versionNEW
codex doctor Diagnose environment, config, connectivity, editor & pager detailsNEW
codex login Auth (ChatGPT / API / device code)
v2 personal access tokens Token usage visibility + v2 PAT support in account settingsNEW
Device code flow Useful when browser callback login failsNEW
codex login status Check auth (for CI)
codex logout Remove credentials
codex completion Shell completions (bash/zsh/fish)
codex app-server Run app server / remote tooling (Unix socket transport + resume/fork pagination)NEW
app-server thread timeout App-server clients can set thread timeouts exceeding one hourNEW
App-server reconnect Auto-reconnects after disconnect, preserving draftsNEW
Windows daemon Shared background server for Windows; parallel sessions share one daemonNEW
codex exec-server Experimental remote exec server toolingNEW
codex app Launch Desktop app (macOS)
codex execpolicy check Validate execpolicy rule files