Create and configure Claude Code hooks for customizing agent behavior. Use when the user wants to (1) create a new hook, (2) configure automatic formatting, logging, or notifications, (3) add file protection or custom permissions, (4) set up pre/post tool execution actions, or (5) asks about hook events like PreToolUse, PostToolUse, Notification, etc.
Inherits all available tools
Additional assets for this skill
This skill inherits all available tools. When active, it can use any tool Claude has access to.
references/examples.mdreferences/hook-events.mdCreate Claude Code hooks that execute shell commands at specific lifecycle events.
* for all, or specific tool names like Bash, Edit|Write)~/.claude/settings.json) or project (.claude/settings.json){
"hooks": {
"<EventName>": [
{
"matcher": "<ToolPattern>",
"hooks": [
{
"type": "command",
"command": "<shell-command>"
}
]
}
]
}
}
Hooks receive JSON via stdin. Use jq to extract fields:
# Extract tool input field
jq -r '.tool_input.file_path'
# Extract with fallback
jq -r '.tool_input.description // "No description"'
# Conditional processing
jq -r 'if .tool_input.file_path then .tool_input.file_path else empty end'
0 - Allow the tool to proceed2 - Block the tool and provide feedback to Claude* - Match all toolsBash - Match only Bash toolEdit|Write - Match Edit or Write toolsRead - Match Read toolLog all bash commands:
jq -r '"\(.tool_input.command)"' >> ~/.claude/bash-log.txt
Auto-format TypeScript after edit:
jq -r '.tool_input.file_path' | { read f; [[ "$f" == *.ts ]] && npx prettier --write "$f"; }
Block edits to .env files:
python3 -c "import json,sys; p=json.load(sys.stdin).get('tool_input',{}).get('file_path',''); sys.exit(2 if '.env' in p else 0)"
references/hook-events.md for detailed event documentation with input/output schemasreferences/examples.md for complete, tested hook configurations