ChatGPT 網頁版的撰寫工具有自己的指令選單。輸入 / 即可查看目前對話可用的操作。網頁版未提供 ChatGPT 桌面應用程式或 CLI 的指令集,因此本參考文件中的 Codex 斜線指令、CLI 指令與旗標均不適用於 ChatGPT 網頁版。
ChatGPT 桌面應用程式指令
指令頁面介紹如何在應用程式中導覽、使用對話快捷操作、自訂鍵盤快速鍵,以及透過深層連結開啟對話、設定、技能、排程任務、外掛程式和寵物。
斜線指令頁面介紹應用程式撰寫工具中可用的指令,包括 /feedback、/goal、/init、/mcp、/plan、/review 和 /status。
如何使用本參考文件
本頁列出文件中記載的所有 Codex CLI 指令與旗標。你可以在互動式表格中依鍵名或說明搜尋。各節會顯示選項的成熟度,並標示已棄用的選項和有風險的組合。
CLI 的多數預設值來自 ~/.codex/config.toml。在指令列傳入的 -c key=value 覆寫設定會在該次執行中優先套用。詳情請參閱設定基礎。
全域旗標
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--add-dir | path | Grant additional directories write access alongside the main workspace. Repeat for multiple paths. |
--approve-for-me, --not-so-yolo | boolean | Use automatic approval review with on-request approvals and the workspace-write sandbox. Conflicts with --sandbox and --yolo; the interactive CLI also rejects --ask-for-approval. |
--ask-for-approval, -a | on-request | never | Control when Codex pauses for human approval before running a command. |
--cd, -C | path | Set the working directory for the agent before it starts processing your request. |
--config, -c | key=value | Override configuration values. Values parse as TOML if possible; otherwise the literal string is used. |
--dangerously-bypass-approvals-and-sandbox, --yolo | boolean | Run every command without approvals or sandboxing. Only use inside an externally hardened environment. |
--dangerously-bypass-hook-trust | boolean | Run enabled hooks without requiring persisted hook trust for this invocation. Intended only for automation that already vets hook sources. |
--disable | feature | Force-disable a feature flag (translates to -c features.<name>=false). Repeatable. |
--enable | feature | Force-enable a feature flag (translates to -c features.<name>=true). Repeatable. |
--image, -i | path[,path...] | Attach one or more image files to the initial prompt. Separate multiple paths with commas or repeat the flag. |
--local-provider | lmstudio | ollama | Choose the local provider used with --oss, overriding oss_provider for this run. |
--model, -m | string | Override the model set in configuration (for example gpt-6.1-sol). |
--no-alt-screen | boolean | Disable alternate screen mode for the TUI (overrides tui.alternate_screen for this run). |
--no-daemon | boolean | Run the interactive CLI without the shared background server. Can't be combined with --remote or codex agents. |
--oss | boolean | Use a local open source model provider. Codex uses --local-provider, your configured oss_provider, or prompts you to choose between LM Studio and Ollama. |
--profile, -p | string | Layer $CODEX_HOME/profile-name.config.toml on top of the base user config. |
--remote | ws://host:port | wss://host:port | unix:// | unix://PATH | Connect to a remote app-server endpoint over WebSocket or a Unix socket. Supported for codex, codex agents, codex queue, codex resume, codex fork, codex archive, codex delete, and codex unarchive; other subcommands reject remote mode. |
--remote-auth-token-env | ENV_VAR | Read a bearer token from this environment variable and send it when connecting with --remote. Requires --remote; tokens are only sent over wss:// URLs or local-only ws:// URLs. |
--sandbox, -s | read-only | workspace-write | danger-full-access | Select the sandbox policy for model-generated shell commands. |
--search | boolean | Enable live web search (sets web_search = "live" instead of the default "cached"). |
--strict-config | boolean | Error when config.toml contains fields this Codex version does not recognize. Supported by runtime commands such as codex, exec, review, resume, fork, app-server, and exec-server. |
--worktree | boolean | Start in a new managed Git worktree. Supports new interactive sessions, codex fork <SESSION_ID>, codex exec, and codex exec fork; requires local execution. |
PROMPT | string | Optional text instruction to start the session. Omit to launch the TUI without a pre-filled message. |
--add-dirpath--approve-for-me, --not-so-yolobooleanon-request approvals and the workspace-write sandbox. Conflicts with --sandbox and --yolo; the interactive CLI also rejects --ask-for-approval.--ask-for-approval, -aon-request | never--cd, -Cpath--config, -ckey=value--dangerously-bypass-approvals-and-sandbox, --yoloboolean--dangerously-bypass-hook-trustboolean--disablefeature-c features.<name>=false). Repeatable.--enablefeature-c features.<name>=true). Repeatable.--image, -ipath[,path...]--local-providerlmstudio | ollama--oss, overriding oss_provider for this run.--model, -mstringgpt-6.1-sol).--no-alt-screenbooleantui.alternate_screen for this run).--no-daemonboolean--remote or codex agents.--ossboolean--local-provider, your configured oss_provider, or prompts you to choose between LM Studio and Ollama.--profile, -pstring$CODEX_HOME/profile-name.config.toml on top of the base user config.--remotews://host:port | wss://host:port | unix:// | unix://PATHcodex, codex agents, codex queue, codex resume, codex fork, codex archive, codex delete, and codex unarchive; other subcommands reject remote mode.--remote-auth-token-envENV_VAR--remote. Requires --remote; tokens are only sent over wss:// URLs or local-only ws:// URLs.--sandbox, -sread-only | workspace-write | danger-full-access--searchbooleanweb_search = "live" instead of the default "cached").--strict-configbooleanconfig.toml contains fields this Codex version does not recognize. Supported by runtime commands such as codex, exec, review, resume, fork, app-server, and exec-server.--worktreebooleancodex fork <SESSION_ID>, codex exec, and codex exec fork; requires local execution.PROMPTstring這些選項適用於基本指令 codex,多數也會傳遞給子指令。例外情況請參閱上方備註或相關指令的說明。使用可傳遞的旗標時,請依照相關指令的說明操作。例如,codex exec --oss ... 會將 --oss 套用至 exec。
指令總覽
「成熟度」欄使用「實驗性」、「Beta」、「穩定」和「已棄用」等功能成熟度標籤。各標籤的意義請參閱功能成熟度。
| Key | 成熟度 | 詳細資料 |
|---|---|---|
codex | Stable | Launch the terminal UI. Accepts the global flags above plus an optional prompt or image attachments. |
codex agents | Stable | Open the agent command center on a shared local or remote server. |
codex app | Stable | Launch the ChatGPT desktop app on macOS or Windows. On macOS, Codex can open a workspace path; on Windows, Codex prints the path to open. |
codex app-server | Experimental | Launch the Codex app server for local development or debugging over stdio, WebSocket, or a Unix socket. |
codex apply | Stable | Apply the latest diff generated by a Codex cloud chat to your local working tree. Alias: codex a. |
codex archive | Stable | Archive a saved interactive session by session ID or session name. |
codex cloud | Experimental | Browse or execute Codex cloud chats from the terminal without opening the TUI. Alias: codex cloud-tasks. |
codex completion | Stable | Generate shell completion scripts for Bash, Zsh, Fish, or PowerShell. |
codex debug app-server send-message-v2 | Experimental | Debug app-server by sending a single V2 message through the built-in test client. |
codex debug models | Experimental | Print the raw model catalog Codex sees, including an option to inspect only the bundled catalog. |
codex debug prompt-input | Experimental | Render the model-visible prompt input list as JSON, optionally with a prompt and images. |
codex delete | Stable | Permanently delete a saved interactive session by session ID or session name. |
codex doctor | Stable | Generate a diagnostic report for local installation, config, auth, runtime, Git, terminal, app-server, and thread inventory issues. |
codex exec | Stable | Run Codex non-interactively. Alias: codex e. Stream results to stdout or JSONL, resume sessions, or fork them into new sessions. |
codex execpolicy | Experimental | Evaluate execpolicy rule files and see whether a command would be allowed, prompted, or blocked. |
codex features | Stable | List feature flags and persistently enable or disable them in config.toml. |
codex fork | Stable | Fork a previous interactive session into a new chat, preserving the original transcript. |
codex login | Stable | Authenticate Codex using ChatGPT OAuth, device auth, an API key, or an access token piped over stdin. |
codex logout | Stable | Remove stored authentication credentials. |
codex mcp | Stable | Manage Model Context Protocol servers (list, add, remove, authenticate). |
codex plugin | Stable | Install, list, and remove plugins from configured marketplace sources. |
codex plugin marketplace | Stable | Add, list, upgrade, or remove plugin marketplaces from Git or local sources. |
codex queue | Stable | Queue a text message for an existing session by UUID or exact name. |
codex remote-control | Experimental | Run or manage remote control for the local app-server, or create a short-lived pairing code. |
codex resume | Stable | Continue a previous interactive session by ID or resume the most recent chat. |
codex review | Stable | Run a non-interactive review of uncommitted changes, a base branch diff, a commit, or custom review instructions. |
codex sandbox | Stable | Run arbitrary commands inside Codex-provided macOS, Linux, or Windows sandboxes. |
codex unarchive | Stable | Restore an archived interactive session by session ID or session name. |
codex update | Stable | Check for and apply a Codex CLI update when the installed release supports self-update. |
codexcodex appcodex applycodex a.codex cloudcodex cloud-tasks.codex deletecodex doctorcodex execcodex e. Stream results to stdout or JSONL, resume sessions, or fork them into new sessions.config.toml.codex forkcodex logincodex resumecodex reviewcodex update指令詳情
codex(互動模式)
執行 codex 而不指定子指令,會啟動互動式終端使用者介面(TUI)。智慧體接受上述全域旗標,也支援圖片附件。網頁搜尋預設使用快取模式,可使用 --search 切換為即時瀏覽。若要簡化本機作業,可使用 --sandbox workspace-write --ask-for-approval on-request。
使用 --remote ws://host:port 或 --remote wss://host:port,可將 TUI 連線至以 codex app-server --listen ws://IP:PORT 啟動的 App Server。若要透過本機 Unix socket 連線,可使用 --remote unix:// 連線至預設 socket,或使用 --remote unix://PATH 指定路徑。如果伺服器要求以 bearer 權杖進行 WebSocket 驗證,請加上 --remote-auth-token-env <ENV_VAR>。
codex agents
開啟指令中心,可瀏覽共用伺服器上的對話,並在智慧體之間切換。使用 --remote <URL> 連線至遠端伺服器,使用 --cd <DIR> 設定新遠端任務的目錄。codex agents 不支援 --no-daemon。
codex queue
將文字訊息加入現有工作階段的佇列:
codex queue --thread <SESSION_ID> --message "Run the remaining checks"--thread 接受 UUID 或完全相符的工作階段名稱。若有多個工作階段同名,請使用 UUID。佇列中的訊息會使用該工作階段的模型。此指令只接受文字。
加上 --resume 後,Codex 會先將訊息加入佇列,再恢復尚未載入的工作階段。若要恢復工作階段,本機必須有執行中的常駐程式,或須使用 --remote 指定伺服器。若伺服器要求權杖,請使用 --remote-auth-token-env。如果無法恢復工作階段,Codex 會輸出警告,但仍會以成功的結束碼退出。
codex app-server
在本機啟動 Codex App Server。此指令主要用於開發與偵錯,可能隨時變更,恕不另行通知。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--analytics-default-enabled | boolean | Defaults analytics to enabled for first-party app-server clients unless the user opts out in config. |
--code-mode-host | http://HOST[:PORT] | https://HOST[:PORT] | Share an outbound HTTP/2 gRPC connection to a remote Code Mode host across threads. Supply an HTTP or HTTPS origin without credentials, a path, a query, or a fragment. |
--listen | stdio:// | ws://IP:PORT | unix:// | unix://PATH | off | Transport listener URL. Use stdio:// for JSONL, ws://IP:PORT for a TCP WebSocket endpoint, unix:// for the default Unix socket, unix://PATH for a custom Unix socket, or off to disable the local transport. |
--stdio | boolean | Use stdio transport. Equivalent to --listen stdio:// and mutually exclusive with --listen. |
--ws-audience | string | Expected aud claim for signed bearer tokens. Requires --ws-auth signed-bearer-token. |
--ws-auth | capability-token | signed-bearer-token | Authentication mode for app-server WebSocket clients. If omitted, WebSocket auth is disabled; non-local listeners warn during startup. |
--ws-issuer | string | Expected iss claim for signed bearer tokens. Requires --ws-auth signed-bearer-token. |
--ws-max-clock-skew-seconds | number | Clock skew allowance when validating signed bearer token exp and nbf claims. Requires --ws-auth signed-bearer-token. |
--ws-shared-secret-file | absolute path | File containing the HMAC shared secret used to validate signed JWT bearer tokens. Required with --ws-auth signed-bearer-token. |
--ws-token-file | absolute path | File containing the shared capability token. Use with --ws-auth capability-token unless you provide --ws-token-sha256 instead. |
--ws-token-sha256 | hexadecimal SHA-256 digest | Expected SHA-256 digest for capability-token authentication. Use instead of --ws-token-file when the client token comes from another source. |
--analytics-default-enabledboolean--code-mode-hosthttp://HOST[:PORT] | https://HOST[:PORT]--listenstdio:// | ws://IP:PORT | unix:// | unix://PATH | offstdio:// for JSONL, ws://IP:PORT for a TCP WebSocket endpoint, unix:// for the default Unix socket, unix://PATH for a custom Unix socket, or off to disable the local transport.--stdioboolean--listen stdio:// and mutually exclusive with --listen.--ws-audiencestringaud claim for signed bearer tokens. Requires --ws-auth signed-bearer-token.--ws-authcapability-token | signed-bearer-token--ws-issuerstringiss claim for signed bearer tokens. Requires --ws-auth signed-bearer-token.--ws-max-clock-skew-secondsnumberexp and nbf claims. Requires --ws-auth signed-bearer-token.--ws-shared-secret-fileabsolute path--ws-auth signed-bearer-token.--ws-token-fileabsolute path--ws-auth capability-token unless you provide --ws-token-sha256 instead.--ws-token-sha256hexadecimal SHA-256 digest--ws-token-file when the client token comes from another source.codex app-server --listen stdio:// 會保留透過 stdio 傳輸 JSONL 的預設行為,codex app-server --stdio 則是使用相同傳輸方式的別名。--listen ws://IP:PORT 可為 App Server 用戶端啟用 WebSocket 傳輸。伺服器接受 ws:// 監聽網址。如果用戶端透過 wss:// 連線,請使用 TLS 終止或安全代理伺服器。使用 --listen unix:// 可在 Codex 的預設 Unix socket 上接受 WebSocket 交握,或使用 --listen unix:///absolute/path.sock 指定 socket 路徑。若要為用戶端繫結產生結構描述,可加上 --experimental 以納入受功能開關控制的欄位和方法。
使用 --code-mode-host https://code-mode.example.com,可讓 App Server 程序中的所有執行緒透過 gRPC 連線至遠端 Code Mode 主機。--listen 則控制用戶端連線至 App Server 的方式。
codex remote-control
執行 codex remote-control 可啟動遠端控制。符合條件時會使用受管理的背景伺服器,否則會改在前景執行。使用 codex remote-control --no-daemon 可明確指定在前景執行。使用 codex remote-control start 可啟動本機 App Server 常駐程式並啟用遠端控制,使用 codex remote-control stop 則可將其停止。受管理的遠端控制用戶端和 SSH 遠端工作流程會使用這些指令。若要建立本機通訊協定用戶端,仍須使用 codex app-server --listen。
常駐程式啟動後,使用 codex remote-control pair 可建立並輸出短時間內有效的手動配對碼。在任一遠端控制指令後加上 --json,即可取得機器可讀的輸出。執行 pair 時,JSON 回應包含 pairingCode、manualPairingCode、environmentId 和 expiresAt。--no-daemon 僅適用於未加子指令的 remote-control,請勿與 start、stop 或 pair 搭配使用。
codex app
在 macOS 或 Windows 上從終端啟動 ChatGPT 桌面應用程式。在 macOS 上,Codex 可開啟指定路徑的工作區;在 Windows 上,Codex 會輸出要開啟的路徑。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--download-url | url | Advanced override for the ChatGPT desktop app installer URL used during install. |
PATH | path | Workspace path for the ChatGPT desktop app. On macOS, Codex opens this path; on Windows, Codex prints the path. |
--download-urlurlPATHpathcodex app 會開啟已安裝的 ChatGPT 桌面應用程式。如果尚未安裝,則會啟動安裝程式。在 macOS 上,Codex 會開啟指定路徑的工作區;在 Windows 上,則會輸出安裝後要開啟的路徑。
codex debug app-server send-message-v2
使用內建的 App Server 測試用戶端,透過 App Server 的 V2 執行緒與回合流程傳送一則訊息。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
USER_MESSAGE | string | Message text sent to app-server through the built-in V2 test-client flow. |
USER_MESSAGEstring此偵錯流程會以 experimentalApi: true 初始化,啟動執行緒、送出一個回合,並以串流方式接收伺服器通知。你可以用它在本機重現並檢查 App Server 通訊協定的行為。
codex debug models
以 JSON 格式輸出 Codex 讀取到的原始模型目錄。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--bundled | boolean | Skip refresh and print only the model catalog bundled with the current Codex binary. |
--bundledboolean若只想檢查目前執行檔內附的模型目錄,而無須從遠端模型端點更新,請使用 --bundled。
codex debug prompt-input
以 JSON 格式輸出模型實際看到的提示詞輸入清單。可用來釐清 Codex 如何尋找指示、取得工作階段上下文或組合提示詞。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--image, -i | path[,path...] | Attach one or more images to the user prompt. Separate multiple paths with commas or repeat the flag. |
PROMPT | string | Optional user prompt appended after the session context. |
--image, -ipath[,path...]PROMPTstringcodex apply
將 Codex 雲端對話中最新的差異套用至本機程式碼庫。你必須完成身分驗證,且具有該對話的存取權。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
TASK_ID | string | Identifier of the Codex cloud chat whose diff should be applied. |
TASK_IDstringCodex 會列出已套用修補的檔案。如果 git apply 執行失敗(例如發生衝突),Codex 會以非零結束碼退出。
codex review
以非互動方式執行程式碼審查。請只選擇一個審查目標,或透過提示詞傳入自訂審查指示。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--base | branch | Review changes against the specified base branch. |
--commit | SHA | Review the changes introduced by the specified commit. |
--strict-config | boolean | Error when config.toml contains fields this Codex version does not recognize. |
--title | string | Set the commit title shown in the review summary. Requires --commit. |
--trust | boolean | Trust this project for this review and future chats, including its configured MCP servers. Codex refuses an explicitly untrusted project. |
--uncommitted | boolean | Review staged, unstaged, and untracked changes. |
PROMPT | string | - (read stdin) | Custom review instructions. Use - to read the instructions from stdin. |
--basebranch--commitSHA--strict-configbooleanconfig.toml contains fields this Codex version does not recognize.--titlestring--commit.--trustboolean--uncommittedbooleanPROMPTstring | - (read stdin)- to read the instructions from stdin.--uncommitted、--base、--commit 和自訂 PROMPT 彼此互斥。--title 僅可與 --commit 搭配使用。
codex archive 和 codex unarchive
依工作階段 ID 或名稱封存或還原已儲存的互動式工作階段。若想整理工作階段選擇器中的清單並保留對話紀錄,可使用這兩個指令。工作階段 ID 的優先順序高於名稱。
封存或還原工作階段時,Codex 也會嘗試對該工作階段建立的子代理程式工作階段執行相同操作,包括由這些子代理程式工作階段衍生的各層工作階段。
codex archive <SESSION>
codex unarchive <SESSION>| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--remote | ws://host:port | wss://host:port | unix:// | unix://PATH | Connect to a remote app-server endpoint before changing archive state. |
--remote-auth-token-env | ENV_VAR | Read a bearer token from this environment variable when --remote requires authentication. |
SESSION | session ID | session name | Saved session to archive or restore. Session IDs take precedence over session names. |
--remotews://host:port | wss://host:port | unix:// | unix://PATH--remote-auth-token-envENV_VAR--remote requires authentication.SESSIONsession ID | session namecodex delete
依工作階段 ID 或名稱永久刪除已儲存的互動式工作階段。只有在確定要移除對話紀錄,而非僅從使用中的工作階段清單隱藏該項目時,才使用此指令。
codex delete <SESSION>
codex delete <SESSION_UUID> --force| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--force | boolean | Delete without prompting. The session argument must be a UUID; names still require interactive confirmation. |
--remote | ws://host:port | wss://host:port | unix:// | unix://PATH | Connect to a remote app-server endpoint before deleting the session. |
--remote-auth-token-env | ENV_VAR | Read a bearer token from this environment variable when --remote requires authentication. |
SESSION | session ID | session name | Saved session to delete. Session IDs take precedence over session names. |
--forceboolean--remotews://host:port | wss://host:port | unix:// | unix://PATH--remote-auth-token-envENV_VAR--remote requires authentication.SESSIONsession ID | session name--force 僅可搭配工作階段 UUID 使用。依名稱刪除工作階段時仍須確認,以免 Codex 在名稱重複或指涉不明時直接刪除工作階段。
codex cloud
從終端操作 Codex 雲端對話。預設指令會開啟互動式選擇器。codex cloud exec 可直接提交任務,codex cloud list 則會傳回近期對話,方便在指令碼中使用或快速查看。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--attempts | 1-4 | Number of assistant attempts (best-of-N) Codex cloud should run. |
--env | ENV_ID | Target Codex cloud environment identifier (required). Use codex cloud to list options. |
QUERY | string | Task prompt. If omitted, Codex prompts interactively for details. |
--attempts1-4--envENV_IDcodex cloud to list options.QUERYstring身分驗證使用與主 CLI 相同的憑證。若任務提交失敗,Codex 會以非零結束碼退出。
codex cloud list
列出近期雲端對話,也可篩選結果或分頁顯示。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--cursor | string | Pagination cursor returned by a previous request. |
--env | ENV_ID | Filter tasks by environment identifier. |
--json | boolean | Emit machine-readable JSON instead of plain text. |
--limit | 1-20 | Maximum number of tasks to return. |
--cursorstring--envENV_ID--jsonboolean--limit1-20純文字輸出會先列出任務網址,再顯示狀態詳情。自動化作業請使用 --json。JSON 資料包含 tasks 陣列,以及選用的 cursor 值。每個任務都包含 id、url、title、status、updated_at、environment_id、environment_label、summary、is_review 和 attempt_total。
codex completion
產生 shell 指令補全指令碼,並將輸出重新導向至適當的位置,例如 codex completion zsh > "${fpath[1]}/_codex"。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
SHELL | bash | zsh | fish | power-shell | elvish | Shell to generate completions for. Output prints to stdout. |
SHELLbash | zsh | fish | power-shell | elvishcodex doctor
在回報問題給支援團隊之前,或在排查 Codex 安裝異常時,產生本機診斷報告。報告會檢查安裝、設定、身分驗證、執行環境、Git、終端、App Server 和執行緒清單的狀態。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--all | boolean | Expand long lists in the detailed human-readable report. |
--ascii | boolean | Use ASCII status labels and separators in human-readable output. |
--json | boolean | Emit a redacted machine-readable support report. |
--network-only | boolean | Limit checks to configuration, the network environment, provider HTTP connectivity, and Responses WebSocket connectivity. |
--no-color | boolean | Disable ANSI color in human-readable output. |
--summary | boolean | Show grouped check rows and the final count summary only. |
--allboolean--asciiboolean--jsonboolean--network-onlyboolean--no-colorboolean--summarybooleancodex features
管理儲存在 $CODEX_HOME/config.toml 中的功能旗標。enable 和 disable 指令會儲存變更,讓設定適用於後續工作階段。features 子指令不接受 --profile。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
Disable subcommand | codex features disable <feature> | Persistently disable a feature flag in $CODEX_HOME/config.toml. |
Enable subcommand | codex features enable <feature> | Persistently enable a feature flag in $CODEX_HOME/config.toml. |
List subcommand | codex features list | Show known feature flags, their maturity stage, and their effective state. |
Disable subcommandcodex features disable <feature>$CODEX_HOME/config.toml.Enable subcommandcodex features enable <feature>$CODEX_HOME/config.toml.List subcommandcodex features listcodex exec
若要透過指令碼或 CI 執行任務,且過程中無須人工介入,請使用 codex exec(簡寫為 codex e)。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--approve-for-me, --not-so-yolo | boolean | Use automatic approval review with on-request approvals and the workspace-write sandbox. Conflicts with --sandbox and --yolo; the interactive CLI also rejects --ask-for-approval. |
--cd, -C | path | Set the workspace root before executing the task. |
--color | always | never | auto | Control ANSI color in stdout. |
--cyber-access-program | standard | daybreak_blue | daybreak_red | Request a cyber access program for this turn (experimental, OpenAI provider only). Requires access for the account and model. Unavailable with review. A fork requires a prompt. |
--dangerously-bypass-approvals-and-sandbox, --yolo | boolean | Bypass approval prompts and sandboxing. Dangerous—only use inside an isolated runner. |
--dangerously-bypass-hook-trust | boolean | Run enabled hooks without requiring persisted hook trust for this invocation. Intended only for automation that already vets hook sources. |
--ephemeral | boolean | Run without persisting session rollout files to disk. |
--ignore-rules | boolean | Do not load user or project execpolicy .rules files for this run. |
--ignore-user-config | boolean | Do not load $CODEX_HOME/config.toml. Authentication still uses CODEX_HOME. |
--image, -i | path[,path...] | Attach images to the first message. Repeatable; supports comma-separated lists. |
--json, --experimental-json | boolean | Print newline-delimited JSON events instead of formatted text. |
--local-provider | lmstudio | ollama | Choose the local provider used with --oss, overriding oss_provider for this run. |
--model, -m | string | Override the configured model for this run. |
--oss | boolean | Use a local open source provider. Codex uses --local-provider or your configured oss_provider, and exits with an error if neither is set. |
--output-last-message, -o | path | Write the assistant’s final message to a file. Useful for downstream scripting. |
--output-schema | path | Path to a JSON Schema for the model's final response. |
--profile, -p | string | Layer $CODEX_HOME/profile-name.config.toml on top of the base user config. |
--sandbox, -s | read-only | workspace-write | danger-full-access | Sandbox policy for model-generated commands. Defaults to configuration. |
--skip-git-repo-check | boolean | Allow running outside a Git repository (useful for one-off directories). |
--thread-source | SOURCE | Set the source label for a new or forked thread. Resuming a thread keeps its original label. |
--trust | boolean | Save project trust for this run and future chats, even with --ephemeral. Conflicts with --ignore-user-config. |
--worktree | boolean | Run a new or forked session in a managed Git worktree. Requires local execution; can't be combined with resume, review, --ephemeral, or --ignore-user-config. |
-c, --config | key=value | Inline configuration override for the non-interactive run (repeatable). |
PROMPT | string | - (read stdin) | Initial instruction for the task. Use - to pipe the prompt from stdin. |
Resume subcommand | codex exec resume [SESSION_ID] | Resume an exec session by ID or add --last to continue the most recent session from the current working directory. Add --all to consider sessions from any directory. Accepts an optional follow-up prompt. |
--approve-for-me, --not-so-yolobooleanon-request approvals and the workspace-write sandbox. Conflicts with --sandbox and --yolo; the interactive CLI also rejects --ask-for-approval.--cd, -Cpath--coloralways | never | auto--cyber-access-programstandard | daybreak_blue | daybreak_red--dangerously-bypass-approvals-and-sandbox, --yoloboolean--dangerously-bypass-hook-trustboolean--ephemeralboolean--ignore-rulesboolean.rules files for this run.--ignore-user-configboolean$CODEX_HOME/config.toml. Authentication still uses CODEX_HOME.--image, -ipath[,path...]--json, --experimental-jsonboolean--local-providerlmstudio | ollama--oss, overriding oss_provider for this run.--model, -mstring--ossboolean--local-provider or your configured oss_provider, and exits with an error if neither is set.--output-last-message, -opath--output-schemapath--profile, -pstring$CODEX_HOME/profile-name.config.toml on top of the base user config.--sandbox, -sread-only | workspace-write | danger-full-access--skip-git-repo-checkboolean--thread-sourceSOURCE--trustboolean--ephemeral. Conflicts with --ignore-user-config.--worktreebooleanresume, review, --ephemeral, or --ignore-user-config.-c, --configkey=valuePROMPTstring | - (read stdin)- to pipe the prompt from stdin.Resume subcommandcodex exec resume [SESSION_ID]--last to continue the most recent session from the current working directory. Add --all to consider sessions from any directory. Accepts an optional follow-up prompt.Codex 預設會輸出經過排版的內容。加上 --json 可接收以換行分隔的 JSON 事件,每次狀態變更各占一行。使用選用的 resume 子指令可繼續執行非互動式任務。使用 --last 可選取目前工作目錄中最近的工作階段,或加上 --all 搜尋所有工作階段:
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--all | boolean | Include sessions outside the current working directory when selecting the most recent session. |
--image, -i | path[,path...] | Attach one or more images to the follow-up prompt. Separate multiple paths with commas or repeat the flag. |
--last | boolean | Resume the most recent chat from the current working directory. |
PROMPT | string | - (read stdin) | Optional follow-up instruction sent immediately after resuming. |
SESSION_ID | uuid | session name | Resume the specified session. Omit and use --last to continue the most recent session. |
--allboolean--image, -ipath[,path...]--lastbooleanPROMPTstring | - (read stdin)SESSION_IDuuid | session name--last to continue the most recent session.使用 codex exec fork <SESSION_ID> [PROMPT] 可將已儲存的工作階段複製到新的工作階段。工作階段引數接受 UUID 或名稱。若未提供提示詞,Codex 只會建立分支,不會啟動回合。傳入 - 作為提示詞引數,可從 stdin 讀取提示詞;加上 --image 則可附加圖片。
使用圖片、--output-schema、--output-last-message 或 --ephemeral 時,必須提供提示詞。
開始新的執行作業或從既有工作階段建立分支時,加上 --worktree 可建立受管理的 Git 工作樹:
codex exec --worktree "implement the next step"
codex exec fork <SESSION_ID> --worktree "try an alternative approach"--worktree 僅支援本機執行。請勿與 resume、review、--ephemeral 或 --ignore-user-config 搭配使用。
codex execpolicy
儲存 execpolicy 規則檔之前,可先檢查其內容。codex execpolicy check 接受一個或多個 --rules 旗標,用來指定規則檔(例如 ~/.codex/rules 下的檔案),並以 JSON 輸出最嚴格的判定結果與所有相符規則。加上 --pretty 可將輸出排版以便閱讀。execpolicy 指令目前為預覽功能。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--pretty | boolean | Pretty-print the JSON result. |
--rules, -r | path (repeatable) | Path to an execpolicy rule file to evaluate. Provide multiple flags to combine rules across files. |
COMMAND... | var-args | Command to be checked against the specified policies. |
--prettyboolean--rules, -rpath (repeatable)COMMAND...var-argscodex login
使用 ChatGPT 帳戶、API 金鑰或存取權杖驗證 CLI 身分。若未指定旗標,Codex 會開啟瀏覽器以進行 ChatGPT OAuth 驗證。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--device-auth | boolean | Use OAuth device code flow instead of launching a browser window. |
--with-access-token | boolean | Read an access token from stdin (for example printenv CODEX_ACCESS_TOKEN | codex login --with-access-token). |
--with-api-key | boolean | Read an API key from stdin (for example printenv OPENAI_API_KEY | codex login --with-api-key). |
status subcommand | codex login status | Print the active authentication mode and exit with 0 when logged in. |
--device-authboolean--with-access-tokenbooleanprintenv CODEX_ACCESS_TOKEN | codex login --with-access-token).--with-api-keybooleanprintenv OPENAI_API_KEY | codex login --with-api-key).status subcommandcodex login status若已有憑證,codex login status 會以結束碼 0 退出,方便自動化指令碼判斷登入狀態。
codex logout
移除已儲存的 API 金鑰與 ChatGPT 驗證憑證。此指令沒有旗標。
codex mcp
管理儲存在 ~/.codex/config.toml 中的模型上下文協定伺服器項目。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
add <name> | -- <command...> | --url <value> | Register a server using a stdio launcher command or a streamable HTTP URL. Supports --env KEY=VALUE for stdio transports. |
get <name> | --json | Show a specific server configuration. --json prints the raw config entry. |
list | --json | List configured MCP servers. Add --json for machine-readable output. |
login <name> | [--scopes scope1,scope2] [--no-browser] [--oauth-client-registration auto|cimd|dcr] | Sign in to a streamable HTTP server that supports OAuth. With --no-browser, open the printed URL in a browser and paste the full redirect URL into the CLI. |
logout <name> | Remove stored OAuth credentials for a streamable HTTP server. | |
remove <name> | Delete a stored MCP server definition. |
add <name>-- <command...> | --url <value>--env KEY=VALUE for stdio transports.get <name>--json--json prints the raw config entry.list--json--json for machine-readable output.login <name>[--scopes scope1,scope2] [--no-browser] [--oauth-client-registration auto|cimd|dcr]--no-browser, open the printed URL in a browser and paste the full redirect URL into the CLI.logout <name>remove <name>add 子指令同時支援 stdio 與可串流 HTTP 傳輸:
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--bearer-token-env-var | ENV_VAR | Environment variable whose value is sent as a bearer token when connecting to a streamable HTTP server. |
--env KEY=VALUE | repeatable | Environment variable assignments applied when launching a stdio server. |
--oauth-client-id | CLIENT_ID | OAuth client identifier for a streamable HTTP MCP server. Requires --url. |
--oauth-resource | RESOURCE | OAuth resource parameter to include during login for a streamable HTTP MCP server. Requires --url. |
--url | https://… | Register a streamable HTTP server instead of stdio. Mutually exclusive with COMMAND.... |
COMMAND... | stdio transport | Executable plus arguments to launch the MCP server. Provide after --. |
--bearer-token-env-varENV_VAR--env KEY=VALUErepeatable--oauth-client-idCLIENT_ID--url.--oauth-resourceRESOURCE--url.--urlhttps://…COMMAND....COMMAND...stdio transport--.OAuth 操作(login、logout)僅適用於支援 OAuth 的可串流 HTTP 伺服器。
codex plugin
安裝、列出或移除來自已設定市集的外掛程式。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
add <plugin[@marketplace]> | [--marketplace, -m NAME] [--json] | Install a plugin from a configured marketplace. Use --marketplace or -m when the plugin argument omits @marketplace. |
list | [--marketplace, -m NAME] [--available --json] [--json] | List installed plugins. With --json, output has installed and available arrays; --available includes uninstalled marketplace plugins and requires --json. |
marketplace | Manage configured marketplace sources. See codex plugin marketplace below. | |
remove <plugin[@marketplace]> | [--marketplace, -m NAME] [--json] | Remove an installed plugin from local config and cache. Use --json for automation-friendly output. |
add <plugin[@marketplace]>[--marketplace, -m NAME] [--json]--marketplace or -m when the plugin argument omits @marketplace.list[--marketplace, -m NAME] [--available --json] [--json]--json, output has installed and available arrays; --available includes uninstalled marketplace plugins and requires --json.marketplacecodex plugin marketplace below.remove <plugin[@marketplace]>[--marketplace, -m NAME] [--json]--json for automation-friendly output.codex plugin add --json 會輸出 pluginId、name、marketplaceName、version、installedPath 和 authPolicy。codex plugin list --json 會輸出 installed 和 available 陣列。項目包含 pluginId、name、marketplaceName、version、installed、enabled、source、installPolicy 和 authPolicy。若有 marketplaceSource,該欄位會列出已設定的市集來源類型與值。codex plugin remove --json 會輸出 pluginId、name 和 marketplaceName。
codex plugin marketplace
管理 Codex 可瀏覽並用來安裝外掛程式的市集來源。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
add <source> | [--ref REF] [--sparse PATH] [--json] | Install a plugin marketplace from GitHub shorthand, a Git URL, an SSH URL, or a local marketplace root directory. --sparse is supported only for Git sources and can be repeated. |
list | [--json] | Show plugin marketplaces Codex is currently considering and the root path for each marketplace. |
remove <marketplace-name> | [--json] | Remove a configured plugin marketplace. |
upgrade [marketplace-name] | [--json] | Refresh one configured Git marketplace, or all configured Git marketplaces when no name is provided. |
add <source>[--ref REF] [--sparse PATH] [--json]--sparse is supported only for Git sources and can be repeated.list[--json]remove <marketplace-name>[--json]upgrade [marketplace-name][--json]codex plugin marketplace add 接受 owner/repo 或 owner/repo@ref 等 GitHub 簡寫、HTTP 或 HTTPS Git 網址、SSH Git 網址,以及本機市集根目錄。使用 --ref 可鎖定 Git 參照。對於使用 Git 的市集程式碼庫,可重複指定 --sparse PATH 以進行稀疏簽出。
codex plugin marketplace list 會列出目前範圍內的市集名稱與根目錄,包括自動探索到的預設市集和已設定的市集快照。
在市集的 add、list、upgrade 或 remove 指令後加上 --json,即可取得適合自動化處理的輸出。add 的 JSON 包含 marketplaceName、installedRoot 和 alreadyAdded。list 的 JSON 包含 marketplaces 陣列,每個項目都有 name、root,也可能有 marketplaceSource。upgrade 的 JSON 包含 selectedMarketplaces、upgradedRoots 和 errors。remove 的 JSON 包含 marketplaceName 和 installedRoot。
codex mcp-server
codex mcp-server 指令與獨立的 codex-mcp-server 執行檔均已移除。請改用 Codex App Server。
codex resume
依 ID 繼續互動式工作階段,或恢復最近的對話。codex resume 會將 --last 的搜尋範圍限於目前工作目錄,除非你傳入 --all。此指令接受模型與沙盒的覆寫設定,但不接受 --worktree。
若目前工作目錄與工作階段儲存的目錄不同,Codex 會詢問要使用哪個目錄。將 tui.resume_cwd 設為 "current" 或 "session",即可沿用該選擇,無須每次確認。明確指定的 --cd(-C)優先於 tui.resume_cwd。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--all | boolean | Include sessions outside the current working directory when selecting the most recent session. |
--include-non-interactive | boolean | Include non-interactive sessions in the picker and --last selection. |
--last | boolean | Skip the picker and resume the most recent chat from the current working directory. |
SESSION_ID | uuid | session name | Resume the specified session. Omit and use --last to continue the most recent session. |
--allboolean--include-non-interactiveboolean--last selection.--lastbooleanSESSION_IDuuid | session name--last to continue the most recent session.codex fork
從先前的互動式工作階段建立新的對話分支。codex fork 預設會開啟工作階段選擇器。使用 --last 可從目前目錄中最近的工作階段建立分支。使用 --last --all 則會從所有目錄中最近的工作階段建立分支。
若目前目錄與工作階段儲存的目錄不同,codex fork 會提示你選擇工作目錄,並依照 tui.resume_cwd 設定處理,行為與 codex resume 相同。
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--all | boolean | Show sessions beyond the current working directory in the picker. |
--last | boolean | Skip the picker and fork the most recent chat automatically. |
SESSION_ID | uuid | Fork the specified session. Omit and use --last to fork the most recent session. |
--allboolean--lastbooleanSESSION_IDuuid--last to fork the most recent session.若要在受管理的 Git 工作樹中建立分支,請執行 codex fork <SESSION_ID> --worktree。此操作必須在本機執行,且須明確指定工作階段 ID,不支援 --last 或工作階段選擇器。
codex sandbox
使用沙盒輔助工具,可依照 Codex 內部使用的相同政策執行指令。
macOS seatbelt
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--allow-unix-socket | path | Allow the sandboxed command to bind or connect Unix sockets rooted at this path. Repeat to allow multiple paths. |
--cd, -C | DIR | Working directory used for profile resolution and command execution. Requires --permission-profile. |
--config, -c | key=value | Pass configuration overrides into the sandboxed run (repeatable). |
--include-managed-config | boolean | Include managed requirements while resolving an explicit permissions profile. Requires --permission-profile. |
--log-denials | boolean | Capture macOS sandbox denials with log stream while the command runs and print them after exit. |
--permission-profile, -P | NAME | Apply a named permissions profile from the active configuration stack. |
--profile, -p | NAME | Layer $CODEX_HOME/NAME.config.toml on top of the base user config. |
COMMAND... | var-args | Shell command to execute under macOS Seatbelt. Everything after -- is forwarded. |
--allow-unix-socketpath--cd, -CDIR--permission-profile.--config, -ckey=value--include-managed-configboolean--permission-profile.--log-denialsbooleanlog stream while the command runs and print them after exit.--permission-profile, -PNAME--profile, -pNAME$CODEX_HOME/NAME.config.toml on top of the base user config.COMMAND...var-args-- is forwarded.Linux 沙盒
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--cd, -C | DIR | Working directory used for profile resolution and command execution. Requires --permission-profile. |
--config, -c | key=value | Configuration overrides applied before launching the sandbox (repeatable). |
--include-managed-config | boolean | Include managed requirements while resolving an explicit permissions profile. Requires --permission-profile. |
--permission-profile, -P | NAME | Apply a named permissions profile from the active configuration stack. |
--profile, -p | NAME | Layer $CODEX_HOME/NAME.config.toml on top of the base user config. |
COMMAND... | var-args | Command to execute with bubblewrap filesystem isolation and seccomp filtering. Provide the executable after --. |
--cd, -CDIR--permission-profile.--config, -ckey=value--include-managed-configboolean--permission-profile.--permission-profile, -PNAME--profile, -pNAME$CODEX_HOME/NAME.config.toml on top of the base user config.COMMAND...var-args--.Windows
| Key | 型別 / 可用值 | 詳細資料 |
|---|---|---|
--cd, -C | DIR | Working directory used for profile resolution and command execution. Requires --permission-profile. |
--config, -c | key=value | Configuration overrides applied before launching the sandbox (repeatable). |
--include-managed-config | boolean | Include managed requirements while resolving an explicit permissions profile. Requires --permission-profile. |
--permission-profile, -P | NAME | Apply a named permissions profile from the active configuration stack. |
--profile, -p | NAME | Layer $CODEX_HOME/NAME.config.toml on top of the base user config. |
COMMAND... | var-args | Command to execute under the native Windows sandbox. Provide the executable after --. |
--cd, -CDIR--permission-profile.--config, -ckey=value--include-managed-configboolean--permission-profile.--permission-profile, -PNAME--profile, -pNAME$CODEX_HOME/NAME.config.toml on top of the base user config.COMMAND...var-args--.移除舊版 Windows 沙盒前,請先停止使用該沙盒的應用程式。若已安裝沙盒佈建服務,也請停止該服務。接著,以系統管理員身分執行 codex sandbox uninstall。此指令會移除整台電腦共用的沙盒帳戶與網路規則,並保留你的 Codex 主目錄,包括沙盒目錄與檔案系統權限。
codex update
如果已安裝的版本支援自行更新,可使用此指令檢查並套用 Codex CLI 更新。偵錯組建會顯示訊息,提示你改為安裝發行組建。
旗標組合與安全提示
- 對於可完全在工作區內執行、無人值守的本機作業,請使用
--sandbox workspace-write。除非是在專用的沙盒虛擬機器內,否則請避免使用--dangerously-bypass-approvals-and-sandbox。 - 若需授予 Codex 其他目錄的寫入權限,請優先使用
--add-dir,避免強制使用--sandbox danger-full-access。 - 在 CI 中搭配使用
--json和--output-last-message,可擷取機器可讀的進度資訊與最終的自然語言摘要。
互動模式快速鍵
- 輸入
@可搜尋工作區中的檔案,並將其路徑加入提示詞。 - 按 Up 或 Down 可調出先前的草稿。
- 按 Ctrl+R 可搜尋提示詞歷程記錄,再按 Enter 使用相符項目,或按 Escape 取消。
- 按 Ctrl+ O 可複製最近一次已完成的回覆。若要選擇複製的內容,請執行
/copy。 - 在行首加上
!,可依目前的核准與沙盒設定執行本機 shell 指令。 - Codex 工作時,按 Tab 可將後續提示詞、斜線指令或 shell 指令加入佇列,留待下一回合執行。
- Codex 工作時,按 Enter 可將新指示加入目前回合。
- 撰寫工具空白時,按兩次 Escape 可編輯上一則使用者訊息,並從該處建立對話分支。
- 按 Ctrl+C 或執行
/exit可關閉工作階段。
相關資源
- Codex CLI 總覽:安裝、升級與使用訣竅。
- 設定基礎:儲存模型和供應商等預設值。
- 進階設定:設定檔、供應商、沙盒調校與整合。
- AGENTS.md:Codex 智慧體的能力概述與最佳做法。
斜線指令讓你直接透過鍵盤快速操作 Codex。在撰寫工具中輸入 / 以開啟斜線指令選單,再選取指令,即可讓 Codex 切換模型、調整權限或摘要冗長的對話,全程無須離開終端。
本指南說明如何:
- 依任務選擇適合的內建斜線指令
- 使用
/model、/fast、/permissions、/approve、/raw、/agents、/subagents和/status等指令操作目前的工作階段
內建斜線指令
Codex 內建下列指令。開啟斜線指令選單後,開始輸入指令名稱即可篩選清單。
對話進行中時,你可以輸入斜線指令並按 Tab,將指令加入佇列,留待下一回合執行。Codex 會在執行時才解析佇列中的斜線指令,因此指令選單與錯誤訊息會在目前回合結束後出現。將指令加入佇列之前,仍可使用斜線指令補全功能。
| 指令 | 用途 | 使用時機 |
|---|---|---|
/permissions |
設定 Codex 可直接執行而無須先詢問的操作。 | 在工作階段中放寬或收緊核准要求,例如在自動與唯讀模式之間切換。 |
/ide |
納入已開啟的檔案、目前選取的內容和其他 IDE 上下文。 | 在下一個提示詞中帶入編輯器上下文,無須重新說明 IDE 中開啟了哪些內容。 |
/config |
搜尋與變更終端偏好設定。 | 調整佈景主題、通知、鍵盤快速鍵或文字選取方式。 |
/keymap |
重新設定 TUI 鍵盤快速鍵。 | 檢查自訂快速鍵繫結,並將其儲存至 config.toml。 |
/vim |
開啟或關閉撰寫工具的 Vim 模式。 | 在 Vim 的一般/插入模式與撰寫工具預設的編輯模式之間切換。 |
/setup-default-sandbox |
設定具提升權限的智慧體沙盒(僅限 Windows)。 | 在 Codex 提供提升權限的設定選項後,取代功能受限的 Windows 沙盒。 |
/agents |
開啟智慧體指令中心。 | 瀏覽所連線伺服器上的對話,並在智慧體之間切換。 |
/subagents |
切換目前使用的子代理程式執行緒。 | 在目前工作階段中檢查或繼續子代理程式的工作。 |
/apps |
瀏覽應用程式(連接器)並將其插入提示詞。 | 以 $app-slug 的形式附加應用程式,再請 Codex 使用它。 |
/plugins |
瀏覽已安裝和可探索的外掛程式。 | 檢查外掛程式工具、安裝建議的外掛程式,或管理哪些外掛程式可供使用。 |
/hooks |
檢視與管理生命週期掛鉤。 | 檢查已設定的掛鉤、將新增或變更的掛鉤標為信任,或在執行前停用非受管理的掛鉤。 |
/clear |
清除終端畫面並開始新對話。 | 想重新開始時,同時重設可見介面與對話上下文。 |
/rename |
重新命名目前的對話。 | 在 TUI 中為已儲存的工作階段取一個容易辨認的名稱。 |
/archive |
封存目前的工作階段。 | 從使用中的工作階段清單移除目前的工作階段,同時保留對話紀錄。 |
/delete |
永久刪除目前的工作階段。 | 若封存無法滿足需求,可移除對話紀錄與其衍生的工作階段。 |
/compact |
摘要可見的對話內容,釋出 Token 空間。 | 長時間執行後,讓 Codex 保留重點,避免超出上下文視窗容量。 |
/copy |
複製回覆、程式碼區塊或引文。 | 按 Ctrl+ O 可直接複製最近一次已完成的回覆,無須開啟選單。 |
/diff |
顯示 Git 差異,包括 Git 尚未追蹤的檔案。 | 在提交或執行測試前,檢查 Codex 的修改。 |
/exit |
離開 CLI(與 /quit 相同)。 |
兩種指令寫法都會結束工作階段。 |
/experimental |
開啟或關閉實驗性功能。 | 啟用網路代理伺服器或執行時防止休眠等選項。 |
/approve |
核准重試一次近期遭自動審查拒絕的操作。 | 重試自動審查拒絕的指令或操作。 |
/memories |
設定是否使用與產生記憶。 | 在 TUI 中開啟或關閉記憶注入或記憶生成功能。 |
/skills |
瀏覽與使用技能。 | 選擇相關的本機技能,讓 Codex 更能配合特定任務的需求。 |
/import |
匯入 Claude Code 或 Cursor 的設定、專案和對話。 | 將外部智慧體中支援的項目移轉至 Codex 設定與本機檔案。 |
/feedback |
傳送意見回饋,或將診斷資料儲存為 ZIP 檔。 | 回報問題,或與支援團隊分享診斷資訊。 |
/init |
在目前目錄中產生 AGENTS.md 範本。 |
為目前使用的程式碼庫或子目錄記下可持續沿用的指示。 |
/logout |
登出 Codex。 | 使用共用電腦時清除本機憑證。 |
/mcp |
列出已設定的模型上下文協定(MCP)工具。 | 查看 Codex 在工作階段中可呼叫哪些外部工具。加上 verbose 可查看伺服器詳情。 |
/mention |
在對話中附加檔案。 | 指定接下來要讓 Codex 檢查的檔案或資料夾。 |
/model |
選擇目前使用的模型,以及可用的推理強度。 | 若清單中有 gpt-6-luna 或 gpt-6.1-sol,即可選用。 |
/presets |
儲存並執行提示詞或斜線指令。 | 調出常用的指令或提示詞。 |
/fast |
模型目錄提供快速服務層級時,可將其開啟或關閉。 | 開啟或關閉目前模型的快速服務層級,並儲存選擇。 |
/daybreak |
帳戶與模型都符合資格時,開啟或關閉 Daybreak。 | 在對話中使用已獲核准的資安存取方案。 |
/voice |
語音功能可用時,開始或停止語音對話。 | 在支援語音的終端版本中,以語音與 Codex 交談。 |
/plan |
切換至規劃模式,也可一併送出提示詞。 | 在開始實作前,請 Codex 提出執行計畫。 |
/goal |
設定、編輯、暫停、恢復、查看或清除任務目標。 | 為 Codex 設定可持續追蹤的目標,供其執行較大型的任務。 |
/ps |
顯示背景終端及其近期輸出。 | 在主要對話紀錄中查看長時間執行的指令。 |
/stop |
停止所有背景終端。 | 取消目前工作階段啟動的背景終端作業。 |
/fork |
從目前對話建立新的對話分支。 | 從使用中的工作階段建立分支,嘗試新做法並保留目前的對話紀錄。 |
/app |
在 ChatGPT 桌面應用程式中繼續目前的工作階段。 | 在 macOS 或 Windows 上從 TUI 切換至桌面應用程式。 |
/side, /btw |
開啟支線對話。 | 針對特定問題追問,同時保持主要對話紀錄完整。 |
/raw |
開啟或關閉原始回捲模式。 | 查看較長的輸出時,減少終端格式對選取與複製文字的影響。 |
/resume |
從工作階段清單恢復已儲存的對話。 | 接續先前 CLI 工作階段的工作,無須從頭開始。 |
/new |
在同一個 CLI 工作階段中開始新對話。 | 想在同一個程式碼庫中使用新的提示詞時,可直接在 CLI 中重設對話上下文。 |
/quit |
離開 CLI。 | 立即結束工作階段。 |
/review |
請 Codex 審查工作樹。 | 在 Codex 完成工作後執行,或請它協助複查本機變更。 |
/status |
顯示工作階段設定與 Token 用量。 | 確認目前的模型、核准政策、可寫入的根目錄和上下文剩餘容量。 |
/usage |
查看帳戶的 Token 用量,或使用速率限制重設機會。 | 在 TUI 中查看 ChatGPT 每日、每週或累計的 Token 使用情形。 |
/debug-config |
輸出設定層與政策要求的診斷資訊。 | 排查優先順序與政策要求,包括實驗性的網路限制。 |
/statusline |
以互動方式設定 TUI 狀態列欄位。 | 選擇底部顯示的項目(模型、上下文、限制、Git、Token、工作階段),調整順序並儲存至 config.toml。 |
/title |
以互動方式設定終端視窗或分頁的標題欄位。 | 選擇並排列專案、狀態、執行緒、分支、模型和任務進度等標題項目。 |
/theme |
選擇語法醒目提示佈景主題。 | 預覽並儲存終端的語法醒目提示佈景主題。 |
/pets, /pet |
選擇或隱藏終端寵物。 | 使用內建或自訂寵物,為 TUI 增添個人風格。 |
/tui |
選擇下次啟動時的終端模式。 | 在終端回捲模式與全螢幕對話紀錄之間切換。 |
/export |
將對話匯出為 Markdown。 | 將完整對話紀錄存入檔案,或複製到剪貼簿。 |
/recap |
產生目前對話的摘要。 | 快速掌握對話進展,同時保留完整上下文。 |
/cd |
變更工作階段的工作目錄。 | 將閒置的主要對話移至另一個目錄繼續進行。 |
/pwd, /cwd |
顯示工作目錄。 | 查看目前工作階段使用的目錄。 |
/worktree |
在受管理的 Git 工作樹中開始或繼續對話。 | 在本機程式碼庫的另一份簽出副本中工作。 |
/daemon |
開啟背景伺服器的控制選項。 | 檢查連線,並管理由 Codex 控制的本機伺服器。 |
/warnings |
查看保留的警告與診斷資訊。 | 重新查看工作階段中出現過的警告。 |
/quit 和 /exit 都會離開 CLI。請先儲存或提交重要的工作,再使用這些指令。
使用 /permissions 可調整 Codex 無須先詢問就能執行的操作。只有在需要重試近期遭自動審查拒絕的操作時,才使用 /approve。
使用斜線指令操作工作階段
透過以下工作流程,你可以在工作階段中調整 Codex 的行為,無須重新啟動 Codex。
使用 /config 變更終端偏好設定
輸入 /config 以開啟終端偏好設定。你可以依群組瀏覽設定,或按 / 搜尋。Codex 會自動儲存變更。
使用 /tui 選擇終端模式
- 輸入
/tui。 - 選擇回捲模式或全螢幕模式,然後確認。
- 重新啟動 Codex 以套用選擇。
預期結果:下次啟動時會使用已儲存的終端模式。--no-alt-screen 等啟動時指定的覆寫選項仍然有效。
使用 /export 匯出對話
- 輸入
/export。 - 選擇複製到剪貼簿或儲存至檔案。
預期結果:Codex 會以 Markdown 格式匯出完整對話。若要直接儲存至檔案,請執行 /export session.md。請等目前回合結束後再匯出。
使用 /recap 摘要對話
- 在 Codex 閒置時輸入
/recap。
預期結果:Codex 會產生對話摘要,即使已設定 tui.auto_recap = false 也一樣。若想釋出上下文空間,請使用 /compact。
使用 /cd 變更目錄
- 輸入
/pwd(或/cwd)以查看目前目錄。 - 輸入
/cd <path>以切換目錄,或輸入/cd以切換至家目錄。
預期結果:Codex 會在所選目錄中繼續對話。只有在主要工作階段閒置、沒有輸入在佇列中等候,且沒有背景終端時,才能變更目錄。
使用 /worktree 在工作樹中繼續對話
- 在本機 Git 程式碼庫中輸入
/worktree。 - 選擇要在新的工作樹中開始新對話,還是繼續目前的對話。
預期結果:Codex 會建立受管理的 Git 工作樹,並在其中啟動所選對話。選擇瀏覽工作樹可查看現有工作樹及其所屬對話。此指令需要本機工作樹支援,且無法在任務執行期間使用。
使用 /daemon 管理背景伺服器
- 輸入
/daemon。 - 查看伺服器連線與可用操作。
預期結果:Codex 會讓你選擇為本機背景伺服器安裝最新的公開穩定版本,或使用目前的 CLI 組建。確認更新後會離開 Codex,可能中斷進行中的工作。若要重新啟動受管理的本機伺服器,請選擇重新啟動背景伺服器並確認。Codex 會自動重新連線。重新啟動可能會中斷其他對話中正在執行或在佇列中等候的工作。若使用遠端連線,請在伺服器所在的主機上進行管理。
使用 /warnings 檢查警告
- 輸入
/warnings。
預期結果:Codex 會顯示保留的警告及其詳細診斷資訊。
使用 /model 設定目前的模型
選擇器只會顯示你的帳戶與工作區可用的模型。如果清單中沒有 GPT-6.1 Sol,請選擇其他模型。請參閱各方案的 GPT-6.1 Sol 可用性。
- 啟動 Codex 並開啟撰寫工具。
- 輸入
/model並按 Enter。 - 從彈出式選單選擇模型,例如
gpt-6-luna或gpt-6.1-sol。
預期結果:Codex 會在對話紀錄中確認新模型。執行 /status 可確認變更已生效。
若要直接變更目前工作階段的設定,請使用 /model [model] [--reasoning=<level>] [--speed=<tier>]。例如,/model --reasoning=high 會沿用目前的模型,並在模型支援時將推理強度設為高。
使用 /presets 重複使用提示詞與指令
輸入 /presets 並按 n ,可將提示詞或斜線指令儲存在有編號的位置。按 s 可根據目前的模型、權限、終端標題或狀態列建立預設組合。若要執行已儲存的預設組合,請開啟 /presets 並按下對應的數字鍵。
使用 /fast 切換快速模式
- 輸入
/fast以啟用目前模型的快速服務層級。 - 再次輸入
/fast即可關閉。
預期結果:Codex 會切換服務層級並儲存選擇。你也可以使用 /statusline,在 TUI 底部的狀態列顯示快速模式項目。
快速服務層級的指令是否可用取決於模型目錄。若目前模型未列出快速服務層級,Codex 就不會顯示 /fast。
開啟或關閉 Daybreak
如果你使用 OpenAI 供應商,且帳戶與模型都有 Daybreak 存取權,即可使用 /daybreak 開啟或關閉 Daybreak。Codex 會將你的選擇套用至目前的對話,並儲存為後續對話的預設值。
使用 /voice 與 Codex 進行語音對話
當 CLI 組建與工作階段都支援語音時,使用 /voice 或按 F8 即可開始或停止語音對話。使用 /voice mute 可開啟或關閉麥克風,使用 /voice stop 可結束對話。使用 /voice settings 可選擇後續對話使用的聲音。
使用 /plan 切換至規劃模式
- 輸入
/plan並按 Enter,將目前對話切換至規劃模式。 - 如有需要,可在指令後直接輸入提示詞,例如
/plan 請為這項服務擬定移轉計畫。 - 使用
/plan的行內引數時,也可以貼上內容或附加圖片。
預期結果:Codex 會進入規劃模式。如果你在指令後加上提示詞,Codex 會將其作為第一個規劃要求。
選擇是,清除上下文並開始實作,即可將完整計畫帶入新對話。若無法轉移計畫,Codex 會讓目前的對話保持開啟。
Codex 正在工作時,暫時無法使用 /plan。
使用 /goal 設定或查看任務目標
- 輸入
/goal <objective>以設定目標,例如/goal 完成移轉,並確保所有測試持續通過。 - 輸入
/goal以查看目前目標。 - 使用
/goal edit可修改目標。使用/goal pause、/goal resume或/goal clear可分別暫停、恢復或移除目標。
預期結果:工作持續進行時,Codex 會保留目前對話的目標。
目標內容不得為空,且最多可包含 4,000 個字元。若指示較長,請將詳情寫入檔案,並在目標中指定該檔案。
使用 /experimental 切換實驗性功能
- 輸入
/experimental並按 Enter。 - 開啟或關閉所需的功能(例如網路代理伺服器或執行時防止休眠)。如果出現重新啟動的提示,請重新啟動 Codex。
預期結果:Codex 會將功能選擇儲存至設定,並在重新啟動時套用。
使用 /approve 核准重試遭自動審查拒絕的操作
若近期有操作遭自動審查拒絕,而你想讓 Codex 重試一次,可使用 /approve。
- 輸入
/approve。 - Codex 顯示遭拒絕的操作後,確認要重試。
預期結果:Codex 會依目前工作階段的政策重試該操作一次。
使用 /memories 設定記憶
- 輸入
/memories。 - 選擇是否讓 Codex 使用現有記憶、產生新記憶,或繼續停用記憶功能。
預期結果:Codex 會更新相關記憶設定,供後續工作階段使用。
使用 /skills 套用技能
- 輸入
/skills。 - 選擇要讓 Codex 套用的技能。
預期結果:Codex 會插入所選技能的上下文,讓下一個要求遵循該技能的指示。
使用 /import 匯入 Claude Code 或 Cursor 設定
- 輸入
/import。 - 選擇 Claude Code 或 Cursor。
- 選擇要移轉的設定、專案檔案或近期對話。
Codex 會尋找過去 30 天內的對話,最多 50 個。連線至本機常駐程式或遠端伺服器時,Codex 會在執行該常駐程式或伺服器的電腦上讀取並匯入檔案。請等目前任務結束後再開始匯入。
如需桌面應用程式的操作流程與支援匯入的項目類型,請參閱從其他智慧體匯入。
使用 /clear 清除終端畫面並開始新對話
- 輸入
/clear並按 Enter。
預期結果:Codex 會清除終端畫面、重設可見的對話紀錄,並在同一個 CLI 工作階段中開始新對話。
若要在建立新對話時一併命名,請執行 /clear release prep。
與 Ctrl+L 不同,/clear 會開始新對話。
Ctrl+L 只會清除終端畫面,並保留目前對話。任務執行期間,Codex 會停用這兩項操作。
使用 /archive 封存目前的工作階段
- 輸入
/archive並按 Enter。 - 確認要封存目前的工作階段。
預期結果:Codex 會封存工作階段。若已連線至本機背景伺服器或遠端伺服器,Codex 會返回指令中心;若未使用共用伺服器,則會退出。Codex 會保留對話紀錄,日後可使用 codex unarchive <SESSION> 還原。
若有回合正在執行,確認 /archive 後,Codex 會先停止該回合,再封存工作階段。
使用 /delete 刪除目前的工作階段
- 輸入
/delete並按 Enter。 - 確認要刪除目前的工作階段。
預期結果:Codex 會永久刪除目前工作階段的對話紀錄、已儲存的支線對話,以及由此衍生的各層工作階段。若已連線至本機背景伺服器或遠端伺服器,Codex 會返回指令中心;若未使用共用伺服器,則會退出。
對話執行期間或在支線對話中,無法使用 /delete。
使用 /permissions 更新權限
- 輸入
/permissions並按 Enter。 - 選擇你能接受的核准預設設定。例如,選擇
Auto可讓作業自動執行,選擇Read Only(唯讀)則可審查修改。若已啟用具名權限設定檔,選擇器也會顯示已設定的自訂設定檔及其說明。
若要依 ID 為目前工作階段選取權限設定檔,請使用 /permissions <profile-id> [--approval-policy=<policy>] [--reviewer=user|auto_review]。例如,/permissions :workspace --approval-policy=on-request --reviewer=user 會選用工作區存取權,並在設定允許時將核准要求傳送給你。
使用 /ide 納入 IDE 上下文
- 輸入
/ide。 - 如有需要,可在指令後加上文字,說明你希望 Codex 如何處理目前在 IDE 中選取的內容或已開啟的檔案。
預期結果:Codex 會在下一個提示詞中納入可用的 IDE 上下文。
使用 /vim 切換 Vim 模式
- 輸入
/vim。 - 在撰寫工具中繼續編輯。
預期結果:Codex 會切換目前工作階段中撰寫工具的 Vim 模式。若要讓新工作階段預設使用 Vim 模式,請將 tui.vim_mode_default = true 加入 config.toml。
使用 /setup-default-sandbox 設定具提升權限的 Windows 沙盒
只有在 Windows 上且 Codex 正使用功能受限的限制權杖沙盒時,才會顯示此指令。
- 輸入
/setup-default-sandbox。 - 依照系統管理員設定流程操作。
預期結果:Codex 會設定具提升權限的 Windows 沙盒,並選取對應的自動核准預設設定。
使用 /copy 複製最新回覆
在回捲模式中,輸入 /copy 後,可以選取最近一次已完成的整則回覆,或只選取其中的程式碼區塊或引文。在全螢幕模式中,請從對話紀錄選取區塊。按 Enter 即可複製所選內容。
執行 /status 後,使用 /copy 可複製完整狀態或單一欄位。若要直接複製最近一次已完成的回覆,請按 Ctrl+ O 。
使用 /raw 切換原始回捲模式
- 輸入
/raw、/raw on或/raw off。
預期結果:Codex 會切換原始回捲模式,方便直接在終端中選取與複製文字。你也可以使用預設快速鍵 Alt+R,或透過 tui.raw_output_mode = true 將此模式儲存為預設值。
使用 /status 檢查工作階段
- 在任一對話中輸入
/status。 - 查看輸出中的目前模型、核准政策、可寫入的根目錄,以及目前的 Token 用量。TUI 使用遠端連線時,輸出也會顯示遠端位址與伺服器版本。
預期結果:Codex 會輸出摘要,讓你確認執行位置是否符合預期。
使用 /usage 查看帳戶用量
- 輸入
/usage以開啟用量選單。 - 選擇查看 Token 使用情形,或兌換已取得且可用的速率限制重設機會。
- 若要直接查看 Token 使用情形,請輸入
/usage daily、/usage weekly或/usage cumulative。
預期結果:Codex 會開啟用量操作選單,或顯示所選檢視範圍內的帳戶 Token 使用情形。如果工作階段尚未通過 Codex 服務帳戶驗證,Codex 會提示你登入。
使用 /debug-config 檢查設定層
- 輸入
/debug-config。 - 查看輸出中的設定層順序(優先順序由低至高)、啟用或停用狀態,以及政策來源。
預期結果:Codex 會輸出各層的診斷資訊與政策詳情,例如已設定的 allowed_approval_policies、allowed_sandbox_modes、mcp_servers、rules 和 network_proxy。
若實際生效的設定與 config.toml 不同,可透過這些輸出找出原因。
使用 /statusline 設定底部顯示項目
- 輸入
/statusline。 - 在選擇器中開啟或關閉項目並調整順序,然後確認。
預期結果:底部狀態列會立即更新,所選項目會儲存至 tui.status_line 設定(位於 config.toml)。
狀態列可顯示的項目包括模型、模型與推理強度、上下文統計資料、速率限制、Git 分支、Token 計數器、工作階段 ID、目前目錄/專案根目錄,以及 Codex 版本。
若只想設定目前工作階段的底部狀態列,請依顯示順序列出項目。例如,/statusline model project-name 會先顯示模型,再顯示專案名稱。使用 /statusline --clear 可隱藏目前工作階段的所有狀態列項目。
使用 /title 設定終端標題項目
- 輸入
/title。 - 在選擇器中開啟或關閉項目並調整順序,然後確認。
預期結果:終端視窗或分頁的標題會立即更新,所選項目會儲存至 tui.terminal_title 設定(位於 config.toml)。
標題可顯示的項目包括應用程式名稱、專案、旋轉進度指示器、狀態、執行緒、Git 分支、模型和任務進度。
若只想設定目前工作階段的標題,請依顯示順序列出項目。例如,/title project-name model 會先顯示專案名稱,再顯示模型。使用 /title --clear 可清除目前工作階段的標題項目。
使用 /theme 選擇語法佈景主題
- 輸入
/theme。 - 在選擇器中預覽佈景主題,然後確認。
預期結果:Codex 會更新語法醒目提示,並將選擇儲存至 tui.theme 設定(位於 config.toml)。
使用 /pets 選擇終端寵物
- 輸入
/pets(或/pet)以開啟寵物選擇器。 - 選擇內建或自訂寵物,或關閉寵物功能。
預期結果:Codex 會在支援的終端中顯示所選寵物,並儲存你的選擇。你也可以輸入 /pets off 以隱藏寵物。
使用 /keymap 重新設定 TUI 快速鍵
使用 /keymap 可檢查、更新並儲存 TUI 的鍵盤快速鍵繫結。
- 輸入
/keymap。 - 選擇要變更的快速鍵適用情境與操作。
- 輸入新的按鍵組合,或移除現有繫結。
預期結果:Codex 會更新目前的按鍵對應,並將自訂繫結寫入 tui.keymap 設定(位於 config.toml)。
按鍵繫結使用 ctrl-a、shift-enter 和 page-down 等名稱。特定情境的繫結會覆寫 tui.keymap.global。將繫結清單留空即可解除該操作的按鍵繫結。
使用 /ps 檢查背景終端
- 輸入
/ps。 - 查看背景終端清單與各終端的狀態。
預期結果:Codex 會顯示各背景終端執行的指令,以及最近最多三行非空白輸出,方便你快速掌握進度。
使用 unified_exec 時才會顯示背景終端,否則清單可能是空的。
使用 /stop 停止背景終端
- 輸入
/stop。 - 如果 Codex 在停止清單中的終端前要求確認,請確認操作。
預期結果:Codex 會停止目前工作階段的所有背景終端。你仍可使用 /clean 作為 /stop 的別名。
使用 /compact 精簡對話紀錄
- 在進行長時間對話後,輸入
/compact。 - 當 Codex 詢問是否要摘要目前為止的對話時,確認操作。
預期結果:Codex 會以精簡摘要取代先前回合,在保留重要細節的同時釋出上下文空間。
使用 /diff 檢查變更
- 輸入
/diff以檢查 Git 差異。 - 在 CLI 中捲動輸出內容,查看修改與新增的檔案。
預期結果:Codex 會顯示已暫存的變更、尚未暫存的變更,以及 Git 尚未追蹤的檔案,方便你決定要保留哪些內容。
使用 /mention 指定檔案
- 輸入
/mention並在後方加上路徑,例如/mention src/lib/api.ts。 - 從彈出式選單中選擇相符的結果。
預期結果:Codex 會將該檔案加入對話,供後續回合直接參照。
使用 /new 開始新對話
- 輸入
/new並按 Enter。 - 如果 Codex 詢問要使用哪份簽出副本,請選擇目前目錄或新的工作樹。
預期結果:Codex 會在同一個 CLI 工作階段中開始新對話,讓你直接在終端中切換對話。
若要在建立新對話時一併命名,請執行 /new bug bash。
與 /clear 不同,/new 不會先清除目前的終端畫面。
使用 /rename 重新命名目前的對話
- 輸入
/rename <name>,或輸入/rename以開啟命名提示。 - 輸入簡短且容易辨認的名稱,以便日後找到對話。
預期結果:Codex 會更新已儲存的對話名稱,並保留原有對話紀錄。
使用 /resume 恢復已儲存的對話
- 輸入
/resume並按 Enter。 - 在選擇器中選擇搜尋範圍。
Cwd會顯示目前目錄中的對話。若有Repo選項,其範圍也包括已連結的本機工作樹中對應的目錄。All則會跨目錄搜尋。 - 選取要恢復的對話。
預期結果:Codex 會重新載入所選對話的紀錄,讓你從上次中斷處繼續,並完整保留原有歷程。
使用 /fork 建立目前對話的分支
- 輸入
/fork並按 Enter。 - 如果 Codex 詢問要使用哪份簽出副本,請選擇目前目錄或新的工作樹。
預期結果:Codex 會複製目前對話,建立具有新 ID 的對話。原始對話紀錄會保持完整,讓你可以同時嘗試其他做法。
若要從已儲存的工作階段而非目前的工作階段建立分支,請在終端中執行 codex fork 以開啟工作階段選擇器。
使用 /app 在桌面應用程式中繼續對話
在 macOS 或 Windows 上輸入 /app,即可在 ChatGPT 桌面應用程式中開啟目前的工作階段。如果應用程式尚未安裝或未執行,Codex 會顯示錯誤訊息,提示你安裝或啟動應用程式。
預期結果:桌面應用程式會開啟同一個已儲存的對話,讓你接續工作。
使用 /side 開始支線對話
主要對話繼續進行時,你可以使用 /side 在獨立的對話中追問。
- 輸入
/side以開啟支線對話。 - 如有需要,可在指令後加上文字,例如
/side 檢查這個計畫是否有明顯風險。 - 處理完支線問題後,返回上層對話。
預期結果:Codex 會開啟支線對話,其紀錄與上層對話分開。在支線模式中,TUI 仍會顯示上層對話的狀態,讓你知道主要對話是否仍在執行。
支線對話預設為臨時對話。在本機全螢幕工作階段中,如果已啟用 features.tui_workspace,且有已儲存的歷程記錄可用,輸入 /side 會重新開啟現有的支線對話,輸入 /side <prompt> 則會開始新的支線對話。重新啟動 Codex 後,你可以從側邊欄重新開啟已儲存的支線對話。
在支線對話中或審查模式下,無法使用 /side。
產生 AGENTS.md 的指令 /init
- 在希望 Codex 尋找持續適用指示的目錄中執行
/init。 - 檢查產生的
AGENTS.md,再依程式碼庫的慣例編輯內容。
預期結果:Codex 會建立 AGENTS.md 範本,你可以加以調整並提交,供後續工作階段使用。
使用 /review 要求審查工作樹
- 輸入
/review。 - 若要檢查檔案的具體變更,可接著執行
/diff。
預期結果:Codex 會摘要它在工作樹中發現的問題,著重於行為變更與缺少的測試。預設會使用目前工作階段的模型,除非你已將 review_model 設定在 config.toml 中。
使用 /mcp 列出 MCP 工具
- 輸入
/mcp。 - 查看清單,確認有哪些 MCP 伺服器與工具可供使用。
預期結果:你會看到已設定且 Codex 可在此工作階段中呼叫的模型上下文協定(MCP)工具。
使用 /mcp verbose 可一併顯示詳細的伺服器診斷資訊。使用 /mcp login <name> 可從目前工作階段登入已設定的 MCP 伺服器。
使用 /apps 瀏覽應用程式
- 輸入
/apps。 - 從清單中選擇應用程式。
預期結果:Codex 會以 $app-slug 的形式將應用程式參照插入撰寫工具,讓你可以立即請 Codex 使用它。
使用 /plugins 瀏覽外掛程式
- 輸入
/plugins。 - 選擇市集分頁,再選取外掛程式以查看其功能或可用操作。
預期結果:Codex 會開啟外掛程式瀏覽器,讓你查看已安裝的外掛程式及其狀態,以及目前設定允許探索的外掛程式。選取已安裝的外掛程式後,按 Space 即可啟用或停用該外掛程式。
使用 /hooks 檢視與管理生命週期掛鉤
- 輸入
/hooks。 - 選擇掛鉤事件以檢查相符的處理常式。
- 視需要將非受管理的掛鉤標為信任、停用或重新啟用。
預期結果:Codex 會開啟掛鉤瀏覽器,讓你檢查已設定的生命週期掛鉤。受管理的掛鉤會標示為受管理,且無法從使用者掛鉤瀏覽器停用。
使用 /agents 管理對話
- 輸入
/agents並按 Enter,或在終端中執行codex agents。 - 若要尋找較早的對話,請按 F3 或 / ,然後輸入對話名稱、提示詞預覽或工作目錄中的部分文字。搜尋不區分大小寫。
- 選取要開啟的對話。
在 macOS 和 Linux 上,已使用 ChatGPT 登入且符合資格的本機工作階段可以使用實驗性的雲端連線功能。先啟用 features.tui_multi_backend,再於送出第一個提示詞前,使用新對話撰寫工具中顯示的主機切換快速鍵,從「本機」切換至「雲端」。在雲端對話中,你可以傳送圖片、為下一回合選擇模型與推理強度,以及封存或還原對話。
使用 /subagents 切換智慧體執行緒
- 輸入
/subagents並按 Enter。 - 在選擇器中選取所需的執行緒。
預期結果:Codex 會切換至所選執行緒,讓你檢查或繼續該智慧體的工作。
使用 /feedback 傳送意見回饋
- 輸入
/feedback並按 Enter。 - 選擇意見回饋類別,並決定是否附上記錄。
- 在意見編輯器中按 Enter 即可送出回饋。若使用本機連線,也可以按 Ctrl+ S ,改將診斷資料儲存為 ZIP 檔。
Codex 會顯示 ZIP 檔的路徑。即使設定禁止上傳,你仍可儲存這個檔案。
使用 /logout 登出
- 輸入
/logout並按 Enter。
預期結果:Codex 會清除目前使用者工作階段的本機憑證。
使用 /quit 或 /exit 離開 CLI
- 輸入
/quit(或/exit)並按 Enter。
預期結果:Codex 會立即退出。請先儲存或提交重要的工作。
使用這些指令可從 VS Code 的命令選擇區操作 Codex。你也可以為這些指令設定鍵盤快速鍵。
指派快速鍵
若要為 Codex 指令指派或變更快速鍵:
- 開啟命令選擇區(macOS 按 Cmd+Shift+P,Windows 或 Linux 按 Ctrl+Shift+P)。
- 執行喜好設定:開啟鍵盤快速鍵。
- 搜尋
Codex或指令 ID(例如chatgpt.newChat)。 - 選取鉛筆圖示,再輸入所需的快速鍵。
擴充功能指令
| 指令 | 預設快速鍵 | 說明 |
|---|---|---|
chatgpt.addToThread |
- | 將選取範圍內的文字加入目前對話的上下文 |
chatgpt.addFileToThread |
- | 將整個檔案加入目前對話的上下文 |
chatgpt.newChat |
macOS:Cmd+NWindows/Linux: Ctrl+N |
建立新對話 |
chatgpt.newCodexPanel |
- | 建立新的 Codex 面板 |
chatgpt.openCommandMenu |
- | 開啟 Codex 指令選單 |
chatgpt.openSidebar |
- | 開啟 Codex 側邊欄面板 |
斜線指令讓你直接在撰寫工具中操作 Codex。你可以用這些指令檢查狀態、在本機與雲端模式之間切換,或傳送意見回饋。
使用斜線指令
- 在 Codex 撰寫工具中輸入
/。 - 從清單中選取指令,或繼續輸入以篩選清單(例如
/status)。 - 按 Enter。
可用的斜線指令
| 斜線指令 | 說明 |
|---|---|
/approve |
啟用自動審查時,核准重試一次近期遭自動審查拒絕的操作。 |
/cloud |
雲端執行可用時,在雲端執行對話。 |
/cloud-environment |
選擇對話使用的雲端環境。 |
/compact |
壓縮目前對話的上下文。 |
/fast |
模型目錄提供快速服務層級時,可將其開啟或關閉。 |
/feedback |
開啟意見回饋對話方塊以提交意見,也可一併附上記錄。 |
/fork |
將本機對話複製為新的本機對話。 |
/goal |
設定目標,讓 Codex 持續朝該目標工作。 |
/ide-context |
開啟或關閉自動加入 IDE 上下文的功能。 |
/init |
為目前專案產生 AGENTS.md 範本。 |
/local |
在本機工作區中執行對話。 |
/mcp |
開啟 MCP 狀態以查看已連線的伺服器。 |
/memories |
記憶功能可用時,設定對話是否可使用或產生記憶。 |
/model |
選擇目前對話使用的模型。 |
/plan |
開啟或關閉規劃模式,以規劃多步驟任務。 |
/project |
為新對話選擇專案。 |
/reasoning |
選擇目前對話的推理強度。 |
/review |
啟動程式碼審查模式,以審查尚未提交的變更或與基底分支比較。 |
/side |
開始臨時的支線對話,同時讓主要對話繼續進行。 |
/status |
顯示對話 ID、上下文用量與速率限制。 |
/worktree |
在新的 Git 工作樹中執行對話。 |