What problem does it solve?
Claude Code hooks automate repetitive tasks, enforce policies, and inject context without modifying core code. This Skill helps you leverage these powerful event-driven automations to streamline your workflow, ensure safety, and customize Claude's behavior, allowing you to focus on higher-value tasks.
Core Features & Use Cases
- Event-Driven Automation: Execute shell commands or LLM prompts in response to specific events like tool use, session start/end, or user prompts.
- Command Validation & Safety: Implement pre-execution checks to block destructive commands (e.g.,
rm -rf), validate user input, or ensure code quality (e.g., auto-format after edits).
- Workflow Customization: Inject session-specific context, trigger desktop notifications for user input, or define custom completion criteria for Claude's operations.
- Use Case: Automatically log all
Bash commands executed by Claude to an audit file, or block git push --force to protect your main branch from accidental overwrites.
Quick Start
- Create a
.claude/hooks.json file in your project.
- Add a
PreToolUse hook with a Bash matcher.
- Configure a
command hook to log jq -r '.tool_input.command' >> ~/.claude/bash-log.txt.
- Test with
claude --debug.