This skill should be used when the user asks to "create a hook", "add PreToolUse hook", "configure hooks.json", or mentions hook events, PostToolUse, SessionStart, Stop, or UserPromptSubmit.
Creates event-driven hooks for Claude Code plugins to validate, enforce policies, and automate workflows.
/plugin marketplace add GGPrompts/my-plugins/plugin install plugin-dev@my-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Hooks enable event-driven automation in Claude Code plugins for validation, policy enforcement, context loading, and workflow integration.
Prompt-Based (Recommended)
Command
${CLAUDE_PLUGIN_ROOT} for portable pathsPlugin format (hooks/hooks.json):
{
"hooks": {
"PreToolUse": [{
"matcher": "Write|Edit",
"hooks": [{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/validate.sh",
"timeout": 30
}]
}]
}
}
Settings format (.claude/settings.json):
{
"PreToolUse": [{
"matcher": "Write",
"hooks": [{ "type": "command", "command": "..." }]
}]
}
| Event | Purpose |
|---|---|
PreToolUse | Approve/deny/modify tool calls before execution |
PostToolUse | React to tool results, provide feedback |
Stop | Validate main agent completion |
SubagentStop | Ensure subagent task completion |
UserPromptSubmit | Add context or block prompts |
SessionStart | Load context, set environment |
SessionEnd | Cleanup, state preservation |
PreCompact | Context preservation before compaction |
Notification | Handle notifications |
"Write""Read|Write|Edit""*""mcp__.*__delete.*"{
"continue": true,
"suppressOutput": false,
"systemMessage": "Context for Claude"
}
Exit codes: 0 (success), 2 (blocking error), other (non-blocking)
Available in command hooks:
$CLAUDE_PROJECT_DIR - Project root$CLAUDE_PLUGIN_ROOT - Plugin directory$CLAUDE_ENV_FILE - Persist vars (SessionStart only).. detection).env, credentials)"$variable"DO:
${CLAUDE_PLUGIN_ROOT} consistentlyDON'T:
#!/bin/bash
# ${CLAUDE_PLUGIN_ROOT}/scripts/validate-write.sh
FILE_PATH="$1"
# Block writes to sensitive files
if [[ "$FILE_PATH" == *".env"* ]]; then
echo '{"continue": false, "systemMessage": "Cannot modify .env files"}'
exit 2
fi
echo '{"continue": true}'
Note: Hooks load at session start only. Changes require Claude Code restart.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.