hook-development

Develop event-driven hooks for Claude Code plugins to validate tool usage events.

Updated Apr 19, 2026
One-click install
npx skills add https://github.com/cjrfoto/claude-config --skill hook-development-cjrfoto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-development
Source: https://github.com/cjrfoto/claude-config/tree/main/plugins/marketplaces/claude-plugins-official/plugins/plugin-dev/skills/hook-development
Command: npx skills add https://github.com/cjrfoto/claude-config --skill hook-development-cjrfoto

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jq, timeout, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Hooks provide a structured, self-contained way to intercept Claude Code events and enforce policies, compose workflows, and load contextual data during plugin development.

Core Features & Use Cases

  • Support for PreToolUse, PostToolUse, Stop, SessionStart, and other hook events to validate, react, and automate tool usage
  • Flexible prompt-based and command hooks, with a clear hooks.json structure and environment variable usage
  • Testing and debugging utilities in scripts/ (validate-hook-schema.sh, test-hook.sh) to ensure safety and reliability

Quick Start

Create a basic prompt-based PreToolUse hook and test it with the provided test-hook utility to verify the flow

Frequently Asked Questions about hook-development

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

FAQPage Schema
How do I use Claude Code hooks to validate tool usage events?

Claude Code hooks validate tool usage by intercepting PreToolUse events, allowing you to enforce policies and check inputs before execution. You can implement prompt-based or command hooks using a hooks.json structure to automate this validation workflow.

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

Prompt-based hooks serve as the main approach for intercepting events, while command hooks offer optional execution. Both are supported within the plugin hooks.json structure, allowing you to choose between contextual prompting or direct shell commands for workflow automation.

How do I test and debug event-driven hooks for Claude Code plugins?

You test and debug event-driven hooks using provided scripts like validate-hook-schema.sh and test-hook.sh. These utilities verify hook schema correctness and test execution flows to ensure safety and reliability across PreToolUse and PostToolUse events.

Can I use SessionStart hooks to load context for Claude Code workflows?

Yes, SessionStart hooks load contextual data when a session begins. Along with Stop and PostToolUse events, they automate workflows and inject necessary environment context into your plugin development scenarios using proper JSON outputs.

Do I need jq and timeout to manage hook development?

Yes, jq and timeout are required dependencies for hook development. jq processes and validates JSON outputs from command hooks, while timeout enforces execution limits to prevent hanging during hook testing and plugin validation.

How do I reference plugin root paths in a hooks.json configuration?

You reference plugin root paths using the ${CLAUDE_PLUGIN_ROOT} environment variable within your hooks.json configuration. This ensures command hooks and scripts can reliably locate plugin resources across different hook events.