Skip to main content

Hook Components

Hooks are automation triggers that execute before or after specific events. They enable automated workflows, validation, and enforcement of best practices.

Browse All Hooks

Explore 45+ hooks at aitmpl.com

Installation

Hook Categories

Git Hooks

Automate git workflows and enforce commit standards:

Conventional Commits

Enforce conventional commit message format
Validates:
  • Commit message format (feat:, fix:, docs:, etc.)
  • Scope and description
  • Breaking change notation

Prevent Direct Push

Block direct pushes to protected branches
Protects:
  • main/master branches
  • production branches
  • Enforces PR workflow

Validate Branch Name

Enforce branch naming conventions
Enforces:
  • feature/, bugfix/, hotfix/ prefixes
  • Lowercase with hyphens
  • Ticket/issue references

Hook Types

Pre-Commit Hooks

Run before a commit is created:
  • Validate commit messages
  • Run linters and formatters
  • Check for secrets
  • Run tests

Pre-Push Hooks

Run before pushing to remote:
  • Run full test suite
  • Check branch protection
  • Validate no uncommitted changes

Pre-Tool Hooks

Run before Claude Code tool execution:
  • Validate environment
  • Check permissions
  • Load context

Post-Tool Hooks

Run after Claude Code tool execution:
  • Clean up temporary files
  • Update metrics
  • Send notifications

Hook Configuration

Hooks are stored in .claude/hooks/:

Python Script Hooks

Many hooks use Python scripts for complex logic:

Example Usage

Disabling Hooks

Temporarily bypass hooks when needed:

Creating Custom Hooks

Create your own hooks:
  1. Create JSON config in .claude/hooks/
  2. Create Python script in .claude/scripts/ (if needed)
  3. Test the hook
  4. Share with your team

Next Steps