What Are Claude Code Hooks?
Hooks are shell commands Claude Code runs automatically before or after tool calls. Automate linting, testing, notifications, and validation — not reliant on Claude remembering.
TL;DR: Claude Code automation hooks. Run shell commands before/after tool calls (lint/tests/block/notify). Configured in settings.json. Enforced at the harness level.
Event Types
PreToolUse (before tool), PostToolUse (after tool), Notification (status change), Stop (on completion).
Practical Examples
- Auto-format on write
- Run related tests after edits
- Block writes to protected files
- TypeScript type-check
- Desktop notification on completion
Hooks vs CLAUDE.md
Hooks = shell commands, 100% executed; CLAUDE.md = text instructions, best-effort compliance.