HKS14 verified hooks

9 Best Claude Code Hooks — Automate Your Development Workflow

A Claude Code hookis an event-driven automation script that runs at specific points during Claude's tool execution lifecycle. Hooks intercept actions like file writes, shell commands, and code generation to inject custom logic without requiring manual input from the developer. They are the primary mechanism for building guardrails, enforcing standards, and extending Claude Code's capabilities beyond its default behavior.

The hook system in Claude Code operates on a simple but powerful model: trigger, match, execute. Each hook defines a trigger event (such as PreToolUse or PostToolUse), an optional tool name matcher to narrow scope, and a command that runs when conditions are met. The command receives structured JSON input through stdin containing the tool name, parameters, and context. It returns a JSON response that can approve the operation, block it with a reason, or modify the inputs before they reach the tool.

Pre-tool hooks fire before Claude executes a tool. They are ideal for security enforcement, input validation, and policy compliance. A common pre-tool hook pattern is the secret scanner, which inspects file content for API keys, passwords, and tokens before Claude writes them to disk. Another popular pattern is the command guard, which blocks dangerous shell commands like rm -rf /, git push --force, or database drop statements from ever executing.

Post-tool hooks fire after a tool completes and are used for notifications, logging, follow-up actions, and result validation. For example, a post-tool hook can send a Slack message every time Claude modifies a critical configuration file, log all shell command outputs to an audit trail, or automatically run a linter on any code file Claude has changed. Post-tool hooks are also valuable for chaining workflows: after Claude writes a test file, a hook can automatically run the test suite and feed results back into the conversation.

Security-focused teams find hooks indispensable. By layering multiple hooks, you create a defense-in-depth architecture around Claude's tool usage. A pre-commit review hook can analyze all staged changes for code quality before Claude commits them. A dependency audit hook can check newly added packages against vulnerability databases. These automated checks run consistently on every operation, eliminating the human inconsistency that comes with manual code review.

Notification hooks bridge Claude Code with your team's communication tools. When Claude completes a significant operation, such as finishing a refactoring task, deploying to staging, or encountering an error it cannot resolve, notification hooks can post updates to Slack channels, create Jira tickets, send email alerts, or update project management dashboards. This keeps the entire team informed about what the AI agent is doing without anyone needing to monitor the terminal.

Building custom hooks requires minimal boilerplate. A hook script can be as simple as a ten-line bash script that checks a condition and returns a JSON verdict, or as sophisticated as a Python service that calls external APIs for validation. The hook protocol is language-agnostic: anything that reads JSON from stdin and writes JSON to stdout works. This flexibility means you can integrate hooks with existing tooling, corporate compliance systems, or custom business logic without rearchitecting your workflow.

This directory contains 14 curated hooks covering the most common automation patterns. Each hook has been tested for reliability, documented for ease of installation, and categorized by use case. Whether you need to enforce security policies, automate notifications, ensure code quality, or build custom workflow triggers, you will find production-ready solutions below.

All Hooks & Triggers

14 resources

Claude Code Hooks Mastery Guide

Intermediate

Comprehensive guide to all 13 Claude Code hook lifecycle events with practical examples. Covers prompt validation, security controls, AI-powered TTS feedback, sub-agents, and team-based validation workflows.

hookslifecycle-eventssecurity
3,500by disler
GitHub

Pre-Commit Code Review Hook

Beginner

Git pre-commit hook that runs Claude Code review on staged changes. Blocks commits with critical issues, warns on style violations, and auto-fixes formatting.

git-hookspre-commitcode-review
1,654by hooksmith
GitHub

AI Prompt Secret Scanner

Beginner

Local proxy and Claude Code hook that blocks secrets before they reach AI APIs -- zero data leakage

git-hookspre-commitsecurity
1,432by secretguard
GitHub

Smart Commit Message Generator

Beginner

prepare-commit-msg hook that generates Conventional Commits messages from staged diffs. Understands scope, breaking changes, and linked issues automatically.

git-hookscommit-messageconventional-commits
1,234by commitcraft
GitHub

Auto-Format Hook (Prettier/Biome/Ruff)

Beginner

Auto-format code when Claude Code edits files -- supports Prettier, Biome, Ruff for JS/TS/Python/Go/Markdown

git-hookspre-commitprettier
1,098by prettierhook
GitHub

Branch Guardian

Intermediate

Pre-push hook that validates branch conventions, checks for secrets, ensures test coverage thresholds, and prevents force-pushes to protected branches.

git-hookspre-pushsecurity
876by guardian_hooks
GitHub

Pre-Commit Validation Hook

Intermediate

Pre-commit hooks for validating Claude Code configuration files, skills, hooks, and settings

git-hookspre-committesting
876by testfirst
GitHub

Desktop Notification Hook

Beginner

Lightweight macOS desktop notification hook for Claude Code events with customizable sounds

git-hookspost-pushnotifications
765by notifyhook
GitHub

Auto-Format on Save Hook

Beginner

Post-checkout and post-merge hook that auto-formats code using project-specific formatters. Detects Prettier, Black, rustfmt, gofmt, and runs the right tool.

git-hooksformattingprettier
654by formatflow
GitHub

Git Branch & Commit Convention Hook

Beginner

Automates git operations with standardized branch naming and commit message conventions

git-hooksbranch-namingconventions
543by branchpolicy
GitHub

Claude Notifications (Cross-Platform)

Beginner

Cross-platform smart notifications for Claude Code with 6 notification types. Supports webhooks for Slack, Discord, Telegram, PagerDuty, Zapier, and n8n. Zero dependencies, written in Go.

notificationsslackdiscord
480by 777genius
GitHub

Claude Code Harness (Plan-Work-Review)

Advanced

Plugin enforcing a structured Plan-Work-Review-Release development cycle with a TypeScript protection engine featuring 13 declarative rules. Prevents destructive operations like force-pushes and secret exposure.

harnessquality-gateforce-push-blocker
423by Chachamaru127
GitHub

Claude Code Hooks Library (55+)

Beginner

55+ plug-and-play Claude Code hooks organized by category: security (blocking dangerous commands), quality (auto-linting), git (conventional commits), productivity, logging, and notifications (desktop/Slack).

hookssecurityquality
280by CodyLunders
GitHub

Claude Hooks (Quality & Notifications)

Intermediate

Python-based hook system for Claude Code enabling automatic quality checks and validation. Features code quality validation (max function length), package age checking, and task completion notifications via Pushover.

hooksquality-checksnotifications
69by decider
GitHub

Frequently Asked Questions

What are Claude Code hooks?

Claude Code hooks are event-driven automation scripts that execute at specific points during Claude Code operations. They let you intercept tool calls, file modifications, and command executions to run custom logic such as linting, security checks, notifications, or logging. Hooks are configured in your project settings or CLAUDE.md file and run automatically without manual intervention.

How do I install a Claude Code hook?

To install a Claude Code hook, add a hook configuration block to your project settings file (typically .claude/settings.json) or define it in your CLAUDE.md file. Each hook specifies a trigger event (such as pre-tool-use or post-tool-use), an optional matcher pattern to filter which tools activate it, and a command to execute. After saving the configuration, Claude Code automatically loads and runs the hook at the appropriate time.

What is the difference between pre-tool and post-tool hooks?

Pre-tool hooks execute before Claude runs a tool, giving you a chance to validate inputs, block dangerous operations, or modify parameters. For example, a pre-tool hook can prevent Claude from writing to protected files or reject shell commands that contain destructive flags. Post-tool hooks execute after a tool completes, allowing you to process results, send notifications, run additional validation on output, or trigger downstream workflows.

Can hooks improve security in Claude Code?

Yes, hooks are one of the most effective ways to enforce security policies in Claude Code. Security hooks can scan file modifications for secrets or credentials before they are written to disk, block shell commands that match dangerous patterns (like rm -rf or force pushes), validate that generated code does not introduce known vulnerability patterns, and audit all tool usage for compliance logging. Many teams use hooks as a security layer between Claude and their codebase.

How do I create a custom Claude Code hook?

Creating a custom hook involves writing a script (shell, Python, Node.js, or any executable) that processes input from stdin and returns a result via stdout. The script receives a JSON payload containing the hook event type, tool name, and relevant parameters. Your script can then perform any logic and return a JSON response indicating whether to proceed, block the operation, or modify the inputs. Register the script in your settings file under the hooks configuration section with the appropriate trigger event.

Know a hook we're missing?

Help us build the most complete directory of Claude Code hooks and triggers.

Submit a Resource