主题
斜杠命令
内置斜杠命令
| 命令 | 用途 |
|---|---|
/add-dir | 添加额外的工作目录 |
/agents | 管理用于专门任务的自定义 AI 子代理 |
/bashes | 列出并管理后台任务 |
/bug | 报告错误 |
/clear | 清除对话历史 |
/compact [instructions] | 压缩对话 |
/config | 打开设置界面 |
/context | 将当前上下文使用情况可视化 |
/cost | 显示令牌使用统计信息 |
/doctor | 检查 Claude Code 安装的健康状况 |
/exit | 退出 REPL |
/export [filename] | 将当前对话导出到文件 |
/help | 获取使用帮助 |
/hooks | 管理工具事件的钩子配置 |
/init | 使用 CLAUDE.md 指南初始化项目 |
/login | 切换 Anthropic 账户 |
/logout | 从 Anthropic 账户登出 |
/mcp | 管理 MCP 服务器连接 |
/memory | 编辑 CLAUDE.md 内存文件 |
/model | 选择或更改 AI 模型 |
/permissions | 查看或更新权限 |
/review | 请求代码审查 |
/sandbox | 启用沙箱化 bash 工具 |
/status | 显示版本、模型、账户信息 |
/vim | 进入 vim 模式 |
自定义斜杠命令
自定义斜杠命令允许您将经常使用的提示定义为 Markdown 文件。
项目命令
存储在您的存储库中并与您的团队共享的命令。
位置: .claude/commands/
bash
mkdir -p .claude/commands
echo "Analyze the performance of this code:" > .claude/commands/optimize.md使用: > /optimize
个人命令
在所有项目中可用的命令。
位置: ~/.claude/commands/
bash
mkdir -p ~/.claude/commands
echo "Review this code for security vulnerabilities:" > ~/.claude/commands/security-review.md使用: > /security-review
功能
命名空间
在子目录中组织命令。位于 .claude/commands/frontend/component.md 的文件创建命令 /component,描述显示"(project:frontend)"。
参数
使用 $ARGUMENTS 的所有参数
markdown
Find and fix issue #$ARGUMENTS.使用: > /fix-issue 123
使用 $1、$2 等的单个参数
markdown
Create a $1 component named $2.使用: > /create-component button MyButton
Bash 命令执行
使用 ! 前缀在斜杠命令运行之前执行 bash 命令:
markdown
!git diff --staged
Review the staged changes above.文件引用
使用 @ 前缀在命令中包含文件内容:
markdown
Review the code in @src/main.ts前置事项
yaml
---
description: Analyze code performance
allowed-tools: Read, Grep, Glob
model: sonnet
---
Analyze the performance of this code...MCP 斜杠命令
MCP 服务器可以将提示公开为斜杠命令:
> /mcp__github__list_prs
> /mcp__github__pr_review 456技能与斜杠命令
| 方面 | 斜杠命令 | 代理技能 |
|---|---|---|
| 复杂性 | 简单提示 | 复杂功能 |
| 结构 | 单个 .md 文件 | 带有 SKILL.md + 资源的目录 |
| 发现 | 显式调用 | 自动(基于上下文) |
| 范围 | 项目或个人 | 项目或个人 |
使用斜杠命令:快速、经常使用的提示 使用技能:具有结构的全面功能