AI agents

Cheat sheets

Codex Cheat Sheet

Start

codex                  # start interactive TUI
codex "fix the bug"    # start with an initial prompt

Resume

codex resume           # open the session picker
codex resume --last    # resume most recent session in this directory
codex fork             # fork a previous session into a new chat
/resume    # resume a saved chat from the picker (inside the TUI)
/new       # new chat in the same session (/new <name> to name it)

Plan

/plan                              # switch to plan mode
/plan Propose a migration plan     # plan mode with an inline prompt

Review

/review    # review the working tree (read-only)
/diff      # show Git diff including untracked files
codex review --uncommitted        # non-interactive review of local changes
codex review --base main          # review against a base branch

Context / Compact

/compact    # summarize the chat to free context
/status     # session config, token usage, context left
/init       # generate an AGENTS.md scaffold

AGENTS.md at the project root is read as project instructions; global instructions live in ~/.codex/AGENTS.md.

Permissions

/permissions    # change what Codex can do without asking (mid-session)

Sandbox modes (-s / sandbox_mode in config.toml): read-only, workspace-write (network off by default), danger-full-access. Approval policies (-a / approval_policy): untrusted, on-request, never.

codex --sandbox workspace-write --ask-for-approval on-request   # recommended "Auto" combo
codex --dangerously-bypass-approvals-and-sandbox                # alias: --yolo

Warning: --yolo runs every command with no approvals and no sandbox. Use only inside an externally hardened environment (dedicated VM/container).

Configuration

~/.codex/config.toml     # user config (CODEX_HOME overrides ~/.codex)
.codex/config.toml       # project config (trusted projects only)
codex -c model="gpt-5.6"        # one-off config override (repeatable)
codex --profile work            # layer ~/.codex/work.config.toml on top

MCP

codex mcp add context7 -- npx -y @upstash/context7-mcp          # stdio server
codex mcp add figma --url https://mcp.figma.com/mcp             # HTTP server
codex mcp list                                                  # list servers
/mcp           # list configured MCP tools (inside the TUI)
/mcp verbose   # server diagnostics

Non-interactive

codex exec "fix the failing tests"     # run once; final message on stdout
codex exec --json "..."                # newline-delimited JSON events
codex exec resume --last "follow-up"   # continue a non-interactive session

Default sandbox for codex exec is read-only; requires a Git repo unless --skip-git-repo-check.


Last verified: 2026-09-07

AI coding tools evolve quickly. If you find outdated information, please open an issue or pull request.