Claude Code hook
Claude Code Hooks Mastery
Reference project demonstrating every Claude Code hook event with working Python scripts for logging, blocking and TTS.
Install
git clone https://github.com/disler/claude-code-hooks-mastery.gitFrom the README
Claude Code Hooks Mastery Claude Code Hooks - Quickly master how to use Claude Code hooks to add deterministic (or non-deterministic) control over Claude Code's behavior. Plus learn about Claude Code Sub-Agents, the powerful Meta-Agent, and Team-Based Validation with agent orchestration. Table of Contents - Prerequisites - Hook Lifecycle & Payloads - What This Shows - UV Single-File Scripts Architecture - Key Files - Features Demonstrated - Hook Error Codes & Flow Control - UserPromptSubmit Hook Deep Dive - Claude Code Sub-Agents - Team-Based Validation System - Output Styles Collection - Custom Status Lines Prerequisites This requires: - Astral UV - Fast Python package installer and resolver - Claude Code - Anthropic's CLI for Claude AI Optional Setup: Optional: - ElevenLabs - Text-to-speech provider (with MCP server integration) - ElevenLabs MCP Server - MCP server for ElevenLabs - Firecrawl MCP Server - Web scraping and crawling MCP server (my favorite scraper) - OpenAI - Language model provider + Text-to-speech provider - Anthropic - Language model provider - Ollama - Local language model provider Hook Lifecycle & Payloads This demo captures all 13 Claude Code hook lifecycle events with their JSON payloads: Hook Lifecycle Overview 1. UserPromptSubmit Hook Fires: Immediately when user submits a prompt (before Claude processes it) Payload: prompt text, session_id, timestamp Enhanced: Prompt validation, logging, context injection, security filtering 2. PreToolUse Hook Fires: Before any tool execution Payload: tool_name, tool_input parameters Enhanced: Blocks dangerous commands (rm -rf, .env access) 3. PostToolUse Hook Fires: After successful tool completion Payload: tool_name, tool_input, tool_response with results 4. Notification Hook Fires: When Claude…
How hooks work
- Hooks are shell commands Claude Code runs at fixed points: before or after a tool call, when you submit a prompt, when Claude stops, on notifications and at session start.
- They are set in the hooks section of ~/.claude/settings.json (or .claude/settings.json for a project), or come bundled in a plugin.
- A hook can block a tool call, add context, or run a formatter or test. Read the scripts before you install them: they run on your machine with your permissions.
Details
- Repository
- disler/claude-code-hooks-mastery
- Type
- Hooks
- Language
- Python
- Last updated
- 4 March 2026
FAQ
What is Claude Code Hooks Mastery?
Reference project demonstrating every Claude Code hook event with working Python scripts for logging, blocking and TTS. It is a hook for Claude Code, from disler/claude-code-hooks-mastery on GitHub.
How do I install Claude Code Hooks Mastery?
Clone disler/claude-code-hooks-mastery from GitHub and follow the setup steps in its README.
Is Claude Code Hooks Mastery popular?
disler/claude-code-hooks-mastery has 3,972 GitHub stars and 640 forks, and is included in 3 curated Claude Code lists. It was last updated on 4 March 2026.
More hooks
Multi-Agent Observability
1.6kdisler/claude-code-hooks-multi-agent-observability
Streams hook events from many Claude Code agents to a live web dashboard for real-time monitoring.
Claude Code Ultimate Guide
6.3kFlorianBruniaux/claude-code-ultimate-guide
The most comprehensive Claude Code guide: agentic workflows, hooks, skills, MCP servers, quizzes, and production-ready templates. 430K+ lines.
destructive_command_guard
6.2kDicklesworthstone/destructive_command_guard
Fast Rust PreToolUse hook that stops destructive shell, git and filesystem commands before they run.
Continuous Claude V3
3.9kparcadei/Continuous-Claude-v3
Context management for Claude Code. Hooks maintain state via ledgers and handoffs. MCP execution without context pollution. Agent orchestration with isolated context windows.
TDD Guard
2.4knizos/tdd-guard
Hook-based enforcer that blocks code changes which skip the red-green-refactor TDD cycle.
Everything Claude Code
5.8kWorldFlowAI/everything-claude-code
Claude Code toolkit - agents, commands, skills, rules, and hooks for productive AI-assisted development
Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.