Hook Development

Develop event-driven Claude Code hooks for tool validation and plugin workflows.

Updated Jan 19, 2026
One-click install
npx skills add https://github.com/kgadek/kgadek-claude-plugin --skill hook-development-kgadek
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Hook Development
Source: https://github.com/kgadek/kgadek-claude-plugin/tree/main/ai-spec/2026-01-21-sdd-inspirations/references/anthropics-claude-plugins-official/plugins/plugin-dev/skills/hook-development
Command: npx skills add https://github.com/kgadek/kgadek-claude-plugin --skill hook-development-kgadek

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Hook Development provides a structured approach to creating event-driven Claude Code hooks that validate tool usage, react to results, and automate plugin workflows across sessions.

Core Features & Use Cases

  • Supports multiple hook events such as PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, and SessionEnd to enforce policies and automate workflows.
  • Offers both prompt-based (LLM-driven reasoning) and command-based (deterministic) hooks, with guidance for integrating into plugin hooks.json or user settings.
  • Provides portable patterns and references (references/, examples/, and scripts) to implement, test, and validate hooks while using ${CLAUDE_PLUGIN_ROOT} for paths.

Quick Start

Create a basic prompt-based PreToolUse hook to validate a tool's input before execution.

Frequently Asked Questions about Hook Development

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

FAQPage Schema
How do I validate tool usage in Claude Code before execution?

Tool usage validation in Claude Code is handled by PreToolUse hooks, which intercept input before execution. You can implement prompt-based LLM reasoning or command-based deterministic checks to enforce policies and block invalid operations.

What events can I use to automate Claude Code plugin workflows?

Claude Code plugin workflows support PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, and SessionEnd events. These events enable automated context loading, policy enforcement, and reactions to tool results across active sessions.

How do I load environment context when a Claude Code session starts?

SessionStart hooks load environment context when a Claude Code session initializes. You reference environment variables using the ${CLAUDE_ENV_FILE} token within your plugin's hooks.json configuration to inject session-specific data.

What is the best way to structure hooks for a Claude Code plugin?

Claude Code plugin hooks should be structured in a hooks.json file using ${CLAUDE_PLUGIN_ROOT} for portable path references. Include YAML frontmatter in SKILL.md for discovery and define both prompt-based and command-based hooks for your events.

Can I use both LLM reasoning and deterministic commands in Claude Code hooks?

Claude Code hooks support both prompt-based and command-based formats. Prompt-based hooks apply LLM-driven reasoning for complex validation, while command-based hooks execute deterministic scripts for strict policy enforcement and automation.

Why do my Claude Code hooks fail to access plugin resources?

Claude Code hooks fail to access plugin resources when paths are hardcoded instead of using the ${CLAUDE_PLUGIN_ROOT} variable. Reference plugin resources via ${CLAUDE_PLUGIN_ROOT} in your hooks.json to ensure portable path resolution across environments.