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 | 覆盖配置中指定的模型(例如 gpt-6.2-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.2-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 套接字,使用 --remote unix:// 连接默认套接字,或使用 --remote unix://PATH 指定路径。如果服务器要求使用持有者令牌进行 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:// 保留通过标准输入输出传输 JSONL 的默认行为,codex app-server --stdio 是这种传输方式的别名。--listen ws://IP:PORT 为 App Server 客户端启用 WebSocket 传输。服务器接受 ws:// 监听 URL。如果客户端通过 wss:// 连接,请使用 TLS 终止或安全代理。使用 --listen unix:// 可在 Codex 的默认 Unix 套接字上接受 WebSocket 握手,也可使用 --listen unix:///absolute/path.sock 指定套接字路径。如果您要为客户端绑定生成模式,请添加 --experimental 以包含受功能开关控制的字段和方法。
使用 --code-mode-host https://code-mode.example.com 可让 App Server 进程中的所有线程通过 gRPC 连接到远程代码模式主机。--listen 控制客户端连接 App Server 的方式。
codex remote-control
运行 codex remote-control 启动远程控制。条件允许时,Codex 会使用托管后台服务器,否则会在前台运行。要明确指定在前台运行,请使用 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 格式输出模型实际可见的提示词输入列表。调试指令查找、会话上下文或提示词构建过程时,可使用此命令。
| 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纯文本输出先打印任务 URL,然后显示状态详情。如需自动化处理,请使用 --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 会创建派生会话,但不会发起新一轮交互。将 - 作为提示词参数传入,可从标准输入读取提示词。添加 --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 子命令支持标准输入输出和可流式传输的 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 URL、SSH Git URL,以及本地市场根目录。使用 --ref 可固定 Git 引用。对于使用 Git 的市场代码仓库,可重复指定 --sparse PATH 以进行稀疏检出。
codex plugin marketplace list 输出当前范围内的市场名称和根目录,包括自动发现的默认市场和已配置的市场快照。
为市场的添加、列出、升级或移除命令添加 --json,可获得便于自动化处理的输出。添加市场的 JSON 输出包含 marketplaceName、installedRoot 和 alreadyAdded。列出市场的 JSON 输出包含 marketplaces 数组,其中各项包含 name、root 和可选的 marketplaceSource。升级市场的 JSON 输出包含 selectedMarketplaces、upgradedRoots 和 errors。移除市场的 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 更新。如果使用的是调试版本,Codex 会提示您安装发行版本。
标志组合和安全提示
- 对于可在工作空间内完成的无人值守本地任务,请使用
--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 空间。 | 长时间运行后保留要点,避免超出上下文窗口容量。 |
/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.2 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 完成工作后运行,或让 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 的情况下管理会话。
使用 /config 更改终端偏好设置
输入 /config 打开终端偏好设置。您可以按组浏览设置,也可以按 / 搜索。Codex 会自动保存更改。
使用 /tui 选择终端模式
- 输入
/tui。 - 选择回滚模式或全屏模式,然后确认。
- 重启 Codex 以应用所选模式。
预期结果:下次启动时会使用已保存的终端模式。--no-alt-screen 等启动时指定的覆盖选项仍会生效。
使用 /export 导出对话
- 输入
/export。 - 选择复制到剪贴板或保存到文件。
预期结果:Codex 将完整对话导出为 Markdown。要直接保存到文件,请运行 /export session.md。请等当前轮次结束后再导出。
使用 /recap 总结聊天
- 在 Codex 空闲时输入
/recap。
预期结果:即使设置了 tui.auto_recap = false,Codex 也会生成对话摘要。如果您想释放上下文空间,请使用 /compact。
使用 /cd 切换目录
- 输入
/pwd(或/cwd)查看当前目录。 - 输入
/cd <path>切换目录,或输入/cd切换到您的主目录。
预期结果:Codex 在所选目录中继续聊天。只有主会话处于空闲状态,且没有排队的输入或后台终端时,才能切换目录。
使用 /worktree 在工作树中继续聊天
- 在本地 Git 代码仓库中输入
/worktree。 - 选择在新工作树中开始新聊天,还是继续当前对话。
预期结果:Codex 创建托管的 Git 工作树,并在其中打开所选聊天。选择浏览工作树可查找现有工作树及其所属聊天。此命令要求本地支持工作树,且在任务运行期间不可用。
使用 /daemon 管理后台服务器
- 输入
/daemon。 - 查看服务器连接和可用操作。
预期结果:Codex 会让您选择安装最新的公开稳定版,或使用当前 CLI 构建版本来运行本地后台服务器。确认更新会退出 Codex,并可能中断正在进行的工作。要重启托管的本地服务器,请选择重启后台服务器并确认。Codex 会自动重新连接。重启可能会中断其他聊天中正在运行或排队等待的任务。如果使用远程连接,请在服务器所在的主机上进行管理。
使用 /warnings 检查警告
- 输入
/warnings。
预期结果:Codex 显示已保留的警告及其诊断详情。
使用 /model 设置当前模型
选择器会显示您的账户和工作空间可用的模型。请参阅各套餐的模型可用情况。
- 启动 Codex 并打开编辑器。
- 输入
/model并按 Enter。 - 从列表中选择模型。对于复杂的调试任务,请选择 GPT-6.2 Astra。对于日常编程,请选择 GPT-6.2 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 会先停止该轮次,再归档会话。
使用 /delete 删除当前会话
- 输入
/delete并按 Enter。 - 确认删除当前会话。
预期结果:Codex 永久删除当前会话的聊天记录、已保存的旁支聊天,以及由此会话创建的所有后代会话。如果已连接到本地后台服务器或远程服务器,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。 - 在选择器中开启或关闭项目,调整顺序,然后确认。
预期结果:页脚状态栏立即更新。Codex 将所选项目作为 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 显示各后台终端运行的命令,并列出最近最多 3 行非空输出,方便您快速判断进度。
使用 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 工作树中运行聊天。 |