简繁EN
← ToolsTools · Guide

A Codex Command Cheat Sheet

Slash commands, shortcuts, input prefixes and launch flags, grouped by when you need them, plus a few habits for beginners.

Last updated
Reading4 min read
Tags#Codex

Codex is OpenAI’s AI coding assistant for the terminal, and it works much like Claude Code: open it in a project folder, describe what you want in plain language, and it reads code, edits files and runs commands. Here are the commands I use, grouped by situation and checked against Codex 0.162.1 (2026-10-21). If you haven’t installed it yet, start with Installing Codex from Scratch.

Slash commands

Type / in the prompt to open the command list.

Everyday

Command What it does
/new Start a new conversation (use it between tasks)
/clear Clear the screen and start a new conversation
/compact Compress the conversation history to save context
/resume Resume an earlier conversation
/fork Branch the current conversation into a new one, keeping the original
/quit Quit Codex; /exit works too
/rename Rename the conversation so it’s easier to resume later
/recap Summarize the conversation, handy when you come back to it
/export Export the conversation as Markdown

Settings and models

Command What it does
/model Switch model and reasoning effort
/fast Toggle fast mode (about 2× speed, uses more of your limits)
/permissions Choose which actions no longer need your approval
/plan Enter plan mode: get a plan before any changes
/statusline Customize the status line
/theme Pick a syntax highlighting theme
/keymap Customize keyboard shortcuts
/vim Toggle Vim editing in the prompt
/logout Sign out

Projects and code

Command What it does
/init Create an AGENTS.md file for the project (the Codex equivalent of Claude Code’s CLAUDE.md)
/mention Add a file to the conversation
/diff See which files Codex changed (git diff, including new files)
/review Review your current changes and look for bugs
/copy Copy the last reply
/ide Bring open files and your selection from the editor into the conversation
/worktree Start a conversation in a new git worktree, leaving the current folder alone

Usage and troubleshooting

Command What it does
/status Show the current model, permission settings and token usage
/usage Show your account’s usage limits (only when signed in with ChatGPT)
/ps List terminals running in the background
/stop Stop all background terminals
/feedback Report a problem to OpenAI (logs are attached)

Advanced

Command What it does
/mcp List connected MCP tools
/skills Manage skills that make Codex better at specific tasks
/plugins Browse and install plugins
/hooks View and manage automation hooks
/memories Configure Codex’s memory
/agents Open the agent command center to see all tasks
/subagents Switch between this conversation’s subagents
/side Open a temporary side conversation without touching the main one (/btw works too)
/goal Set a goal for a long-running task
/import Import settings and recent conversations from Claude Code
/app Continue the conversation in the Codex desktop app

Shortcuts

Keys What it does
Esc Interrupt what Codex is doing
Esc Esc With an empty prompt, edit your previous message and continue from there
Tab While Codex is working, queue a message for when this turn ends
Enter While Codex is working, add instructions to the current turn
Shift + Tab Switch modes, for example into plan mode
Option + , / . Lower / raise reasoning effort
Ctrl + J New line in the prompt
↑ ↓ Scroll through what you typed before
Ctrl + R Search your prompt history
Ctrl + O Copy the last reply
Ctrl + T View the full transcript
Ctrl + G Write a long message in an external editor
Ctrl + L Clear the screen but keep the conversation
Ctrl + / Open a side conversation (same as /side)
← With an empty prompt, open the agent list
Ctrl + C Quit Codex
? With an empty prompt, show all shortcuts

Input prefixes

Prefix What it does Example
@ Search for and reference a file @plan.pdf summarize this
! Run a shell command directly ! ls
/ Run a slash command /new

To add an image, paste it into the prompt or hold Shift and drag it in.

Launching from the terminal

Before you’re inside Codex, run these in the terminal:

codex                        # start an interactive session
codex "question"             # start with a first question
codex resume --last          # continue the last conversation in this folder
codex resume                 # pick an earlier conversation to resume
codex fork --last            # branch the last conversation into a new one
codex exec "question"        # answer once and exit, handy in scripts
codex -m model-name          # start with a specific model
codex -s read-only           # read-only mode: can look but not edit files
codex --search               # allow live web search
codex -i image.png           # attach an image at launch
codex review --uncommitted   # review changes you haven’t committed

Account and maintenance:

codex login                  # sign in with your ChatGPT account
codex login status           # check whether you’re signed in
codex update                 # update to the latest version
codex doctor                 # check installation, settings and sign-in
codex mcp add                # add an MCP server from the command line

Habits for beginners

  1. Run /new before a new task so the old conversation doesn’t interfere.
  2. For bigger tasks, run /plan first. Codex proposes a plan and waits for your approval.
  3. If Codex heads the wrong way, press Esc, then check what it changed with /diff.
  4. When a long conversation makes Codex forgetful, run /compact.
  5. Run /init once at the start of a project so Codex gets up to speed quickly every time.
  6. Not sure what Codex is allowed to do? Check the current settings with /permissions.

Commands change between versions. For the definitive list, check the list that pops up when you type / on your own machine; press ? with an empty prompt to see the shortcuts.