プロジェクトの `.claude/settings.json` に新しいフックを追加します。
Adds a new hook to your project's `.claude/settings.json` file. Use this to automate actions at specific events like tool execution, prompts, or session lifecycle.
/plugin marketplace add shiiman/claude-code-plugins/plugin install shiiman-shiiman-claude-plugins-shiiman-claude@shiiman/claude-code-pluginsプロジェクトの .claude/settings.json に新しいフックを追加します。
/shiiman-claude:create-hook
/shiiman-claude:create-hook --help
| オプション | 説明 |
|---|---|
--help | このコマンドのヘルプを表示 |
# 基本的な使用
/shiiman-claude:create-hook
→ イベント: PreToolUse
→ マッチャー: Bash
→ フックタイプ: command
→ コマンド: echo "Bash コマンドを実行します"
# 結果: .claude/settings.json の hooks セクションが更新される
--help が指定された場合: このファイルの内容を要約して表示し、終了。
ユーザーに以下を聞く:
イベント - いつ実行するか
PreToolUse: ツール実行前(ブロック可能、matcher 必須)PostToolUse: ツール実行後(matcher 必須)UserPromptSubmit: ユーザープロンプト送信時Notification: 通知時Stop: レスポンス完了時SubagentStop: サブエージェント完了時PreCompact: Compact 操作前SessionStart: セッション開始時SessionEnd: セッション終了時マッチャー(PreToolUse / PostToolUse の場合のみ)
Bash, Write, Edit|Write, *(すべて)フックタイプ
command: Bash コマンドを実行prompt: LLM(Haiku)で評価実行するコマンド(type: command の場合)
npm run lint, echo "完了".claude/settings.json が存在するか確認(なければ作成)| イベント | matcher | 説明 |
|---|---|---|
PreToolUse | 必須 | ツール実行前(ブロック可能) |
PostToolUse | 必須 | ツール実行後 |
UserPromptSubmit | 不要 | ユーザープロンプト送信時 |
Notification | 不要 | 通知時 |
Stop | 不要 | レスポンス完了時 |
SubagentStop | 不要 | サブエージェント完了時 |
PreCompact | 不要 | Compact 操作前 |
SessionStart | 不要 | セッション開始時 |
SessionEnd | 不要 | セッション終了時 |
.claude/settings.json の hooks セクションを更新:
PreToolUse / PostToolUse の場合(matcher 必須):
{
"hooks": {
"{イベント}": [
{
"matcher": "{マッチャー}",
"hooks": [
{
"type": "command",
"command": "{コマンド}"
}
]
}
]
}
}
その他のイベントの場合(matcher 不要):
{
"hooks": {
"{イベント}": [
{
"hooks": [
{
"type": "command",
"command": "{コマンド}"
}
]
}
]
}
}
既存の hooks セクションがある場合は、適切なイベントに追加する。
作成されたファイルと次のステップを表示:
フックを作成しました: {イベント} {マッチャー(あれば)}
更新:
- .claude/settings.json
次のステップ:
- /shiiman-claude:create-hook で別のフックを追加
- /shiiman-claude:create-command でコマンドを追加
- /shiiman-claude:create-skill でスキルを追加
- /shiiman-claude:create-subagent でサブエージェントを追加
/create-hookGuided hook creation with brainstorming and security-first design. Triggers: new hook, create hook, hook creation, start hook, build hook, add hook, write hook, PreToolUse, PostToolUse, UserPromptSubmit Use when: creating a new hook from scratch, need security-first design guidance, want structured workflow for hook development with Socratic questioning DO NOT use when: evaluating existing hooks - use /hooks-eval instead. DO NOT use when: deciding where to place hooks - use hook-scope-guide skill. DO NOT use when: validating hook security - use /validate-hook instead. Use this command to create any new hook. Security validation is automatic.