plugin-hooks

Author Claude Code hooks with syntax rules and exit-code contracts.

10|2|Updated Mar 12, 2026
One-click install
npx skills add https://github.com/viktorbezdek/skillstack --skill plugin-hooks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: plugin-hooks
Source: https://github.com/viktorbezdek/skillstack/tree/main/plugin-dev/skills/plugin-hooks
Command: npx skills add https://github.com/viktorbezdek/skillstack --skill plugin-hooks

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Many developers struggle with the complexity of Claude Code hooks, often falling into common traps such as non‑blocking exit codes, incorrect matcher syntax, and unsafe updatedInput handling. This Skill provides a clear, authoritative guide to writing correct, secure hooks and avoids the most frequent pitfalls.

Core Features & Use Cases

  • Comprehensive Hook Mechanics: Detailed explanations of all 24+ events, matcher modes, exit‑code contracts, and handler types (command, http, prompt, agent).
  • Anti‑Pattern Checklist: Quick reference to the 14 most common mistakes, including the exit‑code‑1 trap, infinite Stop loops, and matcher regex pitfalls.
  • Practical Reference Implementations: Ready‑to‑use hooks.json examples for PreToolUse blockers, PostToolUse formatters, SessionStart context injection, Stop loop guards, Notification alerts, FileChanged watchers, and WorktreeCreate provisioning.

Quick Start

Use the plugin-hooks skill to get step‑by‑step guidance for creating a PreToolUse hook that blocks risky commands.

Frequently Asked Questions about plugin-hooks

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

FAQPage Schema
How do I write a Claude Code PreToolUse hook to block risky commands?

To write a Claude Code PreToolUse hook, define a JSON configuration with the correct event matcher and a command handler that returns a non-zero exit code to block unsafe tool actions. This Skill provides step-by-step guidance and reference implementations for creating these blockers safely.

Why does my Claude Code hook fail to block tool execution with exit code 1?

Claude Code hooks fail to block execution when using the exit-code-1 trap, a common anti-pattern. Correct hook authoring requires following specific exit-code contracts where exit code 2 blocks the tool action and outputs the stderr to the model, ensuring safe automation.

What events are available for Claude Code hooks automation?

Claude Code hooks support over 24 event-driven automation triggers including PreToolUse, PostToolUse, SessionStart, Stop, Notification, FileChanged, and WorktreeCreate. These events allow you to intercept and automate workflows across various stages of tool execution and session management.

Can I use Claude Code hooks for event-driven security and workflow automation?

Yes, Claude Code hooks are designed for event-driven security and workflow automation. You can implement safe handlers across events like PreToolUse and FileChanged to prevent unsafe tool actions, inject context, and format outputs automatically.

What are the most common mistakes when configuring Claude Code hooks matchers?

Common Claude Code hook matcher mistakes include incorrect regex syntax and non-blocking exit codes. This Skill provides an anti-pattern checklist covering the 14 most frequent errors, such as matcher regex pitfalls and infinite Stop loops, to ensure correct configuration.

How do I prevent infinite Stop loops in Claude Code hooks?

To prevent infinite Stop loops in Claude Code hooks, implement loop guards as specified in the hook exit-code contracts. This Skill details how to avoid these anti-patterns by providing practical reference implementations for Stop event handlers.