</>MCP Agents Market
Plugin

claude-code-hooks-mastery

by disler3.9kPythonUpdated 2026-03-04

Master Claude Code Hooks

Claude Code

claude-code-hooks-mastery is an educational repository demonstrating all 13 Claude Code hook lifecycle events with working Python implementations. It provides developers with ready-to-use hooks for prompt validation, security filtering, tool execution control, text-to-speech feedback, session management, and automated code quality validation. The project showcases advanced patterns including sub-agent orchestration, team-based validation workflows, custom status lines, and output styles. Built using UV single-file scripts for clean separation and fast dependency management, it serves as both a learning resource and production-ready foundation for customizing Claude Code behavior.

Key Features

Complete coverage of all 13 Claude Code hook lifecycle events with working Python implementations
UserPromptSubmit hook with prompt validation, security filtering, context injection, and audit logging
PreToolUse security blocking for dangerous commands (rm -rf, .env access) before execution
Intelligent TTS feedback system supporting ElevenLabs, OpenAI, and pyttsx3 with queue management
Team-based validation workflow with builder/validator agent pairs and task orchestration
Automated code quality enforcement via Ruff linting and type checking on PostToolUse
Nine custom status line variants displaying real-time context, tokens, costs, and session metadata
UV single-file script architecture for isolated, portable hook logic with embedded dependencies

Use Cases

  • 01Security hardening: block dangerous shell commands and prevent sensitive file access before execution
  • 02Compliance and audit: log every prompt, tool use, and session event with structured JSON output
  • 03Developer experience: add audio feedback for long-running tasks and notifications requiring user input
  • 04Code quality enforcement: automatically validate Python code with linting and type checking before accepting changes
  • 05Team workflows: orchestrate builder and validator agents with task dependencies for multi-step projects
  • 06Context enhancement: inject project-specific information (git status, recent issues) into prompts automatically

Related Plugins

View more

claude-code-hooks-mastery — FAQ

What is claude-code-hooks-mastery?+

It's a comprehensive reference implementation of all 13 Claude Code hook lifecycle events, providing production-ready hooks for security, validation, logging, TTS feedback, and team-based workflows. It serves as both educational documentation and a starter template for customizing Claude Code behavior.

How do I install and configure the hooks?+

Install UV package manager, clone the repository, and copy the `.claude/` directory into your project. Configure which hooks to enable in `.claude/settings.json` using the `$CLAUDE_PROJECT_DIR` prefix for hook script paths. Each hook is a self-contained UV script with embedded dependencies.

What are the prerequisites?+

Requires Astral UV (Python package manager) and Claude Code CLI. Optional integrations include ElevenLabs API key for premium TTS, OpenAI or Anthropic API keys for LLM-generated messages, and Ollama for local models. Most hooks work without API keys using fallback implementations.

Which Claude Code versions does this work with?+

Works with any Claude Code version supporting hooks (introduced in recent releases). The repository follows official Anthropic hook specifications and is tested with the latest Claude Code CLI.

Is this free to use?+

Yes, the repository and all hook implementations are free and open source. However, optional features like ElevenLabs TTS, OpenAI, and Anthropic API calls require paid API keys from those providers.

Can hooks block or modify Claude Code behavior?+

Yes, specific hooks can control execution flow: UserPromptSubmit can block prompts, PreToolUse can prevent tool execution, Stop can force continuation, and PostToolUse can trigger validation feedback. Exit code 2 triggers blocking behavior with stderr fed back to Claude.

How do I install claude-code-hooks-mastery?+

Open the source repository on GitHub and follow its README. claude-code-hooks-mastery is a plugin — MCP Agents Market links you directly to the official repo.

Is claude-code-hooks-mastery free?+

claude-code-hooks-mastery is an open-source project hosted on GitHub. Check the repository for its license and any usage requirements.

Related searches