
Claude Code Hooks
Claude Code moves fast: editing files, running commands, pushing code in quick succession. Hooks let you intercept that flow and enforce your standards automatically. What Are Hooks? Hooks are shell commands that run at lifecycle events during a Claude Code session. They're configured in settings.json and execute outside Claude's control. The harness runs them, not the AI. This matters: Claude can't skip hooks or work around them. They're infrastructure, not suggestions. Hook Types Hook When it runs Can block? PreToolUse Before a tool executes Yes (non-zero exit) PostToolUse After a tool executes No Notification When Claude sends a notification No Stop When Claude's turn ends No SubagentStop When a subagent finishes No PreToolUse is the most powerful: it can stop a tool from running entirely. Configuration Hooks live in settings.json . Two scopes: ~/.claude/settings.json (global, applies everywhere) .claude/settings.json (project-level, merged with global) Structure: { "hooks" : { "Pre
Continue reading on Dev.to
Opens in a new tab




