Help us improve
Share bugs, ideas, or general feedback.
From create-hooks
Scaffolds Claude Code hooks with templates, validation, and conflict analysis. Analyzes existing hooks, prevents conflicts, and generates boilerplate code automatically.
npx claudepluginhub dodo-digital/dodo-marketplace --plugin create-hooksHow this skill is triggered — by the user, by Claude, or both
Slash command
/create-hooks:create-hookThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
<objective>
references/component-scoped-hooks.mdreferences/debugging.mdreferences/dispatcher-pattern.mdreferences/hook-events.mdreferences/json-output.mdreferences/mcp-tools.mdreferences/prompt-based-hooks.mdreferences/security.mdreferences/session-env-vars.mdreferences/sub-agents.mdscripts/hook-log.pyscripts/validate-hook.pytemplates/auto-approve.pytemplates/bash-validator.shtemplates/context-injection.pytemplates/debug-wrap.shtemplates/dispatcher.pytemplates/dispatcher.shtemplates/intelligent-stop-prompt.jsontemplates/notification-forwarder.shCreates, validates, and refines Claude Code plugin hooks for workflow automation. Supports command hooks (shell scripts), prompt hooks (LLM decisions), event matching, decision schemas, and production safety validation.
Guides creation of Claude Code plugin hooks with prompt-based and bash command types for PreToolUse, PostToolUse, Stop, and other events. Covers plugin hooks.json and settings.json formats.
Create event-driven hooks for Claude Code automation. Use when the user wants to create hooks, automate tool validation, add pre/post processing, enforce security policies, or configure settings.json hooks. Triggers: create hook, build hook, PreToolUse, PostToolUse, event automation, tool validation, security hook
Share bugs, ideas, or general feedback.
Core principle: prefer dispatchers over standalone hooks. When multiple hooks exist on the same event, they should be consolidated into a single dispatcher with a checks/ directory. This eliminates redundant JSON parsing, prevents conflicts, and makes adding new checks trivial (drop a file). The create-hook flow automatically detects when a dispatcher should be used and routes accordingly.
If bare /create-hook with no arguments, ask:
What do you need?
scripts/hook-log.py)When creating a new hook, ALWAYS ask about installation level:
Where should this hook be installed?
.claude/settings.json) - Runs only in THIS project, checked into git~/.claude/settings.json) - Runs in ALL your projects.claude/settings.local.json) - Project-level but gitignored (for personal/sensitive hooks)
| Intent | References to Load | Workflow |
|---|---|---|
| Create new hook | hook-events.md, json-output.md, security.md, sub-agents.md, dispatcher-pattern.md | Spawn inventory agent → dispatcher decision → create (check or standalone) → tester agent |
| Create prompt-based hook | prompt-based-hooks.md, hook-events.md | Determine event → configure prompt → test |
| Create component-scoped hook | component-scoped-hooks.md, hook-events.md | Define in frontmatter → test |
| Edit existing hook | hook-events.md, json-output.md, debugging.md | Read existing hook → modify → test |
| Debug hook | debugging.md, hook-events.md | Diagnose → fix → test |
| Validate hooks | debugging.md | Run scripts/validate-hook.py --project |
| View hook logs | debugging.md | Run scripts/hook-log.py or tail -f .claude/hooks/.debug.log |
| Analyze hooks | sub-agents.md | Spawn inventory agent |
| Consolidate hooks (dispatcher) | dispatcher-pattern.md, hook-events.md | workflows/create-dispatcher.md |
| MCP tools | mcp-tools.md, hook-events.md | Show patterns |
| SessionStart/env vars | session-env-vars.md, hook-events.md | Show patterns |
| Security review | security.md | Show checklist |
| Templates | (load template file directly) | Show template |
| Add to settings | workflows/add-to-settings.md | Configure |
<essential_principles>
checks/, not a standalone hookreferences/dispatcher-pattern.md for the full pattern..claude/settings.json) - This project only, version controlled~/.claude/settings.json) - ALL projects for this user.claude/settings.local.json) - This project only, gitignoreddebug-wrap.sh and wrap commands with it (user can opt out)scripts/validate-hook.py to confirm proper installation
</essential_principles><quick_reference> Hook Types:
| Type | When to Use | Supported Events |
|---|---|---|
command | Deterministic checks (regex, file ops, external APIs) | All events |
prompt | Judgment calls (task completeness, quality evaluation) | Stop, SubagentStop, UserPromptSubmit, PreToolUse, PermissionRequest |
Hook Events:
| Event | When | Matcher? | Can Block? |
|---|---|---|---|
| PreToolUse | Before tool runs | Yes | Yes |
| PostToolUse | After tool succeeds | Yes | Feedback only |
| PermissionRequest | Permission dialog | Yes | Yes |
| UserPromptSubmit | User sends prompt | No | Yes |
| Stop | Claude finishes | No | Yes (continue) |
| SubagentStop | Subagent finishes | No | Yes (continue) |
| SessionStart | Session begins | Yes | Context + env vars |
| SessionEnd | Session ends | No | Cleanup only |
| PreCompact | Before compaction | Yes | No |
| Notification | System notification | Yes | No |
Common Matchers:
Write|Edit|MultiEdit - File modificationsBash - Shell commandsTask - Subagent creationmcp__<server>__<tool> - MCP tools (e.g., mcp__github__.*)* or empty - All toolsExit Codes:
exit 0 - Success (stdout in verbose mode, or context for SessionStart/UserPromptSubmit)exit 2 - Block action (stderr shown to Claude)exit 1 - Non-blocking error (logged only)
</quick_reference><references_index> Core (load for most tasks):
| Reference | Purpose |
|---|---|
| references/hook-events.md | Input/output schemas per event |
| references/json-output.md | JSON response format details |
| references/dispatcher-pattern.md | Dispatcher architecture — when and how to consolidate hooks |
Task-specific:
| Reference | When to Load |
|---|---|
| references/prompt-based-hooks.md | Creating LLM-evaluated hooks (type: prompt) |
| references/component-scoped-hooks.md | Defining hooks in SKILL.md/command frontmatter |
| references/security.md | Creating new hooks, security review |
| references/debugging.md | Debugging, testing, healing hooks |
| references/mcp-tools.md | Hooking MCP server tools |
| references/session-env-vars.md | SessionStart hooks with env vars |
| references/sub-agents.md | Creating hooks (analysis phase) |
| </references_index> |
<templates_index>
| Template | Use Case |
|---|---|
| templates/debug-wrap.sh | Debug wrapper - logs hook invocations (~0.5ms overhead) |
| templates/bash-validator.sh | Block dangerous shell commands |
| templates/python-validator.py | Complex validation with JSON |
| templates/auto-approve.py | Auto-approve safe operations |
| templates/context-injection.py | SessionStart/UserPromptSubmit context |
| templates/stop-gate.py | Ensure work completion before stop (command-based) |
| templates/intelligent-stop-prompt.json | LLM-evaluated task completion (prompt-based) |
| templates/permission-handler.py | Handle permission dialogs programmatically |
| templates/notification-forwarder.sh | Forward notifications externally |
| templates/dispatcher.sh | Shell dispatcher (recommended) - routes to checks/ directory |
| templates/dispatcher.py | Python dispatcher - routes to handler functions in one file |
| </templates_index> |
<subagent_usage> When creating hooks, spawn agents in order:
checks/ directory exists for this event → route to "add check" flowworkflows/create-dispatcher.mdSee references/sub-agents.md for full prompt templates.
See references/dispatcher-pattern.md for dispatcher architecture.
</subagent_usage>
<success_criteria>
checks/ directory (no settings change needed)debug-wrap.sh copied to .claude/hooks/) - unless user explicitly opts outscripts/validate-hook.py)