What problem does it solve?
Hooks are event-driven automation for Claude Code that execute shell commands or LLM prompts in response to tool usage, session events, and user interactions. This Skill teaches you how to create, configure, and debug hooks for validating commands, automating workflows, injecting context, and implementing custom completion criteria.
Hooks provide programmatic control over Claude's behavior without modifying core code, enabling project-specific automation, safety checks, and workflow customization.
Core Features & Use Cases
- Hooks events: PreToolUse, PostToolUse, UserPromptSubmit, Stop, SessionStart, etc.
- Create and manage hooks config: .claude/hooks.json
- Logging and observability of Claude actions
- Block destructive commands and inject context
- Automate workflows and notifications
Quick Start
- Create hooks config file:
- Project:
.claude/hooks.json
- User:
~/.claude/hooks.json
- Choose hook event (when it fires)
- Choose hook type (command or prompt)
- Configure matcher
- Test with
claude --debug