hook-patterns

Document Claude Code hook patterns and writing standards for pre- and post-tool use actions.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/Piece-Puzzly/Piece-iOS --skill hook-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-patterns
Source: https://github.com/Piece-Puzzly/Piece-iOS/tree/main/.claude/skills/_hook-patterns
Command: npx skills add https://github.com/Piece-Puzzly/Piece-iOS --skill hook-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear guidelines and examples for implementing and standardizing Claude Code hooks, ensuring consistency and best practices in hook development.

Core Features & Use Cases

  • Hook vs Skill Distinction: Clearly defines the purpose and trigger mechanisms for hooks versus skills.
  • Hook Types: Explains PreToolUse and PostToolUse hooks with their respective use cases.
  • Writing Standards: Details file structure, script templates, and blocking response formats.
  • Use Case: A developer needs to implement a hook to validate commit messages before they are committed. This Skill provides the necessary patterns and examples to create such a hook.

Quick Start

Refer to the hook-patterns skill for guidance on creating a PreToolUse hook to validate bash commands.

Frequently Asked Questions about hook-patterns

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

FAQPage Schema
How do I set up a PreToolUse hook to validate bash commands in Claude Code?

To validate bash commands with a PreToolUse hook, refer to the hook-patterns standards for file structure, script templates, and blocking response formats. These ensure automated pre-tool use actions execute consistently and securely before the command proceeds.

What is the difference between Claude Code hooks and skills?

Claude Code hooks and skills differ in their trigger mechanisms and purposes. Hooks execute automated pre-tool use actions for validation and logging, whereas skills are broader functional modules invoked under different contextual conditions.

How do I create a hook to validate commit messages before they are committed?

To validate commit messages before they are committed, implement a PreToolUse hook using the provided script templates and writing standards. This automates the validation process by intercepting the commit action and returning a blocking response format if the message fails checks.

When should I use PreToolUse versus PostToolUse hooks for automation and logging?

Use PreToolUse hooks for automation tasks requiring validation before an action executes, such as checking commit formats. Use PostToolUse hooks for logging or triggering actions immediately after a tool completes its operation, ensuring secure tool execution workflows.

What is the correct file structure and blocking response format for standardized Claude Code hooks?

Standardized Claude Code hooks require a specific file structure and script templates defined in the hook writing standards. The blocking response format ensures that validation failures properly halt the automated tool execution workflow securely and consistently.