Codex CLI Cheat Sheet

Codex CLI v0.167.1 Last updated: Nov 6, 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
f Fork current conversation while preserving draftsNEW
p Pin task in agent Command CenterNEW
CtrlInsert Copy selected text to clipboardNEW
Shift+click Extend text selectionNEW
F8 Toggle voice conversation on/offNEW
F9 Mute/unmute voice conversationNEW
F13–F24 Extended function keys now recognized in TUINEW
copy-on-select / right-click TUI config options for clipboard behavior in fullscreen modeNEW
Transcript navigation Word/line/page motions + search in transcript; shortcuts configurableNEW
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; inline args set model, reasoning effort & speedNEW
/fast Toggle fast mode
/plan Plan mode (read-only)
/review Review current changes
/diff Show diff of changes
/permissions View/update permissions; inline args set permission profilesNEW
/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
/config Search settings, apply changes immediately, flags which need restartNEW
Tools & Misc
/voice Voice conversations (on by default); F8 toggle; F9 mute; choose mic, speaker & channels; preferences savedNEW
/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
/tui Fullscreen terminal interface with transcript search and mouse controlsNEW
/daemon Restart managed background server; warns about interruption, auto-reconnectsNEW
/keymap Set a leader key (default Ctrl+X) for custom key bindingsNEW
/presets 10 numbered slots for saving and loading reusable prompts & slash commandsNEW
/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 | --resume] Send message to session; --resume resumes unloaded threadsNEW
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
gpt-6-sol GPT-6 Sol; now default in bundled & Bedrock catalogsNEW
gpt-6-luna GPT-6 Luna; added to model picker; recommended when rate-limitedNEW
Daybreak Enabled by default for eligible accounts; selectable in codex exec with OpenAI API keyNEW
gpt-6.1-terra GPT-6.1 Terra; added to model catalogsNEW
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
tui.mouse_scroll_speed Customize TUI scroll speedNEW
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
Bedrock credential commands Amazon Bedrock can obtain credentials from configured shell commands with cachingNEW
Bedrock multi-agent V2 Multi-agent V2 + Ultra reasoning on compatible models; GovCloud regions supportedNEW
Bedrock setup wizard Amazon Bedrock setup wizard enabled by default for new configurationsNEW
provider = "gcp" Built-in Google Cloud Vertex AI providerNEW
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 Isolated git worktrees; worktree.list/worktree.create tools for trusted local projectsNEW
instant_interrupt Opt-in: redirect model mid-execution via user input without waiting for turn endNEW
Mermaid rendering Expanded native Mermaid diagram rendering in TUINEW
Image previews in TUI Inline image previews in fullscreen transcript on Kitty- or Sixel-capable terminalsNEW
Image attach previews Local image attachments show previews while composing on supported terminalsNEW
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
Terminal input approval Enabled by default for elevated commands requiring extra confirmationNEW
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
Credential masking Credentials masked in supported remote Bash and Zsh sessionsNEW
Memory ControlsNEW
--memory Set memory mode (on/off/sync)NEW
--memory-reset Clear session memoryNEW
--memory-cleanup Run memory extension cleanupNEW
Memory v2 Default for fresh profiles; import external-agent memoriesNEW
🔌 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 <name> OAuth login from CLI or active TUI sessionNEW
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
exec-server bearer token WebSocket exec-server connections secured with bearer tokenNEW
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
Touch ID for MCP Touch ID verification for MCP tool requests in local TUI sessions (macOS)NEW
OAuth client secret MCP server OAuth client secret support for authentication flowsNEW
Interactive
/mcp MCP management UI
/mcp verbose Full MCP diagnostics, resources, and templatesNEW
interactive auth MCP tools request OAuth without experimental opt-inNEW
Enterprise MCP auth MCP auth via Codex account grants or dedicated sign-in; OAuth client secrets supportedNEW
☁️ 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
codex agents --no-daemon Open agent Command Center; marks unread resultsNEW
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 [--network-only] Diagnose environment, config, connectivity; --network-only for focused WebSocket checkNEW
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
Background server auto-start Daemon starts automatically for eligible interactive sessions with recovery optionsNEW
codex exec-server Experimental remote exec server toolingNEW
codex app Launch Desktop app (macOS)
codex execpolicy check Validate execpolicy rule files