← 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 · ★ 16 · 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 | | PermissionRequest | Permission dialog appears | Return a decision, notify a remote approver | | Stop | Agent finishes a turn | Cleanup, save state | | StopFailure | Agent stops on failure | Report the failure | | SubagentStart / SubagentStop | Subagent spawns / completes | Process results | | SessionStart / SessionEnd | Session begins / ends | Inject context, export state | | PreCompact / PostCompact | Around context compaction | Save important state | | Notification | System notification | Log events | | TeammateIdle | Teammate about to go idle | Hand off work | ## 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": "co