Command lines, slash commands and terminal UI keys of OpenAI Codex CLI 0.160.1, checked against the built-in help, OpenAI's Codex documentation and the default keymap in the source code. Words in capitals such as PROMPT or SESSION_ID stand for your own value. Slash commands and keys work only inside the interactive session that codex opens; Vim-mode keys and the agents overview are left out. Most keys can be reassigned with /keymap.
Open the terminal UIStarts an interactive session in the current directory; options given without a subcommand go to the TUI.
codex PROMPT
Start with an opening promptThe quoted text becomes the first message; leave it out and the composer opens empty.
codex --image FILE
Attach images to the first promptShort form -i; give several paths separated by commas, or repeat the flag.
codex --cd DIR
Set the working directoryShort form -C; the agent treats that folder as its workspace root instead of the shell's current one.
codex --add-dir DIR
Add a writable directoryGrants write access to one more folder next to the main workspace; repeat it for several.
codex --search
Turn on live web searchWithout the flag, web search results come from a cache rather than live browsing.
codex --profile PROFILE
Load a named profileShort form -p; puts the profile's own config file from CODEX_HOME over your normal settings.
codex --config KEY=VALUE
Override one config valueShort form -c; the value is read as TOML, nested keys use dots, and it applies to this run only.
codex --strict-config
Reject unknown config fieldsStops with an error when config.toml holds a field this release does not know.
codex --no-alt-screen
Run the TUI inlineLeaves the alternate screen off, so earlier terminal output stays in scrollback.
codex --worktree
Start in a new Git worktreeCodex creates and manages the worktree that the session then works in.
codex --version
Print the installed version
codex --help
Show helpWorks after any subcommand too; the short form -h prints a condensed summary.
codex update
Update the CLILooks for a newer release and installs it when this build can update itself.
codex app
Open the ChatGPT desktop appmacOS and Windows only; when the app is missing, the installer starts instead.
codex app PATH
Open a workspace in the desktop appOn macOS the app opens that folder; on Windows the command only prints which path to open.
codex app --download-url URL
Use another installer URLAdvanced option that only matters when the desktop app still has to be installed.
Non-interactive runs 20
The documentation still describes --full-auto as a deprecated alias, but release 0.160.1 answers it with an "unexpected argument" error; use codex exec --sandbox workspace-write.
Shortcut
What it does
codex exec PROMPT
Run one task without the TUIProgress goes to stderr and only the final message to stdout, so the answer can be piped or redirected.
codex e
Short alias of codex exec
codex exec -
Read the whole prompt from stdinThe lone hyphen makes piped input the full instruction instead of extra context.
cat prompt.txt | codex exec -
Pipe a prompt fileThe file's text is what Codex is asked to do.
codex exec --json
Stream events as JSON LinesStdout carries one JSON event per line, such as turn.started and turn.completed, instead of formatted text.
codex exec --output-last-message FILE
Save the final message to a fileShort form -o; the message is still printed on stdout as well.
codex exec --output-schema FILE
Require a JSON Schema replyThe final answer has to match the schema in the file, which gives later pipeline steps structured data.
codex exec --ephemeral
Run without saving the sessionSkips writing the session rollout files.
codex exec --skip-git-repo-check
Allow runs outside a Git repoCodex otherwise refuses to work outside a repository, as a guard against destructive changes.
codex exec --color never
Turn off colored outputTakes always, never or auto; auto is what you get without the flag.
codex exec --ignore-user-config
Skip the user config fileconfig.toml in CODEX_HOME is left unread, while saved authentication is still used.
codex exec --ignore-rules
Skip execpolicy rule filesNeither your own nor the project's .rules files apply to this run.
codex exec --sandbox workspace-write
Let an unattended run edit filescodex exec is read-only unless told otherwise; this widens it to edits inside the workspace.
codex exec --sandbox danger-full-access
Give an unattended run full accessThe docs reserve it for controlled environments such as an isolated CI runner or a container.
codex review
Review code non-interactivelyPick one target with a flag, or pass your own review instructions as the prompt.
codex review --uncommitted
Review uncommitted workCovers staged, unstaged and untracked files in the working tree.
codex review --base BRANCH
Review against a base branchLooks at what the current work adds on top of the branch you name.
codex review --commit SHA
Review a single commitLimits the review to what that one commit changed.
codex review --title TITLE
Title for the review summaryOnly valid together with --commit; the text is displayed as that commit's title.
codex review PROMPT
Review with custom instructionsCannot be combined with the target flags; a single hyphen reads the instructions from stdin.
Resuming and managing sessions 17
Shortcut
What it does
codex resume
Pick a session to resumeOpens a picker of saved interactive sessions and reloads the one you choose.
codex resume --last
Resume the latest sessionNo picker is shown; only sessions from the current directory count unless --all is added.
codex resume --all
List sessions from every directoryTurns off the current-directory filter and adds a CWD column to the picker.
codex resume SESSION_ID
Resume a specific sessionTakes the session UUID or its name; a value that parses as a UUID is tried first.
codex resume --include-non-interactive
Include codex exec sessionsAdds sessions from non-interactive runs to the picker and to what --last can choose.
codex fork
Fork a saved sessionOpens the session picker and copies the chosen transcript into a new chat; the original stays as it was.
codex fork --last
Fork the latest sessionBranches straight from your newest session, with no picker in between.
codex fork SESSION_ID
Fork a session by IDThe ID is the UUID of the saved conversation to copy.
codex exec resume --last
Continue the last exec runAdd a follow-up prompt after the flag to keep working in the same session.
codex exec resume SESSION_ID
Continue an exec run by IDTakes a session UUID or a thread name; a UUID is tried first.
codex exec resume --all
Search every directoryWithout it, only sessions recorded in the current working directory are considered.
codex exec fork SESSION_ID
Fork an exec sessionStarts a new non-interactive session from a copy of the one named.
codex archive SESSION
Archive a saved sessionHides it from the session picker while the transcript is kept; takes an ID or a name.
codex unarchive SESSION
Restore an archived sessionBrings a session hidden with codex archive back into the active lists.
codex delete SESSION
Delete a saved sessionRemoves the transcript for good, after a confirmation prompt.
codex delete SESSION_UUID --force
Delete without confirmationWorks only with a UUID; a session name still asks before anything is removed.
codex queue --thread THREAD --message TEXT
Queue a message for a sessionTHREAD is a session UUID or the exact session name.
Approvals and sandbox 18
Shortcut
What it does
codex --sandbox read-only
Sandbox: read-onlyShort form -s; commands the model runs can read files but not change them.
codex --sandbox workspace-write
Sandbox: write inside the workspaceEdits are allowed in the working directory and in folders added with --add-dir.
codex --sandbox danger-full-access
Sandbox: full accessThe docs advise --add-dir instead when all you need is one more writable folder.
codex --ask-for-approval on-request
Ask when the model requests itShort form -a; the model itself decides which commands to put in front of you.
codex --ask-for-approval never
Never stop for approvalA command that fails goes straight back to the model; combine it with any sandbox mode.
Send one test messageDebug aid: the text goes through a fresh thread and the server notifications are printed.
Plugins and marketplaces 12
Shortcut
What it does
codex plugin add PLUGIN@MARKETPLACE
Install a pluginLeave out @MARKETPLACE and name the marketplace with --marketplace or -m instead.
codex plugin list
List pluginsAdd --marketplace NAME to look at a single marketplace.
codex plugin list --available --json
Include plugins not yet installed--available only works together with --json; the output then has installed and available arrays.
codex plugin remove PLUGIN@MARKETPLACE
Uninstall a pluginAlso deletes the local cache of that plugin.
codex plugin marketplace add SOURCE
Add a plugin marketplaceTakes a folder on disk, GitHub owner/repo shorthand or a Git URL.
codex plugin marketplace add SOURCE --ref REF
Pin a Git refOnly meaningful for marketplaces that come from Git.
codex plugin marketplace add SOURCE --sparse PATH
Use a sparse checkoutRepeat the flag for each path you want checked out.
codex plugin marketplace list
List marketplacesPrints each marketplace Codex is looking at together with its root path.
codex plugin marketplace upgrade
Refresh Git marketplacesWith a name only that marketplace is refreshed; without one, every configured Git marketplace.
codex plugin marketplace remove MARKETPLACE_NAME
Remove a marketplace
/plugins
Browse plugins in the TUIMarketplace tabs list what is installed and what can be added, with each plugin's capabilities.
Space
Enable or disable a pluginWorks on an installed plugin inside the /plugins browser.
No row on this page matches that filter.
Notes
Starting a session
codex alone opens the terminal UI in the current directory; codex PROMPT sends a first message straight away. codex --model MODEL overrides the configured model for one run, codex --cd DIR sets the working directory, and codex --add-dir DIR grants write access to a second directory such as a shared library next to the app. codex --profile PROFILE layers a named config file over the base one, which is how a team keeps separate settings for reviewing versus generating. codex --image FILE attaches screenshots to the first prompt, useful for "make it look like this".
Approval and the sandbox
codex --ask-for-approval on-request lets the model decide when to stop for confirmation and codex --ask-for-approval never removes the prompts; codex --sandbox workspace-write keeps edits inside the workspace either way. codex --dangerously-bypass-approvals-and-sandbox (alias --yolo) removes both — the flag name is long on purpose, and it belongs only inside a container or a throwaway VM. codex execpolicy check --rules PATH COMMAND evaluates rule files against a command to show whether it would be allowed, prompted or blocked, which is the way to test a policy before trusting it. Inside a session, /permissions changes the approval preset and /status shows what is active.
Running unattended and reviewing
codex exec PROMPT runs one prompt non-interactively for scripts and CI, with progress on stderr and the final message on stdout; add codex exec --json for newline-delimited events, codex exec --output-last-message FILE to write the final answer to a file, and codex exec --output-schema FILE to request a reply that matches a JSON Schema. codex exec resume --last continues the most recent run and codex exec --ephemeral leaves no session files behind. codex review reviews changes — codex review --uncommitted for the working tree, codex review --base BRANCH against a branch, codex review --commit SHA for one commit. codex doctor diagnoses install, auth and Git problems, and codex mcp list shows the registered tool servers.
Keys inside the terminal UI
Enter sends the prompt, Tab queues a follow-up while Codex is working, Esc interrupts the turn, and Esc, Esc on an empty composer goes back to edit the previous message. Ctrl + R searches prompt history, Ctrl + T opens the transcript and Ctrl + G hands the draft to your editor. Ctrl + C and Ctrl + D are fixed; the other bindings can be remapped with /keymap, which stores them under tui.keymap in config.toml.
Questions
What is the difference between codex and codex exec?
codex opens the interactive TUI. codex exec PROMPT runs a single prompt to completion without a UI, for scripts and CI.
How do I stop Codex asking for approval?
Start it with codex --ask-for-approval never, or change the preset during a session with /permissions. --yolo disables approvals and the sandbox entirely and should only run inside a hardened container.
How do I resume yesterday's session?
codex resume --last reopens the most recent interactive session from the current directory and codex resume shows a picker; codex resume --all looks beyond that directory. For non-interactive runs use codex exec resume --last.
How do I get structured output from a run?
Use codex exec --json for a stream of JSON Lines events, or codex exec --output-schema FILE with a JSON Schema file that the final message has to match.
Which keys leave the Codex terminal UI?
Ctrl + D quits and Ctrl + C interrupts or quits; both are fixed bindings. /quit and /exit do the same from the composer.
Every row on this page was matched to a line in the documentation above on . A binding that could not be found there is not listed.
10 rows from the earlier version of this page were removed in that check: duplicates, and bindings the documentation does not list or lists differently.
Found a wrong or missing key? Tell us and it gets checked against the source. How we verify describes the process and its limits.