Claude Code 速查表与快速参考

设置和访问

$curl -fsSL https://claude.ai/install.sh | bash
$curl -fsSL https://claude.ai/install.sh | bash

在 macOS、Linux 或 WSL 上原生安装 Claude Code,具有自动后台更新。

$irm https://claude.ai/install.ps1 | iex

从 Windows PowerShell 使用原生安装程序安装 Claude Code,具有自动后台更新。

$curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

从 Windows CMD 使用原生安装程序安装 Claude Code,具有自动后台更新。

$brew install --cask claude-code
$brew install --cask claude-code

使用 Homebrew 安装 Claude Code。

$brew upgrade claude-code
$brew upgrade claude-code

Homebrew 安装不会自动更新。运行此命令以获取最新功能和安全修复。

$winget install Anthropic.ClaudeCode

在 Windows 上使用 WinGet 安装 Claude Code。

$winget upgrade Anthropic.ClaudeCode

WinGet 安装不会自动更新。运行此命令以获取最新功能和安全修复。

$claude

在当前项目中启动交互式 Claude Code 会话。

$claude -v

显示已安装的 Claude Code 版本。

$claude update

手动将 Claude Code 更新到最新版本。

$claude --init

运行初始化钩子并启动交互模式。

$claude auth login

从终端登录到您的 Claude 帐户。使用 --email 预填电子邮件或 --sso 强制 SSO 身份验证。

$claude auth status --text

将身份验证状态显示为 JSON。使用 --text 获得人类可读的输出。如果已登录,则以代码 0 退出,否则以代码 1 退出。

$claude "write a test for this function"

运行一次性任务并获取响应,而无需启动交互会话。

$claude commit

使用 Claude Code 编写提交消息来创建 Git 提交。

/init

为当前项目初始化项目指导文件。

/memory

从会话内部打开 Claude 内存管理。

/login

登录到您的 Anthropic 帐户。

/logout

从您的 Anthropic 帐户注销。

/mobile
/ios
/android

显示二维码以下载 Claude 移动应用。

/import codex
/import gemini
/import cursor

Bring configuration from OpenAI Codex, Google Gemini CLI, or Cursor into Claude Code, including instruction files, MCP servers, commands, subagents, and skills.

提示和输入

$claude -p "explain this function"

在打印模式下运行 Claude 一次,并以单个响应退出。

Ctrl + G
Ctrl + X then Ctrl + E

在默认文本编辑器中打开当前提示。

/btw what was the name of that config file again?

提出一个侧边问题,而无需将其添加到主对话历史记录中。可以在 Claude 工作时运行。

Ctrl + K

删除从光标到行尾的内容。

Ctrl + U

删除整个当前行。

Ctrl + Y

粘贴使用 readline kill 命令删除的文本。

Alt + Y

粘贴后循环浏览较早的 kill-ring 条目。

Alt + B

将光标向后移动一个单词。

Alt + F

将光标向前移动一个单词。

Ctrl + V or Cmd + VAlt + VCtrl + V or Alt + V

从剪贴板粘贴图像。

\ + Enter
Shift + Enter
Ctrl + J
Option + EnterShift + EnterShift + Enter

为多行输入插入换行符。

/

从提示的开始处打开斜杠命令选择器。

!

从提示的开始处进入 bash 模式。

@

触发文件路径自动完成。

Tab

接受提示建议以进行编辑。

Enter

接受提示建议并立即提交。

Escape
Backspace
Ctrl + U

当提示为空时退出 bash 模式。

/voice

切换推送式语音听写。

Space
Enter
Escape

关闭 /btw 侧边问题覆盖层并返回主提示。

/goal all tests passing
/goal clear

Set a goal: Claude keeps working across turns until the condition is met. Pass clear to remove an active goal early.

/loop 5m check if the deploy finished

Run a prompt repeatedly while the session stays open, with an interval such as 5m, or let Claude self-pace. Alias: /proactive.

/schedule

Create, update, list, or run routines, which execute in the cloud on a schedule. Alias: /routines.

/deep-research compare state of the art RAG approaches

Fan out web searches on a question, fetch and cross-check sources, and synthesize a cited report.

Ctrl + S

Stash the current prompt for later. With text in the input, stashes it and clears the prompt; pressed again on an empty prompt, restores the stashed text.

Ctrl + A

Move the cursor to the start of the current line. In multiline input, moves to the start of the current logical line.

Ctrl + E

Move the cursor to the end of the current line. In multiline input, moves to the end of the current logical line.

Ctrl + W

Delete back to the previous whitespace. One press removes a whole path or --flag=value.

Alt + D

Delete to the end of the current word, or to the end of the next word when the cursor is between words.

Ctrl + _
Ctrl + Shift + -

Undo the last input edit, restoring the previous input text and cursor position.

Ctrl + Enter
Ctrl + X then Ctrl + S

Send your queued messages, and your draft with them, right away while Claude is still working.

$claude -p "query" --output-format json

Get JSON output from print mode for scripts and automation.

$claude -p --fallback-model sonnet "query"

Enable automatic fallback to a specified model when the default model is overloaded (print mode only).

$claude -p --max-turns 3 "query"
$claude -p --max-budget-usd 5.00 "query"

Limit agentic turns or set a spending cap for print mode runs.

会话和上下文

$claude -c
$claude --continue

在当前目录中继续最近的对话。

$claude --resume auth-refactor
$claude -r

按 ID 或名称恢复特定会话,或显示交互式选择器以选择会话。

/clear
/reset
/new

清除当前会话并开始新的对话。

/compact "keep only the important parts"

压缩当前对话以仅保留重要上下文。

/resume
/continue

从当前会话内部恢复另一个对话。

/rename feature-auth

重命名当前对话。

/fork bug-investigation

Copy the current conversation into a new background session and keep working here. Pass a prompt to start the copy on it immediately. To switch into a branch yourself, use /branch; to hand a task to a subagent that reports back, use /subtask.

/context

显示当前使用了多少上下文。

/plan fix the auth bug

Enter plan mode, optionally passing a task description to start planning immediately.

/tasks

打开当前会话的任务列表。

/copy

Copy the last assistant response to the clipboard. Pass a number N to copy the Nth-latest response, or pick individual code blocks from the interactive picker.

/export notes.txt

将当前响应导出到文件。

/desktop
/app

将终端会话传输到桌面应用或网络以进行可视差异审查和继续工作。

/add-dir <path>

将新的工作目录添加到当前会话。

/branch feature-auth
/fork

在此处创建当前对话的分支。

/remote-control
/rc

从 claude.ai 启用对当前会话的远程控制。

Esc + Esc

从键盘倒回或总结。

/background

Detach the current session to run as a background agent and free your terminal. Pass a prompt to send one more instruction before detaching. Alias: /bg.

/subtask refactor the auth module

Spawn a forked subagent that inherits the full conversation and works on the task while you keep working. Its result returns to this conversation when it finishes.

/cd ../other-project

Move the session to a new working directory while keeping the conversation.

/recap

Generate a one-line summary of the current session on demand.

/teleport

Pull a cloud session from claude.ai into this terminal. Opens a picker, then fetches the branch and conversation. Alias: /tp.

/autocompact 500k
/autocompact auto

Set the auto-compact window: how full the context window gets before Claude Code compacts automatically. Pass a size such as 500k, or auto for the model-tuned default.

$claude -w feature-auth
$claude --worktree

Start Claude in an isolated git worktree at .claude/worktrees/<name> so parallel sessions do not conflict. If no name is given, one is auto-generated.

$claude -n "my-feature-work"

Set a display name for the session, shown in /resume and the terminal title. Resume it later with claude --resume <name>.

$claude --resume abc123 --fork-session

When resuming, create a new session ID instead of reusing the original, keeping the original conversation untouched.

$claude --from-pr 123

Resume sessions linked to a specific GitHub PR (auto-linked when created via gh pr create).

$claude --teleport

Resume a web session from claude.ai in your local terminal.

$claude --remote "Fix the login bug"

Create a new web session on claude.ai with the provided task description.

$claude --remote-control "My Project"

Start an interactive session with Remote Control enabled so you can also control it from claude.ai or the Claude app.

导航和控制

Ctrl + C

取消当前输入或生成。

Ctrl + F

终止所有后台代理。

Ctrl + D

退出 Claude Code 会话。

/exit
/quit

从命令提示符退出 Claude Code。

Ctrl + L

清除终端屏幕同时保留对话历史。

Ctrl + O

切换工具执行详细信息的冗长输出。

Ctrl + B

后台运行任务。Tmux 用户按两次 Ctrl+B。

Ctrl + T

显示或隐藏任务列表。

在对话框和菜单中循环浏览选项卡。

导航命令历史。

Ctrl + Z

Suspend Claude Code to your shell (Unix only). Run fg to resume.

审查和诊断

/diff

在 Claude 内显示当前差异。

/rewind
/checkpoint
/undo

将对话倒回到较早的检查点。

/doctor
/checkup

Run a setup checkup that diagnoses installation, settings, extension, and CLAUDE.md problems and proposes fixes Claude applies after you confirm.

/status

显示当前 Claude 会话和帐户状态。

/stats

显示详细的对话和使用统计,包括会话历史和条纹。

/insights

生成分析 Claude Code 会话、交互模式和摩擦点的报告。

/usage

显示当前使用信息。

/cost

显示当前支出和成本信息。

/security-review

查看当前分支以了解安全问题。

Cmd + ClickCtrl + ClickCtrl + Click

从页脚打开链接的拉取请求。

/code-review
/code-review high 1234
/code-review ultra --fix
/review

Review the current diff, or a PR number, branch, or path, for correctness bugs. Pass --fix to apply findings, --comment to post them on the PR, or ultra for a deep multi-agent cloud review. Alias: /review.

/simplify

Review the changed code for cleanup opportunities and apply the fixes. Four agents run in parallel covering reuse, simplification, efficiency, and abstraction level. Does not look for correctness bugs; use /code-review for those.

/verify

Confirm a code change does what it should by building the app, running it, and observing the result, rather than relying on tests or type checks.

/debug login fails on safari

Enable debug logging for the current session and troubleshoot issues by reading the session debug log. Optionally describe the issue to focus the analysis.

反向搜索

Ctrl + R

启动对命令历史的反向搜索或循环已有的匹配项。

Tab
Esc

接受当前反向搜索匹配以进行编辑。

Enter

接受当前反向搜索匹配并执行它。

Backspace

查询为空时退出反向搜索。

Ctrl + C

取消反向搜索并恢复原始输入。

配置和集成

/config
/settings
/config theme=dark

Open the Settings interface, or pass key=value pairs to set a setting directly, such as /config thinking=false or /config model=sonnet.

/theme

打开主题选择器。

/color orange

设置界面颜色主题。

/keybindings

打开键绑定配置。

/terminal-setup

安装特定于终端的绑定,例如 Shift+Enter 支持。

/model

从当前会话内部切换模型。

/effort high

更改当前推理工作量级别。

/fast on

在当前会话中切换快速模式。

/permissions
/allowed-tools

打开权限设置。

/sandbox

打开沙箱设置。

/mcp

管理 MCP 服务器集成。

/plugin

从会话内部管理插件。

/reload-plugins

重新加载已安装的插件。

/ide

将 Claude Code 连接到您的 IDE。

/agents

打开代理和队友选项。

/hooks

查看工具事件和自动化的钩子配置。

/config

Toggle between Vim and Normal editing modes from the Settings interface. Removed as the /vim command in v2.1.92.

/statusline

在您的 shell 提示符中配置 Claude Code 的状态行显示。

Shift + Tab
Alt + M

切换权限模式。

Option + PAlt + PAlt + P

在不清除当前提示的情况下切换模型。

Option + TAlt + TAlt + T

切换扩展思维模式。

Ctrl + T

在主题选择器内切换语法突出显示。

/usage-credits

Configure usage credits, or request them from your admin, when you hit a rate limit. Previously /extra-usage.

/output-style concise

List output styles or switch to one.

/update-config allow npm test without prompting

Describe a settings change, such as allowing a command or adding a hook, and Claude edits the matching settings.json file. For theme and model, use /config instead.

/fewer-permission-prompts

Scan your transcripts for common read-only Bash and MCP tool calls, then add a prioritized allowlist to project settings to reduce permission prompts.

/skill-doctor

Show what each of your skills costs in context and how often it gets used, so you can find skills to turn off.

/list-agents
/peers

List the subagents, agent team teammates, and other Claude Code sessions Claude can message, with the name to use for each. Alias: /peers.

Option + OAlt + OAlt + O

Toggle fast mode on or off.

$claude --agents '{"reviewer":{"description":"Reviews code","prompt":"You are a code reviewer"}}'

Define custom subagents dynamically at launch via JSON, using the same fields as subagent frontmatter plus a prompt field.

$claude --tools "Bash,Edit,Read"

Restrict which built-in tools Claude can use. Use "" to disable all, "default" for all, or list tool names.

$claude --effort high

Set the effort level for the session at launch: low, medium, high, or max (Opus only, session-scoped).

$claude --add-dir ../apps ../lib

Add additional working directories for Claude to access at launch.

$claude --permission-mode plan

Begin the session in a specified permission mode, such as plan.

$claude --mcp-config ./mcp.json
$claude --strict-mcp-config --mcp-config ./mcp.json

Load MCP servers from JSON files or strings, optionally ignoring all other MCP configuration.

帮助和发现

/help

打开内置斜杠命令帮助。

/skills

打开可用技能列表。

/release-notes

查看包含最近版本更新的完整更改日志。

/feedback
/bug

提交有关 Claude Code 的反馈或报告错误。

?

打开当前环境的快捷键图例。