← ClaudeAtlas

claude-codehooklisted

Configure, create, or troubleshoot Claude Code hooks (PreToolUse, PostToolUse, UserPromptSubmit), debug hook failures, or set up any automation within Claude Code. Examples include "I want to run tests before every file edit", "My hook isn't firing", "1 out of 2 hooks ran", or "How do I create a hook that formats JSON output with jq?"
bendrucker/claude · ★ 15 · AI & Automation · score 76
Install: claude install-skill bendrucker/claude
# Claude Code Hooks Reference for creating and configuring Claude Code hooks. When uncertain about syntax or features, use the `Agent` tool with `subagent_type='claude-code-guide'` to consult official docs. ## Hook Types | Type | Trigger | Use Cases | |------|---------|-----------| | PreToolUse | Before tool execution | Validate inputs, block operations, modify parameters | | PostToolUse | After tool completes | Check results, run linters, provide feedback | | UserPromptSubmit | When user sends message | Pre-process input, add context | | Stop | Session ends | Cleanup, save state | | SubagentStop | Subagent completes | Process results | | PreCompact | Before context compaction | Save important state | | Notification | System notification | Log events | ## Configuration Files - `~/.claude/settings.json` - User-level (global) - `.claude/settings.json` - Project-level - `.claude/settings.local.json` - Local (not committed) - Plugin hooks: `plugins/<name>/hooks/hooks.json` ## Hook Structure ```json { "hooks": { "PostToolUse": [ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "bun ./hooks/biome" } ] } ] } } ``` **Matcher Patterns**: - Simple: `"Write"`, `"Edit"` - Multiple: `"Edit|Write|MultiEdit"` - With args: `"Bash(npm:*)"`, `"Bash(osascript:*)|Bash(open:*)"` - MCP tools: `"mcp__linear__create_issue"` - Plugin MCP tools: `"mcp__plugin_<plugin>_<namespace>__<