title, date, background, tags, categories, intro, plugins
| title |
date |
background |
tags |
categories |
intro |
plugins |
| Codex CLI |
2026-11-14 16:20:00 |
bg-[#10a37f] |
| ai |
| cli |
| coding |
| terminal |
| shortcuts |
|
|
A quick reference cheat sheet for [Codex CLI](https://github.com/openai/codex), covering interactive keyboard shortcuts, execution modes, prompt syntax, slash commands, and configuration options.
|
|
Getting Started
Launching Codex CLI
Start an interactive session in current folder
Start session targeting a specific prompt
Start with a specific model
Run in non-interactive / one-shot mode
Essential CLI Flags
| Flag |
Description |
-m, --model <name> |
Specify LLM model (e.g. gpt-4o, o3-mini, o1) |
-C, --cd <dir> |
Set project root directory |
--full-auto |
Approve and execute commands automatically |
--dry-run |
Preview proposed changes without applying |
--sandbox |
Run shell commands inside an isolated container |
-v, --verbose |
Enable debug log output |
--help |
Show command line usage |
Keyboard Shortcuts
Session & Control
| Shortcut |
Action |
| Ctrl + C |
Cancel ongoing model response or running tool |
| Ctrl + D |
Exit Codex CLI session (on empty line) |
| Ctrl + L |
Clear screen while preserving chat history |
| Ctrl + Z |
Suspend CLI session to background |
Line Editing & Input
| Shortcut |
Action |
| Shift + Enter |
Insert literal newline for multi-line prompts |
| Alt + Enter |
Alternative multi-line newline insertion |
| Ctrl + A |
Move cursor to beginning of line |
| Ctrl + E |
Move cursor to end of line |
| Ctrl + U |
Clear line before cursor |
| Ctrl + K |
Kill text from cursor to end of line |
| Ctrl + W |
Delete previous word |
History & Autocomplete
| Shortcut |
Action |
| ↑ / ↓ |
Navigate previous prompt history |
| Ctrl + R |
Reverse-search prompt and command history |
| Tab |
Autocomplete file paths, commands, and tools |
| Esc |
Dismiss autocomplete popup or suggestion |
Slash Commands
Session Management
| Command |
Description |
/help |
List available slash commands and keybindings |
/clear |
Clear conversation context and start fresh |
/compact |
Summarize and compact conversation memory |
/exit |
Exit the Codex interactive session |
/quit |
Alias for /exit |
Environment & Mode
| Command |
Description |
/model [name] |
View or switch active model |
/approval |
Toggle auto-approval mode (ask, auto, strict) |
/diff |
Review all uncommitted code edits made by Codex |
/undo |
Revert the last file change performed |
/review |
Run automated self-review on current workspace diff |
Context & Prompting
File & Path References
Reference a specific file in prompt
Reference multiple files or glob pattern
Pipe terminal output into Codex
System Configuration
Configure project instructions in CODEX.md or AGENTS.md in repository root:
Environment Variables
Common Variables
| Variable |
Description |
OPENAI_API_KEY |
OpenAI API authentication key |
CODEX_MODEL |
Default model override |
CODEX_HOME |
Custom directory for config and history storage |
CODEX_AUTO_APPROVE |
When set to 1, automatically runs commands |
NO_COLOR |
Disable terminal color and ANSI styling |