Skip to content

Latest commit

 

History

History
100 lines (73 loc) · 1.92 KB

File metadata and controls

100 lines (73 loc) · 1.92 KB
marp true
theme tessl-cheatsheet
paginate false
size 1400px 1200px

OpenAI Codex CLI Cheat Sheet

Installation

npm install -g @openai/codex
codex

Requires ChatGPT Plus/Pro/Business/Enterprise. Auth via browser or OPENAI_API_KEY.

Operation Modes

Mode Flag Behavior
Suggest --suggest Shows changes, requires approval
Auto-Edit --auto-edit Auto-edits, asks for commands
Full Auto --full-auto Full access, no confirmations

CLI Commands

Command Description
codex Start interactive session
codex "prompt" Direct prompt
codex exec "prompt" Non-interactive run
codex e "prompt" Short form of exec
codex --model o3 Specify model

Keyboard Shortcuts

Key Action
Enter Send message
Ctrl+C Cancel operation
Esc Exit/cancel
y / n Approve/reject

Configuration

Config location: ~/.codex/

export OPENAI_API_KEY="sk-..."
export CODEX_MODEL="codex-1"
export CODEX_MODE="auto-edit"

Project config: AGENTS.md in project root

Models

Model Best For
codex-1 Default, balanced
o3 Complex reasoning
o4-mini Fast, lightweight
gpt-4.1 General coding

MCP Server

Run Codex as MCP server:

npx codex --mcp-server

Works with OpenAI Agents SDK.

Scripting Example

codex exec "Run tests and fix failures" \
  --full-auto --timeout 300

Git Safety

  • Commit before running Codex
  • Use --suggest for risky changes
  • Review diffs before accepting
  • Create feature branches

Tips

  • Start with --suggest mode to learn
  • Use specific file paths in prompts
  • Let Codex iterate on test failures
  • Use codex exec for CI/automation
Tessl · Codex CLI Cheat Sheet · __VERSION__