Codex CLI Cheatsheet
Eine kompakte Referenz für dokumentierte Codex CLI-Befehle, häufige Flags, nicht interaktive Läufe, MCP, Plugin-Verwaltung und integrierte Slash Commands.
codexInteraktive Arbeit im lokalen Repo
codex execSkripte und einmalige Aufgaben
codex cloudCloud-Task-Workflows
/permissionsLive-Steuerung der Sitzung
Schnellstart
Befehle, die Sie zuerst brauchen
Deckt die häufigsten lokalen, automatisierten, Cloud- und interaktiven Kontrollabläufe ab.
codexÖffnet die Terminal-UI im aktuellen Workspace.
codex exec "fix the failing test"Führt Codex nicht interaktiv aus und streamt das Ergebnis.
codex resume --lastKehrt zur neuesten interaktiven Sitzung zurück.
codex apply TASK_IDWendet den neuesten Diff einer Codex Cloud-Aufgabe an.
/permissionsLegt fest, was Codex ohne Nachfrage tun darf.
/modelWählt das aktive Modell und den Reasoning-Aufwand.
Globale Optionen
codex [OPTIONS] [PROMPT]
Diese Optionen gelten hauptsächlich für den Basisbefehl codex. Viele werden auch von Unterbefehlen akzeptiert.
| Option | Typ / Werte | Zweck |
|---|---|---|
--add-dir | path | Add another writable directory beside the main workspace. |
--ask-for-approval, -a | untrusted | on-request | never | Choose when Codex asks before running commands. |
--cd, -C | path | Set the working directory before the agent starts. |
--config, -c | key=value | Override configuration values inline. |
--dangerously-bypass-approvals-and-sandbox | boolean | Disable approvals and sandboxing for externally isolated environments. |
--yolo | boolean | Alias for the dangerous bypass mode. |
--dangerously-bypass-hook-trust | boolean | Run enabled hooks without persisted trust for this run. |
--disable | feature | Force-disable a feature flag. |
--enable | feature | Force-enable a feature flag. |
--image, -i | path[,path...] | Attach images to the initial prompt. |
--model, -m | string | Override the configured model. |
--no-alt-screen | boolean | Disable alternate-screen mode in the terminal UI. |
--oss | boolean | Use a local open-source model provider, commonly with Ollama. |
--profile, -p | string | Load a named Codex config profile. |
--remote | ws://host:port | wss://host:port | unix:// | unix://PATH | Connect the TUI to a remote app-server. |
--remote-auth-token-env | ENV_VAR | Read the remote bearer token from an environment variable. |
--sandbox, -s | read-only | workspace-write | danger-full-access | Select the sandbox policy for shell commands. |
--search | boolean | Enable live web search. |
--strict-config | boolean | Error on unknown config fields. |
PROMPT | string | Optional starting instruction. |
--add-dirTyp / Werte
pathZweck
Add another writable directory beside the main workspace.
--ask-for-approval, -aTyp / Werte
untrusted | on-request | neverZweck
Choose when Codex asks before running commands.
--cd, -CTyp / Werte
pathZweck
Set the working directory before the agent starts.
--config, -cTyp / Werte
key=valueZweck
Override configuration values inline.
--dangerously-bypass-approvals-and-sandboxTyp / Werte
booleanZweck
Disable approvals and sandboxing for externally isolated environments.
--yoloTyp / Werte
booleanZweck
Alias for the dangerous bypass mode.
--dangerously-bypass-hook-trustTyp / Werte
booleanZweck
Run enabled hooks without persisted trust for this run.
--disableTyp / Werte
featureZweck
Force-disable a feature flag.
--enableTyp / Werte
featureZweck
Force-enable a feature flag.
--image, -iTyp / Werte
path[,path...]Zweck
Attach images to the initial prompt.
--model, -mTyp / Werte
stringZweck
Override the configured model.
--no-alt-screenTyp / Werte
booleanZweck
Disable alternate-screen mode in the terminal UI.
--ossTyp / Werte
booleanZweck
Use a local open-source model provider, commonly with Ollama.
--profile, -pTyp / Werte
stringZweck
Load a named Codex config profile.
--remoteTyp / Werte
ws://host:port | wss://host:port | unix:// | unix://PATHZweck
Connect the TUI to a remote app-server.
--remote-auth-token-envTyp / Werte
ENV_VARZweck
Read the remote bearer token from an environment variable.
--sandbox, -sTyp / Werte
read-only | workspace-write | danger-full-accessZweck
Select the sandbox policy for shell commands.
--searchTyp / Werte
booleanZweck
Enable live web search.
--strict-configTyp / Werte
booleanZweck
Error on unknown config fields.
PROMPTTyp / Werte
stringZweck
Optional starting instruction.
Verwenden Sie --dangerously-bypass-approvals-and-sandbox oder --yolo nur, wenn die Umgebung bereits stark isoliert ist.
Befehlsübersicht
Dokumentierte Top-Level-Befehle
Stable-Befehle sind für den regulären Einsatz gedacht. Experimental-Befehle können sich mit Codex ändern.
| Befehl | Reifegrad | Zweck |
|---|---|---|
codex | Stable | Startet die interaktive Terminal-UI. |
codex app | Stable | Öffnet die Codex Desktop-App. |
codex app-server | Experimental | Start the local app server for development or debugging. |
codex apply | Stable | Apply a Codex Cloud task diff locally. |
codex a | Stable | Alias for codex apply. |
codex archive | Stable | Archive a saved interactive session. |
codex cloud | Experimental | Browse or run Codex Cloud tasks from the terminal. |
codex cloud-tasks | Experimental | Alias for codex cloud. |
codex completion | Stable | Generate shell completion scripts. |
codex debug app-server send-message-v2 | Experimental | Send a V2 test message to app-server. |
codex debug models | Experimental | Print the model catalog Codex sees. |
codex doctor | Stable | Create a local diagnostic report. |
codex exec | Stable | Führt Codex nicht interaktiv aus. |
codex e | Stable | Alias for codex exec. |
codex execpolicy | Experimental | Evaluate command execution policy rules. |
codex features | Stable | List or persist feature flag overrides. |
codex fork | Stable | Fork a previous session into a new thread. |
codex login | Stable | Authentifiziert Codex. |
codex logout | Stable | Entfernt gespeicherte Zugangsdaten. |
codex mcp | Experimental | Manage MCP server definitions and auth. |
codex mcp-server | Experimental | Run Codex itself as an MCP server. |
codex plugin | Experimental | Install, list, and remove Codex plugins. |
codex plugin marketplace | Experimental | Manage plugin marketplace sources. |
codex remote-control | Experimental | Ensure app-server remote control support is enabled. |
codex resume | Stable | Resume a previous interactive session. |
codex sandbox | Experimental | Run commands inside Codex sandboxes. |
codex unarchive | Stable | Restore an archived session. |
codex update | Stable | Check for or apply a CLI update when supported. |
codexStableStartet die interaktive Terminal-UI.
codex appStableÖffnet die Codex Desktop-App.
codex app-serverExperimentalStart the local app server for development or debugging.
codex applyStableApply a Codex Cloud task diff locally.
codex aStableAlias for codex apply.
codex archiveStableArchive a saved interactive session.
codex cloudExperimentalBrowse or run Codex Cloud tasks from the terminal.
codex cloud-tasksExperimentalAlias for codex cloud.
codex completionStableGenerate shell completion scripts.
codex debug app-server send-message-v2ExperimentalSend a V2 test message to app-server.
codex debug modelsExperimentalPrint the model catalog Codex sees.
codex doctorStableCreate a local diagnostic report.
codex execStableFührt Codex nicht interaktiv aus.
codex eStableAlias for codex exec.
codex execpolicyExperimentalEvaluate command execution policy rules.
codex featuresStableList or persist feature flag overrides.
codex forkStableFork a previous session into a new thread.
codex loginStableAuthentifiziert Codex.
codex logoutStableEntfernt gespeicherte Zugangsdaten.
codex mcpExperimentalManage MCP server definitions and auth.
codex mcp-serverExperimentalRun Codex itself as an MCP server.
codex pluginExperimentalInstall, list, and remove Codex plugins.
codex plugin marketplaceExperimentalManage plugin marketplace sources.
codex remote-controlExperimentalEnsure app-server remote control support is enabled.
codex resumeStableResume a previous interactive session.
codex sandboxExperimentalRun commands inside Codex sandboxes.
codex unarchiveStableRestore an archived session.
codex updateStableCheck for or apply a CLI update when supported.
Unterbefehle
Befehlsmatrix nach Workflow
Nach Workflow gruppiert, damit die Seite gut scanbar bleibt und trotzdem die dokumentierte Befehlsfläche abdeckt.
| Syntax | Typ / Werte | Zweck |
|---|---|---|
codex | - | Startet die interaktive Terminal-UI. |
codex "PROMPT" | - | Start the TUI with an initial instruction. |
codex --image path | path[,path...] | Start with one or more image attachments. |
codex --remote ENDPOINT | ws://, wss://, unix:// | Connect the TUI to a remote app-server. |
codex app | - | Open the desktop app. |
codex app PATH | path | Open a workspace path in Codex Desktop. |
codex app --download-url URL | url | Override the desktop installer download URL. |
codex app-server | - | Start the local app server. |
codex app-server --listen VALUE | stdio:// | ws://IP:PORT | unix:// | unix://PATH | off | Set the transport listener. |
codex app-server --stdio | boolean | Use stdio transport. |
codex app-server --analytics-default-enabled | boolean | Default analytics to enabled for app-server clients. |
codex app-server --ws-auth MODE | capability-token | signed-bearer-token | Choose WebSocket authentication mode. |
codex app-server --ws-audience VALUE | string | Expected JWT audience. |
codex app-server --ws-issuer VALUE | string | Expected JWT issuer. |
codex app-server --ws-max-clock-skew-seconds N | number | Allow clock skew for token time checks. |
codex app-server --ws-shared-secret-file PATH | absolute path | HMAC secret file for signed bearer tokens. |
codex app-server --ws-token-file PATH | absolute path | Capability token file. |
codex app-server --ws-token-sha256 HEX | hex SHA-256 | Expected SHA-256 digest for a token. |
codex remote-control | - | Ensure the local app-server daemon is running with remote-control enabled. |
codexZweck
Startet die interaktive Terminal-UI.
codex "PROMPT"Zweck
Start the TUI with an initial instruction.
codex --image pathTyp / Werte
path[,path...]Zweck
Start with one or more image attachments.
codex --remote ENDPOINTTyp / Werte
ws://, wss://, unix://Zweck
Connect the TUI to a remote app-server.
codex appZweck
Open the desktop app.
codex app PATHTyp / Werte
pathZweck
Open a workspace path in Codex Desktop.
codex app --download-url URLTyp / Werte
urlZweck
Override the desktop installer download URL.
codex app-serverZweck
Start the local app server.
codex app-server --listen VALUETyp / Werte
stdio:// | ws://IP:PORT | unix:// | unix://PATH | offZweck
Set the transport listener.
codex app-server --stdioTyp / Werte
booleanZweck
Use stdio transport.
codex app-server --analytics-default-enabledTyp / Werte
booleanZweck
Default analytics to enabled for app-server clients.
codex app-server --ws-auth MODETyp / Werte
capability-token | signed-bearer-tokenZweck
Choose WebSocket authentication mode.
codex app-server --ws-audience VALUETyp / Werte
stringZweck
Expected JWT audience.
codex app-server --ws-issuer VALUETyp / Werte
stringZweck
Expected JWT issuer.
codex app-server --ws-max-clock-skew-seconds NTyp / Werte
numberZweck
Allow clock skew for token time checks.
codex app-server --ws-shared-secret-file PATHTyp / Werte
absolute pathZweck
HMAC secret file for signed bearer tokens.
codex app-server --ws-token-file PATHTyp / Werte
absolute pathZweck
Capability token file.
codex app-server --ws-token-sha256 HEXTyp / Werte
hex SHA-256Zweck
Expected SHA-256 digest for a token.
codex remote-controlZweck
Ensure the local app-server daemon is running with remote-control enabled.
| Syntax | Typ / Werte | Zweck |
|---|---|---|
codex apply TASK_ID | string | Apply a Codex Cloud task diff locally. |
codex a TASK_ID | string | Alias for codex apply. |
codex archive SESSION | session ID | session name | Archive a saved session by ID or name. |
codex unarchive SESSION | session ID | session name | Restore an archived session by ID or name. |
codex archive --remote ENDPOINT SESSION | endpoint | Connect to remote app-server before changing archive state. |
codex cloud | - | Browse or run Cloud tasks from the terminal. |
codex cloud exec QUERY | string | Submit a Cloud task directly. |
codex cloud exec --attempts N | 1-4 | Set the number of assistant attempts. |
codex cloud exec --env ENV_ID | ENV_ID | Target a Codex Cloud environment. |
codex cloud list | - | List recent Cloud tasks. |
codex cloud list --cursor VALUE | string | Use a pagination cursor. |
codex cloud list --env ENV_ID | ENV_ID | Filter by environment. |
codex cloud list --json | boolean | Emit JSON output. |
codex cloud list --limit N | 1-20 | Limit the number of tasks returned. |
codex cloud-tasks | - | Alias for codex cloud. |
codex resume | - | Resume an interactive session. |
codex resume SESSION_ID | uuid | Resume a specific interactive session. |
codex resume --all | boolean | Show sessions outside the current directory. |
codex resume --last | boolean | Resume the most recent session. |
codex fork | - | Fork a previous session into a new thread. |
codex fork SESSION_ID | uuid | Fork a specific session. |
codex fork --all | boolean | Show sessions outside the current directory. |
codex fork --last | boolean | Fork the most recent session. |
codex apply TASK_IDTyp / Werte
stringZweck
Apply a Codex Cloud task diff locally.
codex a TASK_IDTyp / Werte
stringZweck
Alias for codex apply.
codex archive SESSIONTyp / Werte
session ID | session nameZweck
Archive a saved session by ID or name.
codex unarchive SESSIONTyp / Werte
session ID | session nameZweck
Restore an archived session by ID or name.
codex archive --remote ENDPOINT SESSIONTyp / Werte
endpointZweck
Connect to remote app-server before changing archive state.
codex cloudZweck
Browse or run Cloud tasks from the terminal.
codex cloud exec QUERYTyp / Werte
stringZweck
Submit a Cloud task directly.
codex cloud exec --attempts NTyp / Werte
1-4Zweck
Set the number of assistant attempts.
codex cloud exec --env ENV_IDTyp / Werte
ENV_IDZweck
Target a Codex Cloud environment.
codex cloud listZweck
List recent Cloud tasks.
codex cloud list --cursor VALUETyp / Werte
stringZweck
Use a pagination cursor.
codex cloud list --env ENV_IDTyp / Werte
ENV_IDZweck
Filter by environment.
codex cloud list --jsonTyp / Werte
booleanZweck
Emit JSON output.
codex cloud list --limit NTyp / Werte
1-20Zweck
Limit the number of tasks returned.
codex cloud-tasksZweck
Alias for codex cloud.
codex resumeZweck
Resume an interactive session.
codex resume SESSION_IDTyp / Werte
uuidZweck
Resume a specific interactive session.
codex resume --allTyp / Werte
booleanZweck
Show sessions outside the current directory.
codex resume --lastTyp / Werte
booleanZweck
Resume the most recent session.
codex forkZweck
Fork a previous session into a new thread.
codex fork SESSION_IDTyp / Werte
uuidZweck
Fork a specific session.
codex fork --allTyp / Werte
booleanZweck
Show sessions outside the current directory.
codex fork --lastTyp / Werte
booleanZweck
Fork the most recent session.
Nicht interaktiver Modus
codex exec Optionen
Diese Flags werden genutzt, wenn Codex als einmaliger Befehl im Terminal, Skript oder in Automatisierung läuft.
| Option | Typ / Werte | Zweck |
|---|---|---|
--cd, -C | path | Set the workspace root. |
--color | always | never | auto | Control ANSI color output. |
--dangerously-bypass-approvals-and-sandbox | boolean | Disable approvals and sandboxing. |
--yolo | boolean | Alias for dangerous bypass mode. |
--dangerously-bypass-hook-trust | boolean | Run hooks without persisted trust. |
--ephemeral | boolean | Do not persist session rollout files. |
--full-auto | boolean | Deprecated compatibility option. |
--ignore-rules | boolean | Do not load execpolicy rule files. |
--ignore-user-config | boolean | Do not load user config. |
--image, -i | path[,path...] | Attach images to the first message. |
--json | boolean | Emit NDJSON events. |
--experimental-json | boolean | Older alias for JSON event output. |
--model, -m | string | Override the model. |
--oss | boolean | Use a local OSS model provider. |
--output-last-message, -o | path | Write the final assistant message to a file. |
--output-schema | path | Validate the final output against a JSON Schema. |
--profile, -p | string | Load a config profile. |
--sandbox, -s | read-only | workspace-write | danger-full-access | Choose the sandbox policy. |
--skip-git-repo-check | boolean | Allow running outside a Git repository. |
--config, -c | key=value | Override config inline. |
PROMPT | string | - | Initial instruction. Use - to read from stdin. |
--cd, -CTyp / Werte
pathZweck
Set the workspace root.
--colorTyp / Werte
always | never | autoZweck
Control ANSI color output.
--dangerously-bypass-approvals-and-sandboxTyp / Werte
booleanZweck
Disable approvals and sandboxing.
--yoloTyp / Werte
booleanZweck
Alias for dangerous bypass mode.
--dangerously-bypass-hook-trustTyp / Werte
booleanZweck
Run hooks without persisted trust.
--ephemeralTyp / Werte
booleanZweck
Do not persist session rollout files.
--full-autoTyp / Werte
booleanZweck
Deprecated compatibility option.
--ignore-rulesTyp / Werte
booleanZweck
Do not load execpolicy rule files.
--ignore-user-configTyp / Werte
booleanZweck
Do not load user config.
--image, -iTyp / Werte
path[,path...]Zweck
Attach images to the first message.
--jsonTyp / Werte
booleanZweck
Emit NDJSON events.
--experimental-jsonTyp / Werte
booleanZweck
Older alias for JSON event output.
--model, -mTyp / Werte
stringZweck
Override the model.
--ossTyp / Werte
booleanZweck
Use a local OSS model provider.
--output-last-message, -oTyp / Werte
pathZweck
Write the final assistant message to a file.
--output-schemaTyp / Werte
pathZweck
Validate the final output against a JSON Schema.
--profile, -pTyp / Werte
stringZweck
Load a config profile.
--sandbox, -sTyp / Werte
read-only | workspace-write | danger-full-accessZweck
Choose the sandbox policy.
--skip-git-repo-checkTyp / Werte
booleanZweck
Allow running outside a Git repository.
--config, -cTyp / Werte
key=valueZweck
Override config inline.
PROMPTTyp / Werte
string | -Zweck
Initial instruction. Use - to read from stdin.
Interaktive TUI
Integrierte Slash Commands
Geben Sie / im Codex Composer ein, um das Slash-Command-Popup zu öffnen.
| Slash Command | Zweck |
|---|---|
/permissions | Set what Codex may do without asking. |
/ide | Include IDE context such as open files and selection. |
/keymap | Remap TUI keyboard shortcuts. |
/vim | Toggle Vim mode for the composer. |
/sandbox-add-read-dir | Add sandbox read access to a directory on Windows. |
/agent | Switch the active agent thread. |
/apps | Browse apps or connectors and insert one into the prompt. |
/plugins | Browse installed and discoverable plugins. |
/hooks | Review lifecycle hooks. |
/clear | Clear the terminal and start a fresh chat. |
/archive | Archive the current session and exit Codex. |
/compact | Summarize visible conversation to free tokens. |
/copy | Copy the latest completed Codex output. |
/diff | Show Git diff, including untracked files. |
/exit | Exit the CLI. |
/experimental | Toggle experimental features. |
/approve | Approve one retry after an auto-review denial. |
/memories | Configure memory usage and generation. |
/skills | Browse and use skills. |
/feedback | Send logs to Codex maintainers. |
/init | Generate an AGENTS.md scaffold. |
/logout | Sign out of Codex. |
/mcp | List configured MCP tools. |
/mcp verbose | Show MCP server details. |
/mention | Attach a file or folder to the conversation. |
/model | Choose model and reasoning effort. |
/fast | Toggle or inspect the Fast service tier. |
/plan | Switch to plan mode. |
/goal | Set, view, pause, resume, or clear a goal. |
/personality | Choose communication style. |
/ps | Show experimental background terminals. |
/stop | Stop all background terminals. |
/fork | Fork the current conversation into a new thread. |
/side | Start an ephemeral side conversation. |
/btw | Start a short side conversation. |
/raw | Toggle raw scrollback mode. |
/resume | Resume a saved conversation. |
/new | Start a new conversation in the same CLI session. |
/quit | Exit the CLI. |
/review | Ask Codex to review the working tree. |
/status | Display session config and token usage. |
/debug-config | Print config-layer diagnostics. |
/statusline | Configure TUI status-line fields. |
/title | Configure terminal title fields. |
/theme | Choose syntax-highlighting theme. |
/permissionsSet what Codex may do without asking.
/ideInclude IDE context such as open files and selection.
/keymapRemap TUI keyboard shortcuts.
/vimToggle Vim mode for the composer.
/sandbox-add-read-dirAdd sandbox read access to a directory on Windows.
/agentSwitch the active agent thread.
/appsBrowse apps or connectors and insert one into the prompt.
/pluginsBrowse installed and discoverable plugins.
/hooksReview lifecycle hooks.
/clearClear the terminal and start a fresh chat.
/archiveArchive the current session and exit Codex.
/compactSummarize visible conversation to free tokens.
/copyCopy the latest completed Codex output.
/diffShow Git diff, including untracked files.
/exitExit the CLI.
/experimentalToggle experimental features.
/approveApprove one retry after an auto-review denial.
/memoriesConfigure memory usage and generation.
/skillsBrowse and use skills.
/feedbackSend logs to Codex maintainers.
/initGenerate an AGENTS.md scaffold.
/logoutSign out of Codex.
/mcpList configured MCP tools.
/mcp verboseShow MCP server details.
/mentionAttach a file or folder to the conversation.
/modelChoose model and reasoning effort.
/fastToggle or inspect the Fast service tier.
/planSwitch to plan mode.
/goalSet, view, pause, resume, or clear a goal.
/personalityChoose communication style.
/psShow experimental background terminals.
/stopStop all background terminals.
/forkFork the current conversation into a new thread.
/sideStart an ephemeral side conversation.
/btwStart a short side conversation.
/rawToggle raw scrollback mode.
/resumeResume a saved conversation.
/newStart a new conversation in the same CLI session.
/quitExit the CLI.
/reviewAsk Codex to review the working tree.
/statusDisplay session config and token usage.
/debug-configPrint config-layer diagnostics.
/statuslineConfigure TUI status-line fields.
/titleConfigure terminal title fields.
/themeChoose syntax-highlighting theme.
Häufige Formen
/fast onTurn the Fast tier on.
/fast offTurn the Fast tier off.
/fast statusShow Fast tier status.
/personality friendlyUse the friendly communication style.
/personality pragmaticUse the pragmatic communication style.
/personality noneDisable personality styling.
/goal <objective>Set a task goal.
/goal pausePause the current goal.
/goal resumeResume the current goal.
/goal clearClear the current goal.
/prompts:<name>Run a local custom prompt. Custom prompts are deprecated in favor of skills.
Lokale Erweiterungen
Die integrierten Slash Commands sind begrenzt, aber installierte Skills, Plugins, MCP Server und veraltete /prompts:*-Dateien können lokale Fähigkeiten ergänzen.
Quellen
Offizielle Dokumentation
Befehlsnamen, Flags, Reifegradlabels und Slash-Command-Abdeckung basieren auf der offiziellen OpenAI Codex CLI-Dokumentation.
Hinweis
Diese Seite ist eine Kurzreferenz, keine vollständige Wiedergabe der offiziellen Dokumentation.