Curated collection of Claude Code hooks — event-driven automations that trigger before or after Claude Code actions.
Hooks are shell commands that run automatically when Claude Code performs specific actions. They're defined in settings.json and trigger on events like PreToolUse, PostToolUse, Notification, Stop, and more.
Looking for complete workflow recipes? See awesome-claude-code-workflows. Looking for tools and skills? See awesome-claude-code.
- Security and Prompt Injection
- Safety and Protection
- Monitoring and Observability
- Code Quality Gates
- Context and Memory
- Model Routing and Cost
- Session Management
- File Organization
- Notification and Alerts
- Voice and Sound
- Git Integration
- Hook SDKs and Frameworks
- Hook Collections
- Creative and Utility
- Learning Resources
Hooks that detect and block prompt injection attacks in tool outputs.
- Lasso Claude-Hooks - Scans tool outputs for 50+ prompt injection patterns including instruction overrides, role-playing jailbreaks, encoded payloads, and data exfiltration commands. Injects warnings into Claude's context. Triggers on:
PostToolUse. - dwarvesf/claude-guardrails - Hardened security config with deny rules, destructive command blocking, pipe-to-shell blocking, data exfiltration prevention, and prompt injection scanning. Lite (3 hooks) and Full (5 hooks + scanner) modes. Install via
npx claude-guardrails install. Triggers on:PreToolUse,PostToolUse. - CloneGuard - 4-layer defense: pre-execution repo scan, InstructionsLoaded hook, PostToolUse output scanning, PreToolUse write/build gating. Uses ONNX embedding classifier (non-promptable) instead of LLM for detection. Works with Claude Code, Gemini CLI, Cursor. Triggers on:
PreToolUse,PostToolUse,InstructionsLoaded. - claude-injection-guard - Two-stage prompt injection guard: Stage 1 is regex (zero deps, sub-ms), Stage 2 escalates to local LLM (Ollama/LM Studio). Zero data leaves your machine. Triggers on:
PostToolUse(WebFetch). - rulebricks/claude-code-guardrails - Real-time guardrails for Claude Code tool calls. 61 stars. Triggers on:
PreToolUse,PostToolUse. - panuhorsmalahti/claude-code-permissions-hook - Rust-based granular permission controls via TOML config. Allow/deny rules with regex pattern matching, exclude patterns for edge cases, and JSON audit logging. Workaround for current Claude Code permission limitations. Triggers on:
PreToolUse. - liberzon/claude-hooks - Smart PreToolUse hook that decomposes compound bash commands (
&&,||,;,|,$(), newlines) into individual sub-commands and checks each against your allow/deny patterns. Loads permissions from all settings layers (global + project + local). Triggers on:PreToolUse(Bash).
Hooks that prevent Claude Code from making unwanted changes.
- wangbooth/Claude-Code-Guardrails - Protective hooks that prevent accidental code loss through branch protection, automatic checkpointing, and safe commit squashing. 51 stars. Triggers on:
PreToolUse,PostToolUse. - gstack freeze/guard - Lock critical files from modification. Uses
PreToolUsehook definitions in SKILL.md frontmatter (not hooks.json) with real shell scripts (freeze/bin/check-freeze.sh). Note: only enforced in Claude Code — generated Codex skill docs are advisory prose only. Found infreeze/SKILL.md.tmplandguard/SKILL.md.tmpl. Triggers on:PreToolUse(Write/Edit). - Everything Claude Code hook profiles - 26 hook entries across 7 event groups with 27 hook scripts. Three preset safety levels: minimal, standard, strict. Codex-verified counts: 116 skills, 28 agents, 59 commands. Triggers on:
PreToolUse,PostToolUse, and 5 other event types. - Pre-commit hook guard - Official example: block commits that skip pre-commit hooks (prevents
--no-verify). Triggers on:PreToolUse(Bash).
Hooks that track and visualize Claude Code activity in real-time.
- Multi-Agent Observability Dashboard - Real-time monitoring dashboard for Claude Code agents through hook event tracking. Streams tool usage events to a web UI. 1,289 stars. Triggers on: all hook events.
- MadameClaude - Monitoring system that captures and streams tool usage events to a web interface in real-time. 21 stars. Triggers on:
PreToolUse,PostToolUse. - ccproxy - Proxy that hooks into Claude Code requests for intelligent model routing, request/response modification, and LangFuse tracking. 189 stars. Triggers on: request-level proxy hooks.
Hooks that enforce code quality standards automatically.
- Auto-lint on save - Run linter after every file write. Reject changes that introduce lint errors. Found in
hooks/hooks.json. Triggers on:PostToolUse(Write/Edit). - Claude Organize - AI-powered file organization hook that automatically sorts temporary scripts from permanent docs. Understands content, not just patterns. 61 stars. Triggers on:
PostToolUse(Write/Edit).
Hooks that manage what Claude knows across sessions and compactions.
- post_compact_reminder - Detects context compaction and injects a reminder to re-read AGENTS.md, preventing post-compaction rule amnesia in long sessions. 34 stars. Triggers on:
PostCompact. - Continuous Claude v3 - Context management via hooks that maintain state through ledgers and handoffs. MCP execution without context pollution. Agent orchestration with isolated context windows. 3,619 stars. Triggers on: multiple lifecycle hooks.
- Memory injection hook - Inject alerts, briefings, and relevant memories before each message. Scans memory files and surfaces the most relevant context. Found in
hooks/hooks.json. Triggers on: pre-message. - Founder OS institutional memory - Accumulates learnings from task completions into
.claude/learnings/. Future sessions automatically reference past lessons. Triggers on: task completion.
Hooks that optimize model selection and track spending.
- claude-model-router-hook - Auto-switches model tier based on task complexity (e.g., Haiku for simple reads, Opus for complex reasoning). 25 stars. Triggers on:
PreToolUse. - Cost tracker hook - Tracks token usage and estimated cost per session. Part of a 10-hook collection. Triggers on:
PostToolUse.
Hooks that manage Claude Code session state.
- Everything Claude Code session persistence - Save and restore session context across restarts. Auto-dumps important state on session end, reloads on next start. Triggers on:
Stop, session start. - Superpowers session-start - Auto-load project context and active tasks when starting a new session. Found in
hooks/hooks.json. Triggers on: session start.
Hooks that keep your project directory clean.
- Claude Organize - Automatically moves files Claude creates in the wrong place. Scripts go to
scripts/, docs go todocs/, test results go todocs/testing/. 10 script subcategories. 61 stars. Triggers on:PostToolUse(Write).
Hooks that notify you about Claude Code activity.
- claude-code-toast - macOS toast notification when Claude Code is waiting for user response. 16 stars. Triggers on:
Notification. - aily - Discord notifications with per-tmux-session threads. Each Claude session gets its own Discord thread. 6 stars. Triggers on:
Notification,Stop. - Desktop notification on complete - Official example: send system notification when a long-running task completes. Triggers on:
Stop. - Solopreneur decision logger - Auto-logs every user decision with reasoning when Claude asks a question. Creates an observer protocol for future reference. Triggers on:
PostToolUse(AskUserQuestion).
Hooks that add audio feedback to Claude Code events.
- Voice output hooks - Adds text-to-speech voice output to Claude Code responses and notifications. 187 stars. Triggers on:
Notification,Stop. - SCV Sounds - StarCraft SCV sound effects for hook events (tool use, completion, errors). 38 stars. Triggers on:
PreToolUse,PostToolUse,Stop,Notification.
Hooks that connect Claude Code actions to git operations.
- GitButler Claude Code hooks - Official GitButler integration: PreToolUse creates session-specific git index, PostToolUse stages files, Stop commits to per-session branch under
refs/heads/claude/. Enables parallel sessions with isolated branches. By Scott Chacon. Triggers on:PreToolUse,PostToolUse,Stop. - Auto-checkpoint on skill completion - Automatically creates a git commit after every skill finishes running. Ensures you can always roll back. Triggers on: skill completion.
- Branch-per-task pattern - Auto-create a new branch when starting a task from the queue. Isolates work for clean PR creation. Triggers on: task start.
Tools for building and managing hooks in different languages.
- cchooks (Python) - Python SDK for building Claude Code hooks. Abstracts stdin/stdout JSON handling, exit codes, and event matching. 123 stars.
- cc-hooks-ts (TypeScript) - TypeScript SDK with full type safety for defining hooks. 35 stars.
- claude-hooks-sdk (PHP) - PHP SDK for building Claude Code hooks. 62 stars.
- claude_hooks (Ruby) - Ruby DSL for creating Claude Code hooks. 36 stars.
- claude-hooks CLI manager - CLI manager for hooks — add, remove, list, toggle hooks without editing JSON. 73 stars.
- Hookify plugin - Zero-JSON hook creation via natural language.
/hookify Block rm -rf commandscreates the hook without editing settings.json.
Repos that bundle multiple hooks together.
- karanb192/claude-code-hooks - 10-hook collection: cost-tracker, rate-limiter, branch-guard, protect-tests, context-snapshot, ntfy-notify, discord-notify, tts-alerts, rules-injector, session-summary. Copy-paste ready. 298 stars.
- Aedelon/claude-code-blueprint - 11 hooks covering 9 of 17 lifecycle events: session-start, session-end, user-prompt-secrets, bash-guard, write-format, bash-vuln (npm audit), posttooluse-failure logging, stop (git summary), pre-compact (context preservation), and permission-git warnings. All scripts start with
set -euo pipefail+trap ERRfor fail-closed behavior. - decider/claude-hooks - Comprehensive hooks for enforcing clean code practices and automating workflows. Covers formatting, linting, and code quality gates.
- JalelTounsi/claude-code-skills - 30 hooks including 6 mandatory security hooks: pre-commit secret scanning (25+ patterns), destructive command blocking (
rm -rf /,DROP DATABASE,chmod 777), and progressive adoption tiers. Part of a 138-skill collection.
Unique and experimental hooks.
- cc-dice - Probabilistic dice triggers — adds randomness to hook execution (e.g., only run expensive checks 20% of the time). Wraps any hook event. 21 stars.
Guides and tutorials for writing hooks.
- Claude Code Hooks Mastery - Complete reference implementation of all 13 hook lifecycle events with JSON payloads captured. Includes TTS, Ruff linting, transcript extraction, sub-agent hooks, and team-based validation. 3,379 stars.
- 95-hook production infrastructure - Blog documenting 95 production hooks across 4 layers: Prevention (PreToolUse), Context (UserPromptSubmit), Validation (PostToolUse), Quality (Stop). Includes recursion-guard, circuit-breaker, and pride-check.
- Claude Code official hooks docs - Official documentation covering all hook events, configuration, and best practices.
- gstack hooks patterns - Production hooks for file protection (freeze/guard) used by a YC partner.
- Claude Directory hooks guide - Complete guide with layered pipeline config combining prevention (PreToolUse), enforcement (PostToolUse), and notification (Stop) hooks into a production-ready setup.
- Blake Crosley hooks tutorial - Step-by-step tutorial building 5 production hooks from scratch: auto-formatter, security gate, test runner, notification alert, and pre-commit quality check. By the author of the 95-hook production infrastructure.
- 12 Automation Configs (heyuan110) - 12 copy-paste-ready hook configs covering all 15 lifecycle events. Includes Prettier auto-format, file protection, command blocking, and team-sharing patterns.
- Serenities AI hooks guide - Covers all 18 hook events including newer ones (ConfigChange, WorktreeCreate, WorktreeRemove). Introduces HTTP hook type for remote webhook integration.
- Agent Rules Builder — 10 hook scripts - 10 production-ready hook scripts with full shell code, JSON config, and testing instructions. Covers auto-format, destructive command blocking, file protection, git context loading, and post-compact recovery.
- awesome-claude-code-workflows - Workflow recipes that combine hooks with skills, MCP servers, and agents.
- awesome-claude-code - Comprehensive catalog of Claude Code tools, skills, hooks, agents, and plugins.
- awesome-mcp-servers - The definitive list of MCP servers.
- awesome-claude-skills - Claude Code skills collection.
See CONTRIBUTING.md for guidelines. We curate, not collect — not every submission will be accepted.