AI logoAIv0.145BEGINNER

OpenAI Codex

OpenAI Codex cheat sheet covering CLI startup, built-in slash commands, session control, permissions, tools, and troubleshooting.

11 min read
codexopenaiai-codingclislash-commandsproductivity
Loading your progress

Installation & Setup

Choose the desktop app or CLI, sign in, and start using Codex.

Desktop App

Install ChatGPT for desktop and open Codex for local software work.

text
Download: https://chatgpt.com/download/

1. Install ChatGPT for macOS or Windows.
2. Open the app and sign in.
3. Select Codex from the top-left menu.
4. Open a local folder or project.

# Continue a CLI session on desktop
/app
🟢 The desktop app is available for macOS and Windows
📌 Select Codex for repositories, terminals, and developer tools
💡 Desktop and CLI are separate interfaces for the same coding workflow
⚡ Use /app to continue a CLI session on desktop
desktopinstallationappcodex

Install with the standalone installer, verify the CLI, and sign in.

bash
# Standalone installer: macOS and Linux
curl -fsSL https://chatgpt.com/codex/install.sh | sh

# Standalone installer: Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

# Verify the installed release
codex --version

# Start Codex and choose Sign in with ChatGPT
codex
🟢 The official quickstart leads with the standalone installers
⚡ Rerun the standalone installer to update Codex
📌 npm and Homebrew remain supported alternatives
🔐 Run codex and choose Sign in with ChatGPT on first launch
installationauthenticationclistandalone

Start a session and discover commands from the composer.

bash
# Start the interactive terminal UI
codex

# Start with an initial task
codex "Explain this repository structure"

# Inside the composer
/               # Open the slash command popup
/status         # Inspect the active session
/model          # Change the active model
/permissions    # Change approval behavior
💡 Type / to discover available commands
⚡ Start typing a command name to filter the popup
📌 Press Tab to queue a command while a turn is running
🔍 Use /status after startup to verify the session
basicsslash-commandstui

Essential Slash Commands

Control sessions, context, files, and code review.

Create, resume, organize, archive, or exit sessions.

text
/new                 Start a fresh chat
/clear               Clear the terminal and start fresh
/resume              Resume a saved chat
/fork                Fork the current chat
/rename NAME         Rename the current chat
/archive             Archive the session and exit
/delete              Permanently delete the session
/logout              Clear local credentials
/quit                Exit the CLI
/exit                Exit the CLI
📌 /new and /clear both start a fresh chat
💡 /fork preserves the original transcript
⚠️ /delete is permanent and removes descendant sessions
🔐 Use /logout before leaving a shared machine
commandssessionsaccount

Manage the context window and inspect session usage.

text
/compact             Summarize the chat to free context
/copy                Copy the latest completed response
/raw                 Toggle raw scrollback mode
/raw on              Enable raw scrollback
/raw off             Disable raw scrollback
/status              Show session configuration and tokens
/usage               Open account usage actions
/usage daily         Show daily token activity
/usage weekly        Show weekly token activity
/usage cumulative    Show cumulative token activity
📌 /compact keeps key context from a long chat
⚡ /copy uses the latest completed response
🔍 /status confirms the model, permissions, and workspace
💡 /usage requires Codex service account authentication
commandscontextusageoutput

Attach project context and inspect code changes.

text
/mention src/lib/api.ts
/ide Review the selected function
/diff
/review
📌 /mention points Codex at an exact file or folder
💡 /ide avoids re-explaining active editor context
🔍 /diff includes untracked files
🧪 /review focuses on defects, behavior changes, and missing tests
commandsfilesdiffreview

Models, Modes & Permissions

Change model behavior, planning state, goals, and access.

Switch models, speed tiers, personality, and memory.

text
/model               Choose model and reasoning effort
/fast                Toggle the Fast service tier
/personality         Choose a communication style
/memories            Configure memory use and generation
📌 /model changes the active session model
⚡ /fast appears only when the model catalog supports it
💬 /personality changes style without replacing instructions
🧠 /memories controls memory use and generation
commandsmodelspersonalitymemory

Plan before editing and track a persistent objective.

text
/plan
/plan Propose a migration plan for this service

/goal Finish the migration and keep tests green
/goal
/goal edit
/goal pause
/goal resume
/goal clear
💡 /plan is best before multi-step implementation
📌 /plan is unavailable while Codex is already working
🎯 /goal keeps a larger objective attached to the chat
⚠️ Goal text must be non-empty and at most 4,000 characters
commandsplangoalworkflow

Adjust approvals and platform sandbox access.

text
/permissions
/approve
/experimental

# Windows-only commands
/setup-default-sandbox
/sandbox-add-read-dir C:\absolute\directory
🔐 /permissions changes what Codex can do without asking
⚠️ /approve retries only a recent automatic-review denial
🧪 /experimental features may require a restart
🪟 Sandbox setup and extra read directories are Windows-only
commandspermissionssandboxwindows

Tools & Integrations

Use skills, custom commands, apps, plugins, MCP, and hooks.

Invoke reusable workflows from the slash menu.

text
/skills
$focused-review Review the current change

# Deprecated custom prompt command
/prompts:draftpr FILES="src/app/page.tsx"
🟢 /skills browses reusable task workflows
⚡ A $ mention invokes a skill explicitly
📌 Custom prompt commands use the /prompts:name prefix
⚠️ Custom prompts are deprecated in favor of skills
commandsskillscustom-prompts

Apps & Plugins

Browse connected apps and installable capability bundles.

text
/apps
/plugins
🔌 /apps inserts a selected app into the prompt
📦 /plugins opens the plugin browser
📌 Plugins can bundle skills, tools, and integrations
🔐 App access may require authorization or workspace approval
commandsappspluginsconnectors

MCP & Hooks

Inspect external tools and lifecycle handlers.

text
/mcp
/mcp verbose
/hooks
🔍 /mcp shows tools available in the current session
🧰 /mcp verbose adds server diagnostics
⚙️ /hooks opens lifecycle hook management
🔐 Managed hooks cannot be disabled from the user browser
commandsmcphookstools

Agents & Background Work

Switch agent threads and manage long-running terminals.

Inspect delegated work without losing the main conversation.

text
/agent
/subagents
/side Check whether this plan has an obvious risk
/btw Explain the last command
🤖 /agent and /subagents open the same thread picker
💡 /side preserves the main transcript
⚡ /btw is an alias for /side
📌 Side chats are temporary focused detours
commandsagentssubagentsside-chat

Inspect and stop terminals launched by the active session.

text
/ps
/stop
/clean
🔍 /ps shows recent output from background terminals
⏹️ /stop ends all background terminals for the session
📌 /clean is an alias for /stop
💡 Check /ps before stopping long-running work
commandsbackgroundprocessesterminals

Customization & Migration

Customize the terminal UI and move work between surfaces.

Customize visible session information and terminal styling.

text
/statusline
/title
/theme
/pets
/pet
/pets off
📊 /statusline controls persistent footer fields
🪟 /title controls terminal title fields
🎨 /theme previews syntax highlighting before saving
🐾 /pet and /pets open the same picker
commandsstatuslinethemetui

Remap TUI shortcuts and change composer editing mode.

text
/keymap
/vim
⌨️ /keymap updates shortcuts immediately
📌 Context-specific bindings override global bindings
💡 /vim toggles composer editing behavior
⚙️ Persistent keybindings are stored in config.toml
commandskeymapvimtui

Continue in the app, create project guidance, or import setup.

text
/app
/init
/import
🖥️ /app continues the same chat in the desktop app
📌 /init creates a starting point for project instructions
🔍 Review generated AGENTS.md content before keeping it
⚠️ /import is unavailable in remote or active-task sessions
commandsdesktopagents-mdimport

Troubleshooting

Inspect configuration, report problems, and recover context.

Inspect active state, configuration layers, and tool health.

text
/status
/debug-config
/mcp verbose
/feedback
🔍 Start with /status for unexpected session behavior
⚙️ /debug-config explains configuration precedence
🧰 /mcp verbose diagnoses external tool connections
🐛 /feedback can include logs for maintainers
commandsdiagnosticsconfigfeedback

Choose the least disruptive way to recover a long session.

text
# Preserve the current chat but free context
/compact

# Start a new chat and keep the terminal view
/new

# Clear the terminal and start a new chat
/clear

# Continue a saved chat
/resume

# Branch the current approach
/fork
📌 /compact is the least disruptive context reset
💡 /new keeps the visible terminal history
🧹 /clear resets both the chat and visible terminal
🔀 /fork is safest for exploring a competing approach
commandscontextrecoverysessions