managing-hooks

Create, analyze, update, and validate Claude Code hook configurations across nine event types.

Updated Nov 26, 2025
One-click install
npx skills add https://github.com/thoeltig/claude-code-toolkit --skill managing-hooks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: managing-hooks
Source: https://github.com/thoeltig/claude-code-toolkit/tree/main/plugins/claude-code-capabilities/skills/managing-hooks
Command: npx skills add https://github.com/thoeltig/claude-code-toolkit --skill managing-hooks

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Claude Code hooks control automated actions at various lifecycle points. This Skill helps design, implement, analyze, and secure hooks across multiple event types (command-based and prompt-based) with guidance for security validation, debugging, and evolution.

Core Features & Use Cases

  • Create new hooks with event type, matcher, and actions
  • Analyze existing hooks for performance, reliability, and security
  • Validate hook configurations against security and policy checklists
  • Debug hook activation and timing across events
  • Update hook configurations and patterns as requirements evolve
  • Understand hook concepts and event lifecycles (PreToolUse, PostToolUse, SessionStart, SessionEnd, Stop, SubagentStop, UserPromptSubmit, Notification, PreCompact)

Quick Start

Create a basic PreToolUse hook for the Write tool to demonstrate blocking or modifying input, then test with a simple input transcript.

Frequently Asked Questions about managing-hooks

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

FAQPage Schema
How do I create hooks that control actions at specific Claude Code events?

Hooks intercept and manage automated actions at lifecycle points like PreToolUse, PostToolUse, SessionStart, and SessionEnd. Create a hook by specifying the event type, a matcher pattern, and actions to execute—such as blocking tool calls, modifying inputs, or logging events—then validate the configuration against security requirements before deployment.

What are the different event types I can hook into with Claude Code?

Claude Code supports nine event types: PreToolUse and PostToolUse for tool execution, SessionStart and SessionEnd for lifecycle, Stop and SubagentStop for agent control, UserPromptSubmit for prompts, Notification for alerts, and PreCompact for context management. Each event type enables governance at different workflow stages.

How do I debug hooks that aren't activating or firing at the right time?

Debug hook activation by analyzing event timing, matcher patterns, and action execution flow. Use comprehensive logging and validation checks to confirm hooks trigger at the expected lifecycle points, verify matcher conditions are met, and trace exit-code semantics to identify why hooks may skip or fail silently.

What security validations should I apply when designing hooks?

Enforce input validation, standardized JSON outputs, and exit-code semantics. Apply security checklists to validate hook configurations, enforce policy governance across tool-based, lifecycle, agent, and context events, and audit hooks that merge configurations from user, project, and plugin sources to prevent unauthorized or malicious actions.

Can I use the same hook configuration across multiple Claude Code event types?

No. Each event type (PreToolUse, PostToolUse, SessionStart, SessionEnd, Stop, SubagentStop, UserPromptSubmit, Notification, PreCompact) requires its own hook configuration. You can merge configurations from user, project, and plugin sources, but matchers and actions must align with the specific event type's semantics and available parameters.

How do I update hook configurations as my security or workflow requirements evolve?

Analyze existing hooks for performance, reliability, and security gaps, then update patterns and actions to meet new requirements. Validate updated configurations against security and policy checklists, test across relevant event types, and redeploy to enforce the revised governance rules.