Knowledges 11 分

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 を並べるだけにさせてください 😅

(とはいえ、記事の最後に Claude Code ユーザーにかなり役立つ repo をいくつか集めておいたので、ぜひチェックしてみてください!)

VB-05「Commands & Hooks」を使い倒して生産性アップ!

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 ユーザーにかなり役立つと思う repo のひとつが https://github.com/mrgoonie/claude-code-setup — ぜひ見てみてください!

Command用途自分でコードを直す?
/askcodebase やアーキテクチャについて何でも質問いいえ
/planplanner-researcher で詳細な計画を作成いいえ、レポートのみ
/cookagent チーム総出で機能実装 / 複雑なバグ修正はい
/fixちょっとしたバグをサクッと修正はい
/fix-testローカルでテストを回し、通るまで修正はい
/fix-ciGithub Actions の logs を読み、修正計画を作成先に確認を取る
/testローカルでテストを回して報告いいえ
/refactor計画と制約つきのリファクタリング先に確認を取る
/debugバグの根本原因を探すいいえ
/watzup最近の変更をまとめるいいえ

/ask

codebase について何でも質問するための 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 を召喚して、機能実装や複雑なバグ修正のための詳細な計画を立てます。REPORT のみ、実行は NO。

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 と働く workflow の重要な 3 要素がすでに入っています:Core Responsibilities、Subagents Team、Development Rules。 agent チーム総出が必要な機能実装や複雑なバグ修正のときに、この command を呼びます。

ロックされたセクション: /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

ロックされたセクション: Case 1:作業が終わったら Telegram で通知

ロックされたセクション: Case 2:TTS + Hook = 音声アシスタント!

ロックされたセクション: 奥義:「敵の武器で敵を討つ」

ロックされたセクション: 裏ワザ!

ロックされたセクション: その他の参考資料

ロックされたセクション: おしまい!

続きは Knowledges 会員向けです

会員向けにあと 22 セクション(約 6 分)

現在、冒頭の約3分の1を読んでいます。Knowledges・コンボ・コミュニティプランで有料記事を全文読めます。Zuey AI プランはプレビューのみです。