hook-development

Create and validate event-driven hooks for Claude Code plugins.

1|Updated Jul 6, 2015
One-click install
npx skills add https://github.com/ksolomon/dotfiles --skill hook-development-ksolomon
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: hook-development
Source: https://github.com/ksolomon/dotfiles/tree/main/AI/.claude/plugins/marketplaces/claude-plugins-official/plugins/plugin-dev/skills/hook-development
Command: npx skills add https://github.com/ksolomon/dotfiles --skill hook-development-ksolomon

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jq, and 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, input/output schemas, and security practices, which is error-prone without structured guidance and validation tooling. ## 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 hook patterns. - 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 linting. - 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 in my plugin that validates file writes and blocks path traversal attempts.

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 name 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 with the claude command, 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 codes.

What exit codes should a Claude Code hook script return?▼

Hook scripts should exit with 0 for success, where stdout appears in the transcript, or 2 for a blocking error, where stderr is fed back to Claude. Other exit codes are treated as non-blocking errors.