Hook Development

Create and validate event-driven hooks for Claude Code plugin automation.

1|1|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/voxxov222/Claude-code- --skill hook-development-voxxov222
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Hook Development
Source: https://github.com/voxxov222/Claude-code-/tree/main/temp-repo/plugins/plugin-dev/skills/hook-development
Command: npx skills add https://github.com/voxxov222/Claude-code- --skill hook-development-voxxov222

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Building hooks for Claude Code plugins requires understanding event types, JSON configuration formats, input/output schemas, and security practices, and mistakes cause silent failures or broken workflows. ## Core Features & Use Cases - Hook Implementation Guidance: Covers all hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification) with both prompt-based and command-based configurations. - Validation and Testing Scripts: Includes validate-hook-schema.sh for hooks.json structure checks, test-hook.sh for running hooks against sample input, and hook-linter.sh for best-practice enforcement. - Reference Patterns and Examples: Provides proven hook patterns, migration guidance from command to prompt hooks, and working example scripts for write validation, bash validation, and context loading. - Use Case: When adding a PreToolUse hook to block dangerous bash commands in a plugin, use this Skill to write the hooks.json entry, validate it with the schema script, and test it before restarting Claude Code. ## Quick Start Create a PreToolUse hook that validates file writes and blocks path traversal in my Claude Code plugin.

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?

Add a PreToolUse entry in your plugin's hooks/hooks.json with a matcher for the tool names and a hooks array containing either a prompt hook for LLM-based validation or a command hook running a bash script. Use ${CLAUDE_PLUGIN_ROOT} for portable script paths.

What is the difference between prompt hooks and command hooks?

Prompt hooks use LLM reasoning for context-aware decisions and work on Stop, SubagentStop, UserPromptSubmit, and PreToolUse events. Command hooks execute bash scripts for fast deterministic checks, file operations, and external tool integration.

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 it, then verify loaded hooks with the /hooks command or claude --debug.

How do I test a hook script before deploying it?

Use the test-hook.sh script with a sample JSON input file, which you can generate with the --create-sample flag for a given event type. It sets up environment variables, measures execution time, and validates the output JSON and exit code.

What exit codes should a Claude Code hook script return?

Exit code 0 means success with stdout shown in the transcript, exit code 2 means a blocking error with stderr fed back to Claude, and any other code is treated as a non-blocking error. Decision hooks should also output structured JSON.