Claude Code

Claude Code Commands 自动化工作流指南

围绕 Claude Code commands、slash commands、custom commands、hooks、skills 和 plugins 的专题首页。

最后更新: 2026年7月26日

功能对比

能力适合场景存放位置
Commands内置会话控制,例如 /help、/compact、/model、/mcp、/hooks 和 /code-reviewClaude Code CLI 会话
Slash commands从提示框或 SDK 快速触发命令,包括内置命令和自定义命令消息开头输入 /
Custom commands复用 review、PRD、test、changelog、commit 等项目或个人提示词.claude/commands/*.md 或 ~/.claude/commands/*.md
Hooks在工具前后、通知、停止、会话事件等生命周期自动执行动作.claude/settings.json 或 ~/.claude/settings.json
Skills带延迟加载说明和支持文件的可复用工作流.claude/skills/<name>/SKILL.md 或 ~/.claude/skills/<name>/SKILL.md
Plugins可共享 commands、skills、hooks、agents 和 MCP servers 的组合包Claude Code plugin marketplace 或 plugin source

建议专题结构

把这些关键词做成互相内链的专题集群,而不是分散的单页。commands 首页定义概念,再链接到生成器和模板目录。

  • /claude-code-commands/:目标词 claude code commands。
  • /claude-code-hooks-generator/:目标词 claude code hooks。
  • /claude-code-custom-commands/:目标词 claude code custom commands。
  • /claude-code-slash-commands/:目标词 claude code slash commands。

项目命令起步块

把稳定命令写入 CLAUDE.md,让 Claude Code 明确知道修改前后该执行哪些验证。

## Project Commands

- Install: npm install
- Dev: npm run dev
- Lint: npm run lint
- Test: npm test
- Typecheck: npm run typecheck
- Build: npm run build

何时使用哪种能力

选择刚好足够的配置层。一次性提示词不需要 plugin;确定性安全检查也不应该依赖 Claude 记住要执行。

  • 人工决定触发时机,用 slash command。
  • 跨项目或团队复用提示词,用 custom command 或 skill。
  • 必须在某个生命周期节点执行时,用 hook。
  • 多个能力需要一起安装和更新时,用 plugin。

Claude Code 官方引用

Claude Code 官方文档把内置 commands、bundled skills、custom commands、hooks 和 plugins 作为相关扩展面来说明。发布配置示例前建议核对官方参考。

常见错误

问题通常来自混淆触发时机、存放位置或权限边界。

  • 把自动检查写成 custom command,而不是 hook。
  • 在复杂复用流程中继续使用旧 .claude/commands,而不是 skill。
  • 忘记 slash command 必须出现在消息开头才会被识别。
  • hook 命令会改文件或访问网络,但没有团队审查。

常见问题

Claude Code custom commands 和 skills 一样吗?

现在两者有重叠。现有 .claude/commands/*.md 仍然可用,但更丰富的可复用工作流建议用 skills。

Hooks 能替代 slash commands 吗?

不能。slash commands 是用户触发;hooks 是生命周期自动执行,应该保持确定性和可审计。

团队命令应该放在哪里?

共享工作流放在项目级 .claude/commands 或 .claude/skills;核心验证命令写入 CLAUDE.md。