VB-05 用好“Commands & Hooks”,效率直接拉满!
Claude Code 里的 Commands & Hooks:把常用 prompt 打包成 / 命令,再配上 hook,让 CC 干完活自动发 Telegram 通知,甚至开口说话。附上我每天在用的全部 commands 清单 😁
其他语言: English · Tiếng Việt · 한국어 · 日本語
“用 Claude Code 来 Vibe Coding”系列第 05 篇来啦!说实话这篇我有点偷懒,就只列一下我常用的 commands 和 hooks 吧 😅
(不过文末也有几个我收藏的 repo,对用 Claude Code 的朋友们挺有用的,记得去看看!)

Commands 是什么?
就是快速发送你预先写好的 prompt 模板的方式。
和 CLAUDE.md 或 agents/*.md 这类“System Prompt”不同,commands 属于“User Prompt”,“分量”重得多,也会被优先处理。
比如工作中有些 prompt 你总是要一遍又一遍地写,现在就可以把它打包成一个 command,用 / 快速调出来。
怎么创建 Commands
非常简单,在 ~/.claude/commands 文件夹里新建一个 Markdown 文件,结构如下:
markdown---
description: 描述这个 command
---
在这里写你的 prompt
$ARGUMENTS$ARGUMENTS 就是你在 command 后面输入的内容,会被插入到这个位置(例如:/fix 默认语言错误)。
command 有 2 种作用范围
| 范围 | .md 文件位置 | 在哪里可用 |
|---|---|---|
| Project commands | 项目里的 .claude/commands | 仅限该项目 |
| Global commands | ~/.claude/commands | 到处都能用! |
Pro tip:用 Commands 召唤 Subagents
在第一篇“Subagents”文章里我提到过,“Commands”是在需要时召唤 Subagents 的最佳方式。所以我们可以在每个 command 里写好详细、清晰的 workflow,按自己的需求定制,适配不同类型的任务。
例子:fix-ci.md
markdown---
description: 读取、分析、调试并修复 Github Actions 中失败的测试
---
读取、分析、调试并修复 Github Actions 中失败的测试:
$ARGUMENTS
流程:
- 使用 "debugger" agent 读取并分析 Github Actions 的 logs
- 使用 "planner" agent 制定修复计划
- 使用 "tester" agent 测试修复结果,确保所有 test suite 都通过我在用的 commands 清单
这篇我有点偷懒,而且关于“Commands”也没剩多少可讲的了,所以就只分享一下我为 Claude Code 创建的 command 清单。
我把所有 command 文件都放在了这个 repo里,还有我优化过、正在用的整套 Subagents 配置,需要的朋友随便拿去用。
(有反馈或改进的点子,欢迎直接给 repo 提 contribute!)
其实我也是“受了启发”(“抄作业”的高级说法)于别人的 repo。其中一个我觉得对 Claude Code 用户特别有用的是 https://github.com/mrgoonie/claude-code-setup ——大家去看看吧!
| Command | 用途 | 会自己改代码吗? |
|---|---|---|
/ask | 问关于代码库、架构的任何问题 | 不会 |
/plan | 用 planner-researcher 制定详细计划 | 不会,只出报告 |
/cook | 调动整个 agent 团队实现功能 / 修复复杂 bug | 会 |
/fix | 快速修小 bug | 会 |
/fix-test | 本地跑测试,修到全部通过为止 | 会 |
/fix-ci | 读 Github Actions logs,制定修复计划 | 先征求确认 |
/test | 本地跑测试并汇报 | 不会 |
/refactor | 有计划、有约束的重构 | 先征求确认 |
/debug | 找出 bug 的根本原因 | 不会 |
/watzup | 汇总最近的改动 | 不会 |
/ask
用这个 command 问关于代码库的任何问题。
查看 /ask command 内容
markdown---
description: Answer technical and architectural questions.
---
## Context
- Technical question or architecture challenge: $ARGUMENTS
- Relevant system documentation and design artifacts will be referenced using @ file syntax.
- Current system constraints, scale requirements, and business context will be considered.
## Your Role
You are a Senior Systems Architect providing expert consultation and architectural guidance. You focus on high-level design, strategic decisions, and architectural patterns rather than implementation details. You orchestrate four specialized architectural advisors:
1. **Systems Designer** – evaluates system boundaries, interfaces, and component interactions.
2. **Technology Strategist** – recommends technology stacks, frameworks, and architectural patterns.
3. **Scalability Consultant** – assesses performance, reliability, and growth considerations.
4. **Risk Analyst** – identifies potential issues, trade-offs, and mitigation strategies.
## Process
1. **Problem Understanding**: Analyze the technical question and gather architectural context.
2. **Expert Consultation**:
- Systems Designer: Define system boundaries, data flows, and component relationships
- Technology Strategist: Evaluate technology choices, patterns, and industry best practices
- Scalability Consultant: Assess non-functional requirements and scalability implications
- Risk Analyst: Identify architectural risks, dependencies, and decision trade-offs
3. **Architecture Synthesis**: Combine insights to provide comprehensive architectural guidance.
4. **Strategic Validation**: Ensure recommendations align with business goals and technical constraints.
## Output Format
1. **Architecture Analysis** – comprehensive breakdown of the technical challenge and context.
2. **Design Recommendations** – high-level architectural solutions with rationale and alternatives.
3. **Technology Guidance** – strategic technology choices with pros/cons analysis.
4. **Implementation Strategy** – phased approach and architectural decision framework.
5. **Next Actions** – strategic next steps, proof-of-concepts, and architectural validation points.
## Important
This command focuses on architectural consultation and strategic guidance. Do not start implementing anything./plan
召唤“planner-researcher” subagent,为实现某个功能或修复某个复杂 bug 制定详细计划。只出 REPORT,不执行。
markdown---
description: Research, analyze, and create implementation plans
---
Use the `planner-researcher` subagent to plan for this task:
$ARGUMENTS
REMEMBER: **Do not** start implementing./cook
我的 system prompt 里已经包含了 subagents 工作流的 3 个关键部分:Core Responsibilities、Subagents Team 和 Development Rules。 需要实现某个功能、或修复某个需要整个 agent 团队参与的复杂 bug 时,就调用这个 command。
markdown---
description: Implement a feature
---
Strictly follow your Core Responsibilities, Subagents Team and Development Rules.
Start implementing this task:
$ARGUMENTS锁定章节: /fix
锁定章节: /fix-test
锁定章节: /fix-ci
锁定章节: /test
锁定章节: /refactor
锁定章节: /debug
锁定章节: /watzup
锁定章节: Hooks 是什么、有什么用?
锁定章节: 1. UserPromptSubmit
锁定章节: 2. PreToolUse
锁定章节: 3. PostToolUse
锁定章节: 4. Notification
锁定章节: 5. Stop
锁定章节: 6. SubagentStop
锁定章节: 7. PreCompact
锁定章节: 8. SessionStart
锁定章节: 案例 1:干完活发 Telegram 通知
锁定章节: 案例 2:TTS + Hook = 语音助手!
锁定章节: 绝招:“以彼之道,还施彼身”
锁定章节: 骚操作!
锁定章节: 更多参考
锁定章节: 完结!
其余内容仅限 Knowledges 会员
另有 22 个章节(约 5 分钟)仅限会员
你正在阅读约前三分之一。Knowledges、组合和社区方案可阅读付费文章全文;Zuey AI 方案仅可阅读预览。