hooks

Create and manage Claude Code hooks for event automation and validation.

3|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/BenjaminG/ai-skills --skill hooks-benjaming
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hooks
Source: https://github.com/BenjaminG/ai-skills/tree/main/hooks
Command: npx skills add https://github.com/BenjaminG/ai-skills --skill hooks-benjaming

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill enables developers to automate Claude Code workflows by creating and managing hooks that respond to events like PreToolUse, PostToolUse, UserPromptSubmit, Stop, SessionStart, and PermissionRequest, ensuring consistent behavior and safety.

Core Features & Use Cases

  • Create and configure event hooks to validate prompts, format outputs, load session context, and control execution flow.
  • Provide deterministic command-based or intelligent prompt-based hooks that integrate with MCP tools, project settings, and user workflows.
  • Example: automatically validate a user input prompt and attach current session context at startup to streamline tool usage.

Quick Start

Start by registering a PreToolUse hook to validate Bash commands. For example, configure a hook that runs validate_bash.py whenever a Bash tool is invoked and hooks that log or enforce style after edits.

Frequently Asked Questions about hooks

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

FAQPage Schema
How do I automate Claude Code workflows with hooks?

Automate Claude Code workflows by configuring event hooks like PreToolUse, PostToolUse, and UserPromptSubmit to validate prompts, format outputs, and control execution flow. Define input/output schemas and matchers in YAML frontmatter to tailor behavior automatically.

What events can I configure hooks for in Claude Code?

Claude Code hooks support PreToolUse, PostToolUse, UserPromptSubmit, Stop, SessionStart, and PermissionRequest events. These events enable automated tool usage, input sanitization, session context loading, and execution flow control across projects.

Can I validate Bash commands before execution in Claude Code?

Yes, register a PreToolUse hook to validate Bash commands before execution. Configure a hook that runs a validation script like validate_bash.py whenever a Bash tool is invoked to ensure command safety and enforce style.

How do I load session context automatically at Claude Code startup?

Load session context automatically by configuring a SessionStart hook. This event hook attaches current session context at startup to streamline tool usage and provide necessary environment details without manual intervention.

Do I need YAML frontmatter to configure Claude Code hooks?

Yes, YAML frontmatter with name and description fields is required in SKILL.md to configure Claude Code hooks. You also need a detailed operational body and can optionally include resources under scripts, references, and assets.

Are Claude Code hooks command-based or prompt-based?

Claude Code hooks can be deterministic command-based or intelligent prompt-based. Command-based hooks execute specific scripts, while prompt-based hooks integrate with MCP tools and project settings to provide more dynamic workflow automation.