hook-development

Create event-driven hooks for Claude Code plugins using prompt-based and command configurations.

2|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/ghoshsam/claude-code-skills --skill hook-development-ghoshsam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-development
Source: https://github.com/ghoshsam/claude-code-skills/tree/main/skills/plugin-dev/hook-development
Command: npx skills add https://github.com/ghoshsam/claude-code-skills --skill hook-development-ghoshsam

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Building event-driven automation for Claude Code requires understanding hook events, JSON configuration formats, matchers, and security practices, which is error-prone without structured guidance. ## Core Features & Use Cases - Hook Event Coverage: Configure PreToolUse, PostToolUse, Stop, SubagentStop, UserPromptSubmit, SessionStart, SessionEnd, PreCompact, and Notification hooks. - Prompt-Based and Command Hooks: Choose LLM-driven validation for context-aware decisions or bash scripts for deterministic checks. - Security and Portability Patterns: Use ${CLAUDE_PLUGIN_ROOT} for portable paths, validate inputs, and block dangerous operations like path traversal. - Use Case: Add a PreToolUse hook that validates every Write operation, denying writes to sensitive files like .env and blocking path traversal attempts before execution. ## Quick Start Create a PreToolUse hook in my plugin that validates file writes and blocks access to sensitive files.

Frequently Asked Questions about hook-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a PreToolUse hook in Claude Code?

Define a PreToolUse entry in your plugin's hooks/hooks.json with a matcher for target tools and a hook of type prompt or command. The hook receives tool input via stdin and returns JSON with a permissionDecision of allow, deny, or ask.

What is the difference between prompt-based and command hooks?

Prompt-based hooks use LLM reasoning for context-aware validation on events like Stop and PreToolUse, while command hooks execute bash scripts for fast deterministic checks. Use prompt hooks for complex logic and command hooks for performance-critical validations.

Why are my hook changes not taking effect in Claude Code?

Hooks load only at session start, so editing hooks.json or hook scripts does not affect the current session. Exit Claude Code and restart with claude, then verify loaded hooks using the /hooks command or claude --debug.

How do I block dangerous bash commands with a hook?

Use a PreToolUse hook matching Bash that inspects the command input and returns a deny decision with exit code 2. Validate inputs with jq, check for path traversal and sensitive files, and quote all variables to prevent injection.

What is ${CLAUDE_PLUGIN_ROOT} used for in hooks?

${CLAUDE_PLUGIN_ROOT} is an environment variable pointing to the plugin directory, making hook command paths portable across machines. Reference scripts as bash ${CLAUDE_PLUGIN_ROOT}/scripts/validate.sh instead of hardcoding absolute paths.