Hooks System - Claude Code
Event-driven automation with 20+ lifecycle events.
Hooks are the event system that lets you run code when Claude Code does things - start sessions, call tools, finish turns, request permissions.
What it does
You wire up hooks in settings.json. Each hook binds to an event (SessionStart, PreToolUse, Stop, and dozens of others) and runs a shell command, a prompt, or a subagent. Hooks can allow, deny, modify, or observe the event. This is how you enforce policy, capture telemetry, customize behavior, and integrate Claude Code into your team's workflow.
When to use it
- Enforcing custom policies that permission rules can't express.
- Logging and telemetry for audit and observability.
- Automating recurring actions (post-edit lint, pre-commit tests).
- Integrating with external systems (Slack notifications, ticket updates).
Gotchas
- Hooks run with your permissions and touch real systems. Treat them like any automation.
- Synchronous hooks block turns until they return. Use async hooks for slow operations.
- Misconfigured hooks can wedge a session. Keep them testable and fail-open where appropriate.
Official docs: https://code.claude.com/docs/en/hooks.md
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools - delivered free every week.
Was this helpful?




