Codex Cheatsheet

Installation And Authentication

# Install CLI
npm install -g @openai/codex
codex --version
codex login

CLI Subcommands

CommandPurpose
codexStart an interactive session
codex execRun a non-interactive task
codex loginAuthenticate
codex logoutSign out

Common Flags

FlagPurpose
-c key=valueOverride config
--modelSelect model
--cdSet working directory
--searchEnable live search when available

Slash Commands

Common commands: /status, /model, /approvals, /review, /goal.

Permission Presets

Use read-only for review, workspace-write for normal local development, and broader access only in trusted environments.

Models (2026)

Model availability changes. Check the current official docs and choose based on task complexity.

Key config.toml Fields

model = "gpt-5.4"
reasoning_effort = "medium"
sandbox_mode = "workspace-write"
approval_policy = "on-request"

Key Paths

PathPurpose
~/.codex/config.tomlUser config
AGENTS.mdProject instructions
~/.codex/skills/User skills

Useful One-Liners

# Safe local development
codex -c sandbox_mode=workspace-write -c approval_policy=on-request

# Read-only planning
codex -c sandbox_mode=read-only

# CI changelog draft
codex exec "Draft release notes from the commits since the last tag."

评论