hooks-reference

Implement and validate event-driven Claude Code hooks with hooks.json structure.

14|1|Updated Dec 21, 2025
One-click install
npx skills add https://github.com/a-ariff/ariff-claude-plugins --skill hooks-reference
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hooks-reference
Source: https://github.com/a-ariff/ariff-claude-plugins/tree/main/plugins/hooks-reference/skills/hooks-reference
Command: npx skills add https://github.com/a-ariff/ariff-claude-plugins --skill hooks-reference

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides guidance on implementing Claude Code hooks to validate and automate workflows and event handling.

Core Features & Use Cases

  • Hook events overview
  • Hook JSON structure
  • Example hooks

Quick Start

Create a PreToolUse hook that blocks writes to sensitive files.

Frequently Asked Questions about hooks-reference

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

FAQPage Schema
How do I implement event-driven hooks in Claude Code?

Event-driven hooks in Claude Code automate workflows by intercepting PreToolUse, PostToolUse, and other events. Define a hooks.json file with matcher patterns, hook types, and exit codes to validate inputs, enforce permissions, and control execution flow based on context conditions.

What is a PreToolUse hook and how do I configure it?

A PreToolUse hook executes before tool invocation, enabling input validation and access control. Configure it in hooks.json with event type, matcher patterns, and a script that reads stdin JSON, performs checks, and returns exit codes to allow or block execution.

Can I use hooks to prevent writes to sensitive files?

Yes. A PreToolUse hook can match file-write operations, validate the target path against sensitive patterns, and return a non-zero exit code to block the operation before it executes, protecting restricted directories from modification.

What does a PostToolUse hook do after tool execution?

PostToolUse hooks run after tool completion for auditing, context propagation, and workflow enforcement. They process execution results via stdin JSON and can update decision state or trigger downstream actions based on the tool's output and exit code.

What structured input and output formats do hooks require?

Hooks receive standardized stdin JSON containing event metadata and context. Output JSON can include decision control fields and context updates. The hooks.json structure defines matcher patterns, hook types, exit codes, and script paths to enforce this contract.

Do I need prior experience with event-driven automation to use hooks?

No prior experience required. This guidance covers hook concepts from fundamentals through advanced patterns. Start with a simple PreToolUse example to block sensitive operations, then progress to complex workflows combining multiple events, matchers, and context propagation.