hook-development

Build event-driven Claude Code plugin hooks that validate tool usage.

1|Updated Mar 30, 2026
One-click install
npx skills add https://github.com/Leap0920/Clean-Portfolio --skill hook-development-leap0920
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-development
Source: https://github.com/Leap0920/Clean-Portfolio/tree/main/%25USERPROFILE%25/.openclaude/plugins/marketplaces/claude-plugins-official/plugins/plugin-dev/skills/hook-development
Command: npx skills add https://github.com/Leap0920/Clean-Portfolio --skill hook-development-leap0920

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps you design and implement Claude Code plugin hooks that validate and control tool usage safely across key hook events.

Core Features & Use Cases

  • Prompt-based hooks for context-aware validation: Use LLM reasoning to approve, deny, or ask before/after tool actions based on natural-language criteria.
  • Command-based hooks for deterministic checks: Use bash scripts for fast, reliable validation (e.g., schema checks, path safety, lightweight policy enforcement).
  • Hook lifecycle guidance across events: Covers common events like PreToolUse, PostToolUse, Stop, SessionStart, SessionEnd, PreCompact, Notification, and more, including expected input/output formats and decision structures.
  • Security guardrails: Guidance for input validation, path traversal prevention, sensitive file blocking, portable paths via ${CLAUDE_PLUGIN_ROOT}, timeouts, and safe JSON output.

Quick Start

Ask Claude to help you create a PreToolUse prompt hook that blocks attempts to write outside the project directory and denies writes to files that look like secrets.

Frequently Asked Questions about hook-development

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

FAQPage Schema
How do I create Claude Code hooks to validate tool usage safely?

Claude Code hooks validate or control tool usage safely by configuring event-driven plugin hooks that apply deterministic command scripts or context-aware LLM prompt checks across PreToolUse and PostToolUse events.

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

Prompt-based plugin hooks use LLM reasoning to approve, deny, or ask before tool actions based on natural-language criteria, while command-based hooks use bash scripts for fast, deterministic validation like schema checks and path safety.

How do I configure PreToolUse hooks to block writes outside the project directory?

Configuring PreToolUse hooks to block writes outside the project directory requires setting valid event matchers and structured decision JSON outputs, using portable ${CLAUDE_PLUGIN_ROOT}-based script paths to intercept and deny unsafe file modifications.

Which hook lifecycle events are supported for automating Claude Code sessions?

Supported hook lifecycle events for automating Claude Code sessions include PreToolUse, PostToolUse, Stop, SessionStart, SessionEnd, PreCompact, and Notification, each featuring specific input and output formats for structured decisions.

What security guardrails are needed for Claude Code hook configuration?

Security guardrails for Claude Code hook configuration include input validation, path traversal prevention, sensitive file blocking, portable paths via ${CLAUDE_PLUGIN_ROOT}, timeout-aware handling, and safe structured JSON output.

Why are my Claude Code plugin hooks timing out or failing to execute?

Claude Code plugin hooks time out or fail when lacking timeout-aware input handling, using non-portable script paths instead of ${CLAUDE_PLUGIN_ROOT}, or outputting malformed decision JSON structures that break event matchers.