1. Install, launch, and update
| Command | What it does |
|---|---|
npm i -g @openai/codex | Installs Codex CLI globally. |
codex | Launches the interactive Codex CLI/TUI. |
npm i -g @openai/codex@latest | Updates Codex CLI to the latest published version. |
OpenAI’s CLI docs say Codex runs on macOS, Windows, and Linux, and that first launch prompts you to sign in.
2. CLI slash commands
In the interactive CLI, type / to open slash commands. While Codex is working, you can also queue commands with Tab.
Main slash commands
| Slash command | What it does | Notes |
|---|---|---|
/agent | Switch the active agent thread. | Used for multi-agent workflows. |
/apps | Manage apps. | Current-source command. |
/approve | Approve one retry of the latest auto-review denial. | Current-source command. |
/approvals | Legacy alias for permissions. | Docs say it still works, but /permissions is preferred. |
/clear | Clear the conversation and start a new one. | Different from Ctrl+L, which only clears the terminal view. |
/clean | Alias for /stop. | Current-source alias. |
/collab | Change collaboration mode. | Experimental/current-source command. |
/compact | Summarize conversation context to save tokens. | Useful before long sessions. |
/copy | Copy the last assistant response as Markdown. | Not available on every platform. |
/debug-config | Show configuration layers and the source of each effective value. | Useful when config behavior is confusing. |
/debug-m-drop | Memory debug command. | Internal/debug; avoid for normal guide users. |
/debug-m-update | Memory debug command. | Internal/debug; avoid for normal guide users. |
/diff | Show Git diff, including untracked files. | Good before review or commit prep. |
/exit | Exit Codex. | Alias of /quit. |
/experimental | Toggle experimental features. | Used for things like goals. |
/fast | Toggle Fast mode. | Supports /fast on, /fast off, /fast status. |
/feedback | Send feedback and logs to maintainers. | CLI/app/IDE surfaces include this. |
/fork | Fork the current conversation into a new thread. | Useful for alternate solution paths. |
/goal | Set, view, pause, resume, or clear a long-running goal. | Experimental; details below. |
/hooks | View and manage lifecycle hooks. | Current-source command. |
/ide | Include current IDE selection, open files, or IDE context. | Current-source command. |
/init | Create an AGENTS.md instruction file. | Common first command in a repo. |
/keymap | Configure TUI keyboard shortcuts. | Supports inline arguments. |
/logout | Log out of Codex. | CLI command also exists. |
/mcp | List MCP tools and resources. | /mcp verbose shows details. |
/memories | Configure memory use and memory generation. | Current-source command. |
/mention | Mention a file. | Alternative to @ file search. |
/model | Select model and reasoning effort. | Also available via CLI flags. |
/new | Start a new chat during the current session. | Current-source command. |
/permissions | Choose what Codex is allowed to do. | Preferred over legacy /approvals. |
/personality | Set communication style. | Docs list friendly, pragmatic, and none. |
/plan | Switch to Plan mode. | Useful before coding or making changes. |
/plugins | Browse or manage plugins. | Current-source command. |
/ps | List background terminals. | Pair with /stop. |
/quit | Exit Codex. | Same as /exit. |
/raw | Toggle raw scrollback mode. | Useful for copy-friendly terminal selection. |
/realtime | Toggle realtime voice mode. | Experimental/current-source command. |
/rename | Rename the current thread. | Supports inline arguments. |
/resume | Resume a saved chat. | CLI command also exists. |
/review | Review current changes and identify issues. | Can be used inline, for example /review staged changes. |
/rollout | Print rollout file path. | Debug-build/current-source command. |
/sandbox-add-read-dir | Allow the sandbox to read an additional directory. | Platform-gated; docs note Windows usage. |
/settings | Configure realtime microphone/speaker settings. | Current-source command. |
/setup-default-sandbox | Set up an elevated agent sandbox. | Specialized/current-source command. |
/side | Start a side conversation as an ephemeral fork. | Details below. |
/skills | Use skills. | Current-source command; skills are replacing older custom prompts. |
/status | Show current session config and token usage. | CLI/app/IDE surfaces include this. |
/statusline | Configure status-line items. | Useful for persistent session info. |
/stop | Stop running background terminals. | /clean aliases to this. |
/subagents | Switch active subagent thread. | Current-source sibling/alias for multi-agent use. |
/test-approval | Test approval request behavior. | Debug-build/current-source command. |
/theme | Choose syntax highlighting theme. | Current-source command. |
/title | Configure terminal title items. | Useful when many sessions are open. |
/vim | Toggle Vim mode. | Current-source command. |
OpenAI’s public slash-command docs list the primary CLI commands, while the current CLI source enumerates additional commands such as /theme, /skills, /memories, /rename, /vim, /hooks, /raw, and debug/platform-gated items.
3. High-value slash command patterns
/goal
Use /goal for a long-running objective that Codex should continue working toward.
/goal Complete the migration to TypeScript and keep going until tests pass.
Useful forms:
/goal <objective>
/goal
/goal pause
/goal resume
/goal clear
OpenAI documents /goal as experimental and notes it requires the goals feature to be enabled. The docs also recommend clear goals with an objective, done condition, scope, and constraints.
/side
Use /side to open a temporary side conversation without permanently derailing the main thread.
/side explain why this test is failing
Typical uses:
/side summarize the current plan
/side what are the risks in this migration?
/side explain this error without changing files
OpenAI describes /side as an ephemeral fork of the conversation. It is not available inside nested side or review modes.
/mcp
Use /mcp to inspect MCP tools and resources available to Codex.
/mcp
/mcp verbose
/mcp verbose shows expanded MCP details.
/fast
/fast on
/fast off
/fast status
Fast mode toggles faster behavior where supported.
/personality
/personality friendly
/personality pragmatic
/personality none
OpenAI’s docs list those three personality modes.
4. CLI keyboard and input shortcuts
| Shortcut or prefix | What it does |
|---|---|
/ | Open slash-command menu. |
@ | Fuzzy-search files; use Tab or Enter to insert a path. |
!<command> | Run a local shell command. |
Enter while Codex is running | Inject instructions into the current turn. |
Tab while Codex is running | Queue a follow-up instruction or command for the next turn. |
Ctrl+G | Open the prompt composer in your external editor using VISUAL or EDITOR. |
Ctrl+L | Clear the terminal view only. |
/clear | Clear the conversation and start a new chat. |
Esc twice with an empty composer | Edit the previous user message; continuing to press Esc walks backward. |
Enter after editing a previous message | Fork from that point. |
OpenAI’s CLI tips document the @, !, Enter, Tab, Ctrl+G, and Esc behaviors. The slash docs distinguish /clear from Ctrl+L.
5. Top-level Codex CLI commands
| Command | Alias | What it does |
|---|---|---|
codex | — | Launches the interactive TUI. |
codex app | — | Opens the Codex desktop app. |
codex app-server | — | Runs the experimental app server. |
codex apply | codex a | Applies a patch generated by Codex. |
codex cloud | codex cloud-tasks | Works with cloud tasks. |
codex completion | — | Generates shell completion scripts. |
codex debug app-server send-message-v2 | — | Debug app-server message command. |
codex debug models | — | Debug model listing. |
codex exec | codex e | Runs Codex non-interactively. |
codex execpolicy | — | Tests command policy behavior. |
codex features | — | Lists, enables, or disables feature flags. |
codex fork | — | Forks a saved session. |
codex login | — | Logs in. |
codex logout | — | Logs out. |
codex mcp | — | Manages MCP servers. |
codex mcp-server | — | Runs Codex MCP server. |
codex plugin marketplace | — | Manages plugin marketplaces. |
codex resume | — | Resumes a saved session. |
codex sandbox | — | Runs a command under Codex sandboxing helpers. |
codex update | — | Updates Codex. |
OpenAI’s CLI reference lists these command groups and marks several as stable or experimental.
6. Global CLI flags
These can be used with top-level codex where applicable.
| Flag | Values / shape | What it does |
|---|---|---|
--add-dir | path | Adds a directory as writable or readable context. |
--ask-for-approval, -a | untrusted, on-request, never | Sets approval policy. |
--cd, -C | path | Sets working directory. |
--config, -c | key=value | Overrides a config value. |
--dangerously-bypass-approvals-and-sandbox | boolean | Disables approvals and sandboxing. |
--yolo | boolean | Alias for bypassing approvals and sandboxing. |
--disable | feature | Disables a feature flag. |
--enable | feature | Enables a feature flag. |
--image, -i | path or comma-separated paths | Adds image input. |
--model, -m | model name | Selects model. |
--no-alt-screen | boolean | Avoids alternate screen behavior. |
--oss | boolean | Uses the local open-source model provider. |
--profile, -p | profile name | Uses a config profile. |
--remote | ws://... or wss://... | Connects to a remote endpoint. |
--remote-auth-token-env | env var name | Reads remote auth token from an environment variable. |
--sandbox, -s | read-only, workspace-write, danger-full-access | Sets sandbox policy. |
--search | boolean | Enables web search where supported. |
PROMPT | string | Starts Codex with an initial prompt. |
OpenAI’s CLI reference lists these global options.
7. Important subcommand details
codex exec
Use this for non-interactive automation.
codex exec "fix the failing tests"
codex exec -m gpt-5.1-codex --sandbox workspace-write "review this repo"
Common options include:
| Option | What it does |
|---|---|
--cd | Set working directory. |
--color | always, never, or auto. |
--dangerously-bypass-approvals-and-sandbox, --yolo | Disable approvals and sandboxing. |
--ephemeral | Run without saving the session. |
--full-auto | Deprecated full-auto behavior. |
--ignore-rules | Ignore rules. |
--ignore-user-config | Ignore user config. |
--image | Include images. |
--json, --experimental-json | Emit JSON events. |
--model | Select model. |
--oss | Use local OSS provider. |
--output-last-message, -o | Save last message to a file. |
--output-schema | Constrain output to a schema. |
--profile | Use config profile. |
--sandbox | Set sandbox. |
--skip-git-repo-check | Skip Git repo check. |
-c, --config | Override config. |
PROMPT or - | Prompt string or stdin. |
OpenAI’s CLI reference documents these codex exec flags, plus codex exec resume.
codex cloud
Common forms:
codex cloud "investigate this issue"
codex cloud list
Useful options:
| Option | What it does |
|---|---|
--attempts | Sets 1–4 attempts. |
--env | Selects environment ID. |
--cursor | Pagination cursor for listing. |
--json | JSON output. |
--limit | Number of cloud tasks to list. |
OpenAI’s reference documents codex cloud, codex cloud exec, and codex cloud list.
codex features
codex features list
codex features enable <feature>
codex features disable <feature>
Use this to inspect or change feature flags.
codex mcp
| Command | What it does |
|---|---|
codex mcp add <name> -- <command...> | Adds a stdio MCP server. |
codex mcp add <name> --url <url> | Adds a URL-based MCP server. |
codex mcp get <name> | Shows one MCP server. |
codex mcp list | Lists MCP servers. |
codex mcp login <name> | Authenticates an MCP server. |
codex mcp logout <name> | Logs out of an MCP server. |
codex mcp remove <name> | Removes an MCP server. |
Useful options include --env, --bearer-token-env-var, --json, and --scopes.
codex plugin marketplace
| Command | What it does |
|---|---|
codex plugin marketplace add <source> | Adds a plugin marketplace. |
codex plugin marketplace remove <marketplace-name> | Removes a marketplace. |
codex plugin marketplace upgrade [marketplace-name] | Upgrades one or all marketplaces. |
Options include --ref and --sparse for marketplace add.
codex resume and codex fork
codex resume
codex resume --last
codex resume --all
codex resume <SESSION_ID>
codex fork
codex fork --last
codex fork --all
codex fork <SESSION_ID>
These resume or fork previous sessions.
codex sandbox
codex sandbox runs a command inside Codex’s sandbox helper. Subcommands vary by platform, including macOS seatbelt and Linux/Windows modes.
Common options include:
| Option | What it does |
|---|---|
--cd | Sets working directory. |
--config | Overrides config. |
--include-managed-config | Includes managed config. |
--permissions-profile | Selects permissions profile. |
--allow-unix-socket | macOS seatbelt option. |
--log-denials | macOS seatbelt option. |
COMMAND... | Command to run in the sandbox. |
OpenAI’s reference documents platform-specific sandbox helper options and warns that bypassing sandboxing should be used carefully.
8. Codex app commands
App slash commands
| Slash command | What it does |
|---|---|
/feedback | Send feedback. |
/mcp | Show MCP information. |
/plan-mode | Toggle or use plan mode. |
/review | Review changes. |
/status | Show status. |
The Codex app also exposes enabled skills in the slash-command list and supports $ for skills.
App keyboard shortcuts
| Shortcut | Action |
|---|---|
Cmd+Shift+P or Cmd+K | Command menu. |
Cmd+, | Settings. |
Cmd+O | Open folder. |
Cmd+[ | Navigate back. |
Cmd+] | Navigate forward. |
Cmd++ or Cmd+= | Increase font size. |
Cmd+- or Cmd+_ | Decrease font size. |
Cmd+B | Toggle sidebar. |
Cmd+Option+B | Toggle diff panel. |
Cmd+J | Toggle terminal. |
Ctrl+L | Clear terminal. |
Cmd+N or Cmd+Shift+O | New thread. |
Cmd+F | Find in thread. |
Cmd+Shift+[ | Previous thread. |
Cmd+Shift+] | Next thread. |
Ctrl+M | Dictation. |
OpenAI’s app docs list these shortcuts for macOS.
App deeplinks
| Deeplink | What it opens |
|---|---|
codex://settings | Settings. |
codex://skills | Skills. |
codex://automations | Automations. |
codex://threads/<thread-id> | Specific thread. |
codex://new | New thread. |
codex://new supports query parameters such as prompt, originUrl, and path.
9. IDE extension commands
IDE slash commands
| Slash command | What it does |
|---|---|
/auto-context | Configure automatic context. |
/cloud | Use cloud behavior. |
/cloud-environment | Select or configure cloud environment. |
/feedback | Send feedback. |
/local | Use local behavior. |
/review | Review changes. |
/status | Show status. |
OpenAI’s IDE docs say typing / in the Codex chat input shows available IDE slash commands.
VS Code command IDs
| Command ID | What it does |
|---|---|
chatgpt.addToThread | Add current selection to thread. |
chatgpt.addFileToThread | Add file to thread. |
chatgpt.newChat | New chat; default shortcut Cmd+N on macOS and Ctrl+N on Windows/Linux. |
chatgpt.implementTodo | Implement a TODO. |
chatgpt.newCodexPanel | Open a new Codex panel. |
chatgpt.openSidebar | Open the Codex sidebar. |
OpenAI documents these as VS Code command-palette commands that can be bound to shortcuts.
10. Custom slash commands and reusable prompts
OpenAI says custom prompts are deprecated in favor of skills, but existing custom prompts can still expose slash commands in the CLI and IDE.
Create a custom prompt slash command
Directory:
~/.codex/prompts
Example file:
~/.codex/prompts/draftpr.md
Example contents:
---
description: Draft a pull request description
argument-hint: FILES=<files> PR_TITLE=<title>
---
Review the following files and draft a concise PR description.
Files: $FILES
Title: $PR_TITLE
All arguments: $ARGUMENTS
After restarting Codex, it appears as:
/prompts:draftpr
Custom prompt files support front matter such as description and argument-hint, positional placeholders like $1 through $9, $ARGUMENTS, named placeholders such as KEY=value, and $$ for a literal dollar sign.
11. Safety defaults for a practical guide
For a user-facing Codex guide, I’d include this rule of thumb:
| Situation | Recommended setting |
|---|---|
| Normal repo work | --sandbox workspace-write |
| Read-only investigation | --sandbox read-only |
| Trusted automation in isolated environment | Consider stricter explicit approvals first. |
| Dangerous local bypass | Avoid --dangerously-bypass-approvals-and-sandbox / --yolo unless inside a disposable or isolated environment. |
OpenAI’s CLI reference includes safety guidance around sandboxing and warns about bypassing approvals and sandbox restrictions.







