Using Codex

CLI 斜杠命令

用 CLI 斜杠命令快速触发常见 Codex 操作。

Slash commands give you fast, keyboard-first control over Codex。输入 / in the composer 到 打开 the slash popup, 选择 a command, 和 Codex will perform actions such as switching models, adjusting permissions, 或 summarizing long conversations 不使用 leaving the terminal.

本指南会说明如何:

Find the right built-in slash command for a task

Steer an active session 使用 commands like /model, /fast, /personality, /permissions, /approve, /raw, /agent, 和 /status

内置 slash commands

Codex 内置以下 commands。打开 slash popup 并开始输入 command name,即可过滤列表。

Command用途何时使用
/permissions 设置 what Codex can do 不使用 asking first.Relax 或 tighten approval requirements mid-session, such as switching between Auto 和 读取 Only.
/ide Include 打开 files, 当前 selection, 和 other IDE context.Pull editor context into the next prompt 不使用 re-explaining what’s 打开 in your IDE.
/keymap Remap TUI keyboard shortcuts.Inspect 和 持久化 custom shortcut bindings in config.toml.
/vim 切换 Vim mode for the composer.切换 between Vim normal/insert behavior 和 the 默认 composer editing mode.
/sandbox-add-read-dir Grant sandbox 读取 access 到 an extra directory (Windows only).Unblock commands that need 到 读取 an absolute directory path outside the 当前 readable roots.
/agent 切换 the active agent thread.Inspect 或 continue work in a spawned subagent thread.
/apps Browse apps (connectors) 和 insert them into your prompt.附加 an app as $app-slug 之前 asking Codex 到 使用 it.
/plugins Browse installed 和 discoverable plugins.Inspect plugin tools, 安装 suggested plugins, 或 manage plugin availability.
/hooks View 和 manage lifecycle hooks.Inspect configured hooks, trust 新的 或 changed hooks, 或 disable non-managed hooks 之前 they 运行.
/clear Clear the terminal 和 启动 a fresh chat.Reset the visible UI 和 conversation together 当 you want a fresh 启动.
/archive 归档 the 当前 session 和 exit Codex.移除 the 当前 session 从 active session lists 不使用 deleting its transcript.
/delete Permanently 删除 the 当前 session 和 exit Codex.移除 the transcript 和 descendant sessions 当 archiving isn’t enough.
/compact Summarize the visible conversation 到 free tokens.使用 之后 long runs so Codex retains key points 不使用 blowing the context window.
/copy 复制 the latest completed Codex output.Grab the latest finished response 或 plan text 不使用 manually selecting it。You can also 按 Ctrl+O.
/diff 显示 the Git diff, including files Git isn’t tracking yet.检查 Codex’s edits 之前 you commit 或 运行 tests.
/exit Exit the CLI (same as /quit ).Alternative spelling;both commands exit session.
/experimental 切换 experimental features.Enable 可选 features such as subagents 从 the CLI.
/approve Approve one retry of a 最近 auto 检查 denial.Retry a command 或 action that the auto reviewer denied.
/memories 配置 memory 使用 和 generation.Turn memory injection 或 memory generation on 或 off 不使用 leaving the TUI.
/skills Browse 和 使用 skills.Improve task-specific behavior by selecting a relevant local skill.
/import Import Claude Code setup, project files, 和 最近 chats.Migrate 支持的 external-agent artifacts into Codex configuration 和 local files.
/feedback Send logs 到 the Codex maintainers.Report issues 或 share diagnostics 使用 support.
/init 生成 an AGENTS.md scaffold in the 当前 directory.Capture 持久化ent instructions for repository 或 subdirectory you’re working in.
/logout Sign out of Codex.Clear local credentials 当 using a shared machine.
/mcp 列出 configured Model Context Protocol (MCP) tools.Check which external tools Codex can call during session;添加 verbose for server details.
/mention 附加 a file 到 the conversation.Point Codex at specific files 或 folders you want it 到 inspect next.
/model 选择 the active model (和 reasoning effort, 当 可用).切换 between general-purpose models (gpt-4.1-mini) 和 deeper reasoning models 之前 running a task.
/fast 切换 a Fast service tier 当 the model catalog exposes one.Turn the 当前 model’s Fast tier on 或 off, 或 check whether the thread is using it.
/plan 切换 到 plan mode 和 可选ly send a prompt.Ask Codex 到 propose an execution plan 之前 implementation work starts.
/goal 设置, pause, 恢复, view, 或 clear a task goal.Give Codex a 持久化ent target 到 track while a larger task runs.
/personality 选择 a communication style for responses.Make Codex more concise, more explanatory, 或 more collaborative 不使用 changing your instructions.
/ps 显示 experimental background terminals 和 their 最近 output.Check long-running commands 不使用 leaving the main transcript.
/stop Stop all background terminals.Cancel background terminal work started by the 当前 session.
/fork Fork the 当前 conversation into a 新的 thread.Branch the active session 到 explore a 新的 approach 不使用 losing the 当前 transcript.
/side, /btw 启动 an ephemeral side conversation.Ask a focused follow-up 不使用 disrupting the main thread’s transcript.
/raw 切换 raw scrollback mode.Make terminal selection 和 copying less formatted while reviewing long output.
/resume 恢复 a saved conversation 从 your session 列出.Continue work 从 a previous CLI session 不使用 starting over.
/new 启动 a 新的 conversation inside the same CLI session.Reset the chat context 不使用 leaving the CLI 当 you want a fresh prompt in the same repo.
/quit Exit the CLI.Leave session 立即.
/review Ask Codex 到 检查 your working tree.运行 之后 Codex completes work 或 当 you want a second 设置 of eyes on local changes.
/status Display session configuration 和 token usage.确认 the active model, approval policy, writable roots, 和 remaining context capacity.
/usage View account token usage 或 使用 a rate-limit reset.Inspect daily, weekly, 或 cumulative ChatGPT token activity 从 inside the TUI.
/debug-config 打印 config layer 和 requirements diagnostics.Debug precedence 和 policy requirements, including experimental network constraints.
/statusline 配置 TUI status-line fields interactively.Pick 和 reorder footer items (model/context/limits/git/tokens/session) 和 持久化 in config.toml.
/title 配置 terminal window 或 tab title fields interactively.Pick 和 reorder title items such as project, status, thread, branch, model, 和 task progress.
/theme 选择 a syntax-highlighting theme.Preview 和 持久化 a terminal syntax-highlighting theme.

/quit 和 /exit 都会退出 CLI。请只在保存或提交重要工作之后使用它们。

使用 /permissions 调整 Codex 可以在不先询问的情况下执行什么。只有当你需要重试最近被 automatic review 拒绝的 action 时,才使用 /approve。

使用 slash commands 控制 session

The following workflows keep your session on track 不使用 restarting Codex.

设置 the active model 使用 /model

启动 Codex 和 打开 the composer.

输入 /model 和 按 Enter.

选择 a model such as gpt-4.1-mini 或 gpt-4.1 从 popup.

预期结果: Codex confirms the 新的 model in the transcript。运行 /status 到 verify the change.

切换 Fast mode 使用 /fast

输入 /fast on, /fast off, 或 /fast status.

如果 you want the setting 到 持久化, 确认 the update 当 Codex offers 到 save it.

预期结果: Codex reports whether the 当前 model’s Fast service tier is on 或 off for the 当前 thread。In the TUI footer, you can also 显示 a Fast mode status-line item 使用 /statusline.

Fast tier commands are catalog-driven。如果 the 当前 model doesn’t advertise a Fast tier, Codex won’t 显示 /fast.

设置 a communication style 使用 /personality

使用 /personality 到 change how Codex communicates 不使用 rewriting your prompt.

In an active conversation, 输入 /personality 和 按 Enter.

选择 a style 从 popup.

预期结果: Codex confirms the 新的 style in the transcript 和 uses it for later responses in the thread.

Codex supports friendly, pragmatic, 和 none personalities。使用 none 到 disable personality instructions.

如果 the active model doesn’t support personality-specific instructions, Codex hides this command.

切换 到 plan mode 使用 /plan

输入 /plan 和 按 Enter 到 切换 the active conversation into plan mode.

Optional:provide inline prompt text (例如, /plan Propose a migration plan for this service).

You can paste content 或 附加 images while using inline /plan arguments.

预期结果: Codex enters plan mode 和 uses your 可选 inline prompt as the first planning request.

While a task is already running, /plan is 暂时 un可用.

设置 或 view a task goal 使用 /goal

输入 /goal <objective> 到 设置 the goal, 例如 /goal Finish the migration 和 keep tests green.

输入 /goal 到 view the 当前 goal.

使用 /goal pause, /goal 恢复, 或 /goal clear 到 pause, 恢复, 或 移除 it.

预期结果: Codex keeps the goal attached 到 the active thread while work continues.

Goal objectives must be non-empty 和 at most 4,000 characters。For longer instructions, put the details in a file 和 point the goal at that file.

切换 experimental features 使用 /experimental

输入 /experimental 和 按 Enter.

切换 the features you want (例如, Apps 或 Smart Approvals), then restart Codex 如果 prompt asks you 到.

预期结果: Codex saves your feature choices 到 config 和 applies them on restart.

Approve an auto 检查 denial 使用 /approve

使用 /approve 当 the automatic reviewer denied a 最近 action 和 you want Codex 到 retry it once.

输入 /approve.

确认 the retry 当 Codex shows the relevant denied action.

预期结果: Codex retries that denied action once under the 当前 session policy.

配置 memories 使用 /memories

输入 /memories.

选择 whether Codex should 使用 已有 memories, 生成 新的 memories, 或 keep memory behavior disabled.

预期结果: Codex updates the relevant memory settings for future sessions.

使用 skills 使用 /skills

输入 /skills.

Pick the skill you want Codex 到 应用.

预期结果: Codex inserts the selected skill context so the next request follows that skill’s instructions.

Import Claude Code configuration 使用 /import

输入 /import.

选择 the Claude Code setup, project files, 或 最近 chats you want 到 migrate.

预期结果: Codex opens the external-agent import picker 和 imports the selected 支持的 artifacts into Codex configuration 和 local files.

运行 /import 从 a local TUI session。It’s un可用 while a task is running, in remote sessions, 和 while connected 到 the local app-server daemon.

Clear the terminal 和 启动 a 新的 chat 使用 /clear

输入 /clear 和 按 Enter.

预期结果: Codex clears the terminal, resets the visible transcript, 和 starts a fresh chat in the same CLI session.

Unlike Ctrl+L, /clear starts a 新的 conversation.

Ctrl+L only clears the terminal view 和 keeps the 当前 chat。Codex disables both actions while a task is in progress.

归档 the 当前 session 使用 /归档

输入 /归档 和 按 Enter.

确认 that you want 到 归档 the 当前 session 和 exit Codex.

预期结果: Codex archives the 当前 session 和 closes the interactive TUI。Codex keeps session transcript stored locally;restore it later 使用 codex unarchive <SESSION>.

/archive is unavailable while a task is running.

删除 the 当前 session 使用 /删除

输入 /删除 和 按 Enter.

确认 that you want 到 删除 the 当前 session 和 exit Codex.

预期结果: Codex deletes the 当前 session transcript 和 closes the interactive TUI。Deletion is permanent 和 also removes spawned descendant sessions.

/delete is unavailable while a task is running or in a side conversation.

Update permissions 使用 /permissions

输入 /permissions 和 按 Enter.

选择 the approval preset that matches your comfort level, 例如 Auto for hands-off runs 或 读取 Only 到 检查 edits。当 named permission profiles are active, picker also shows configured custom profiles 和 their descriptions.

预期结果: Codex announces the updated policy。Future actions respect the updated approval mode until you change it again.

Include IDE context 使用 /ide

输入 /ide.

添加 可选 inline text 如果 you want 到 explain what Codex should do 使用 the 当前 IDE selection 或 打开 files.

预期结果: Codex includes 可用 IDE context in the next prompt.

切换 Vim mode 使用 /vim

输入 /vim.

Continue editing in the composer.

预期结果: Codex toggles composer Vim mode for the 当前 session。To make Vim mode the 默认 for 新的 sessions, 设置 tui.vim_mode_默认 = true in config.toml.

复制 the latest response 使用 /复制

输入 /复制 和 按 Enter.

预期结果: Codex copies the latest completed Codex output 到 your clipboard.

如果 a turn is still running, /复制 uses the latest completed output 而不是 the in-progress response。The command is un可用 之前 the first completed Codex output 和 立即 之后 a rollback.

You can also 按 Ctrl+O 从 the main TUI 到 复制 the latest completed response 不使用 opening the slash command menu.

切换 raw scrollback 使用 /raw

输入 /raw, /raw on, 或 /raw off.

预期结果: Codex toggles raw scrollback mode, which makes terminal selection 和 copying more direct。You can also 使用 the 默认 Alt+R binding 或 持久化 the 默认 使用 tui.raw_output_mode = true.

Grant sandbox 读取 access 使用 /sandbox-add-read-dir

This command is 可用 only 当 running the CLI natively on Windows.

输入 /sandbox-add-read-dir C:\absolute\directory\path 和 按 Enter.

确认 the path is an 已有 absolute directory.

预期结果: Codex refreshes the Windows sandbox policy 和 grants 读取 access 到 that directory for later commands that 运行 in the sandbox.

Inspect session 使用 /status

In any conversation, 输入 /status.

检查 the output for the active model, approval policy, writable roots, 和 当前 token usage。当 the TUI connects remotely, the output also shows the remote address 和 the server version.

预期结果: Codex prints a summary confirming that it’s operating where you expect.

View account usage 使用 /usage

输入 /usage 到 打开 the usage menu.

选择 whether 到 显示 token activity 或 redeem an 可用 earned reset.

To 打开 token activity directly, 输入 /usage daily, /usage weekly, 或 /usage cumulative.

预期结果: Codex opens usage actions 或 shows account token activity for the selected view。如果 session doesn’t have Codex service account auth, Codex shows a sign-in requirement.

Inspect config layers 使用 /debug-config

输入 /debug-config.

检查 the output for config layer order (lowest precedence first), on/off state, 和 policy sources.

预期结果: Codex prints layer diagnostics plus policy details such as allowed_approval_policies, allowed_sandbox_modes, mcp_servers, rules, enforce_residency, 和 experimental_network 当 configured.

使用 this output 到 debug why an effective setting differs 从 config.toml.

输入 /statusline.

使用 picker 到 切换 和 reorder items, then 确认.

预期结果: The footer status line updates 立即 和 持久化s 到 tui.status_line in config.toml.

Available status-line items include model, model+reasoning, context stats, rate limits, git branch, token counters, session id, 当前 directory/project root, 和 Codex version.

配置 terminal title items 使用 /title

输入 /title.

使用 picker 到 切换 和 reorder items, then 确认.

预期结果: The terminal window 或 tab title updates 立即 和 持久化s 到 tui.terminal_title in config.toml.

Available title items include app name, project, spinner, status, thread, git branch, model, 和 task progress.

选择 a syntax theme 使用 /theme

输入 /theme.

Preview a theme 从 picker, then 确认.

预期结果: Codex updates syntax highlighting 和 持久化s the choice 到 tui.theme in config.toml.

Remap TUI shortcuts 使用 /keymap

使用 /keymap 到 inspect, update, 和 持久化 keyboard shortcut bindings for the TUI.

输入 /keymap.

Pick the shortcut context 和 action you want 到 change.

Enter the 新的 binding 或 移除 the 已有 one.

预期结果: Codex updates the active keymap 和 writes the custom binding 到 tui.keymap in config.toml.

Key bindings 使用 names such as ctrl-a, shift-enter, 和 page-down。Context-specific bindings override tui.keymap.global;an empty binding 列出 unbinds the action.

Check background terminals 使用 /ps

输入 /ps.

检查 the 列出 of background terminals 和 their status.

预期结果: Codex shows each background terminal’s command plus up 到 three 最近, non-empty output lines so you can gauge progress at a glance.

Background terminals appear 当 unified_exec is in 使用;otherwise, the 列出 may be empty.

Stop background terminals 使用 /stop

输入 /stop.

确认 如果 Codex asks 之前 stopping the listed terminals.

预期结果: Codex stops all background terminals for the 当前 session。/clean is still 可用 as an alias for /stop.

Keep transcripts lean 使用 /compact

After a long exchange, 输入 /compact.

确认 当 Codex offers 到 summarize the conversation so far.

预期结果: Codex replaces earlier turns 使用 a concise summary, freeing context while keeping critical details.

检查 changes 使用 /diff

输入 /diff 到 inspect the Git diff.

Scroll through the output inside the CLI 到 检查 edits 和 added files.

预期结果: Codex shows changes you’ve staged, changes you haven’t staged yet, 和 files Git hasn’t started tracking, so you can decide what 到 keep.

Highlight files 使用 /mention

输入 /mention followed by a path, 例如 /mention src/lib/api.ts.

选择 the matching result 从 popup.

预期结果: Codex adds file 到 the conversation, ensuring follow-up turns reference it directly.

启动 a 新的 conversation 使用 /新的

输入 /新的 和 按 Enter.

预期结果: Codex starts a fresh conversation in the same CLI session, so you can 切换 tasks 不使用 leaving your terminal.

Unlike /clear, /新的 doesn’t clear the 当前 terminal view first.

恢复 a saved conversation 使用 /恢复

输入 /恢复 和 按 Enter.

选择 session you want 从 the saved-session picker.

预期结果: Codex reloads the selected conversation’s transcript so you can pick up where you left off, keeping the original history intact.

Fork the 当前 conversation 使用 /fork

输入 /fork 和 按 Enter.

预期结果: Codex clones the 当前 conversation into a 新的 thread 使用 a fresh ID, leaving the original transcript untouched so you can explore an alternative approach in parallel.

如果 you need 到 fork a saved session 而不是 the 当前 one, 运行 codex fork in your terminal to open the session picker.

启动 a side conversation 使用 /side

使用 /side 到 启动 an ephemeral fork 从 the 当前 conversation 不使用 switching away 从 the main task.

输入 /side 到 打开 a side conversation.

Optionally 添加 inline text, 例如 /side Check whether this plan has an obvious risk.

Return 到 the parent thread 之后 the focused detour finishes.

预期结果: Codex opens a side conversation whose transcript is separate 从 the parent thread。While you are in side mode, the TUI continues 到 显示 parent-thread status so you can see whether the main task is still running.

/side is unavailable inside another side conversation and during review mode.

生成 AGENTS.md 使用 /init

运行 /init in directory where you want Codex 到 look for 持久化ent instructions.

检查 the generated AGENTS.md, then edit it 到 match your repository conventions.

预期结果: Codex creates an AGENTS.md scaffold you can refine 和 commit for future sessions.

Ask for a working tree 检查 使用 /检查

输入 /检查.

Follow up 使用 /diff 如果 you want 到 inspect the exact file changes.

预期结果: Codex summarizes issues it finds in your working tree, focusing on behavior changes 和 missing tests。It uses the 当前 session model unless you 设置 review_model in config.toml.

列出 MCP tools 使用 /mcp

输入 /mcp.

检查 the 列出 到 确认 which MCP servers 和 tools are 可用.

预期结果: You see the configured Model Context Protocol (MCP) tools Codex can call in this session.

使用 /mcp verbose 到 include detailed server diagnostics。如果 you pass anything other than verbose, Codex shows command usage.

Browse apps 使用 /apps

输入 /apps.

Pick an app 从 the 列出.

预期结果: Codex inserts the app mention into the composer as $app-slug, so you can 立即 ask Codex 到 使用 it.

Browse plugins 使用 /plugins

输入 /plugins.

选择 a marketplace tab, then pick a plugin 到 inspect its capabilities 或 可用 actions.

预期结果: Codex opens the plugin browser so you can 检查 installed plugins, discoverable plugins that your configuration allows, 和 installed plugin state。按 Space on an installed plugin 到 切换 its enabled state.

View 和 manage lifecycle hooks 使用 /hooks

输入 /hooks.

选择 a hook event 到 inspect the matching handlers.

Trust, disable, 或 re-enable non-managed hooks as needed.

预期结果: Codex opens the hook browser so you can 检查 configured lifecycle hooks。Managed hooks appear as managed 和 can’t be disabled 从 the user hook browser.

切换 agent threads 使用 /agent

输入 /agent 和 按 Enter.

选择 the thread you want 从 picker.

预期结果: Codex switches the active thread so you can inspect 或 continue that agent’s work.

Send feedback 使用 /feedback

输入 /feedback 和 按 Enter.

Follow the prompts 到 include logs 或 diagnostics.

预期结果: Codex collects the requested diagnostics 和 submits them 到 the maintainers.

Sign out 使用 /logout

输入 /logout 和 按 Enter.

预期结果: Codex clears local credentials for the 当前 user session.

Exit the CLI 使用 /quit 或 /exit

输入 /quit (或 /exit) 和 按 Enter.

预期结果: Codex exits 立即。Save 或 commit any important work first.

站内延伸阅读