◉CLAUDE LABJP
●CC 2.1.332 — No new Claude Code release over the weekend. 2.1.332 (11/25) is still current●ANALYTICS — A fix to search counts in the Enterprise Analytics API may raise numbers from 11/17 onward●SONNET 4.5 — Today, 11/30, is Sonnet 4.5's last day on the Claude API. Move to claude-sonnet-5-5●USAGE — Some users report weekly usage jumping right after upgrading to a higher plan●NEW — New: Does what a Project remembers carry over into your everyday chats?●BILLING — More readers are looking for what to check when a payment won't go through●CC 2.1.332 — No new Claude Code release over the weekend. 2.1.332 (11/25) is still current●ANALYTICS — A fix to search counts in the Enterprise Analytics API may raise numbers from 11/17 onward●SONNET 4.5 — Today, 11/30, is Sonnet 4.5's last day on the Claude API. Move to claude-sonnet-5-5●USAGE — Some users report weekly usage jumping right after upgrading to a higher plan●NEW — New: Does what a Project remembers carry over into your everyday chats?●BILLING — More readers are looking for what to check when a payment won't go through
Articles/Claude Code
⟐ Claude Code/2026-04-27Advanced

Claude Code Hooks: A Field Guide to the 8 Core Hooks — and the 33-Event Catalog They Now Live In

Claude Code hooks are powerful, but most people give up before figuring out which event does what. Here's the field guide I wish I had when I started — six months of running hooks in production, distilled.

Claude Code295Hooks10Automation44Workflow8Practical GuideAgent Design

✦ Premium Article

I spent six months running Claude Code in production before I truly understood hooks. The documentation covers what they do, but not why you'd pick one over another in a real scenario. Halfway through, I realized I'd been setting up hooks wrong the whole time: two hooks fighting each other, one never firing because I'd misconfigured the timing, another creating an infinite loop.

The frustration wasn't the hooks themselves—it was the mental model. I was treating them like simple on/off switches when they're actually a control flow system that governs the entire conversation between you, Claude Code, and your tools.

This guide is for people who got hooks working once, then broke something and gave up. Or people who want to avoid that entirely. I'll walk through every hook type, show you when to use it, and reveal the three production bugs I hit that taught me the hard way.

The Design Philosophy Behind Hooks

Claude Code hooks aren't just event listeners. They're the connective tissue between what you ask Claude to do and what actually gets executed.

Think of the traditional flow: user prompt → code generation → done. One direction, no feedback loop.

Hooks create: user ⇄ Claude Code (with hooks) ⇄ tools (git, npm, shell, API calls). Bidirectional. The hook system manages that conversation. Each hook type handles a specific phase.

The first principle: separate concerns. Don't put PostToolUse logic in PreToolUse. Don't use Stop to handle single-tool failures. Mixing them is where everything breaks.

The second: hooks are synchronous by default, but support async. If you put a Promise in a hook, Claude Code will wait. But wait too long and the session times out. The balance is tight—that's our first production trap.

The third: hooks fire in sequence, not in parallel. Misunderstanding this sequence is the most common footgun. Get this wrong and you'll spend hours debugging why a value is undefined or why a tool runs twice.

The fourth: each hook phase has a different responsibility. Don't make SessionStart do what SessionEnd should do. Don't make PreToolUse handle post-execution validation. This separation is what makes debugging possible.

The 8 Core Hooks: A Reference Map

A quick note on scope before the table. When this article was first published, these eight were the main events hooks offered. The catalog has grown a lot since — the official reference now lists 33 events as of late August 2026 — and I cover how to navigate that expansion in two later sections. The eight below are still the backbone, and everything else is easier to place once you know them.

HookFiresResponsibilityCommon Use
SessionStartImmediately after session beginsInitialize environmentSet up dependencies, env files, initial checks
UserPromptSubmitWhen user sends a message (before processing)Pre-filter and enrich inputDetect code, validate syntax, security checks
PreToolUseRight before a tool executesValidate preconditionsSecurity gates, permission checks, state validation
PostToolUseRight after a tool executesVerify resultsConfirm success, handle errors, log outcomes
NotificationWhen Claude Code itself raises a notificationRelay waiting statesForward permission prompts and idle prompts off-screen
StopRight before Claude ends its turnWithhold the endingRefuse to stop while work is unfinished
SubagentStopRight before a subagent endsWithhold the subagent's endingSend a subagent back for work it skipped
SessionEndBefore session closesFinal cleanupGenerate reports, archive logs, notifications

This table is deceptive because it makes them look independent. They're not. Understanding the firing sequence is the foundation of hooks that actually work.

One note about the JSON in this guide. Three sections — PreToolUse vs PostToolUse, UserPromptSubmit, and the SessionStart/SessionEnd pair — use a conceptual pseudo-schema to make each hook's responsibility obvious; those blocks won't run as written. Everything from Stop/SubagentStop onward is real: the notification hook, model switching, the three traps, the templates, the config section, and the exit-code section all show configs and scripts running on my machine. If you want something you can paste and run, skip ahead.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦The real hooks config format in settings.json — matcher, command, the stdin JSON contract, and exit code 2 to block — not the conceptual pseudo-schema
✦A map of the hook catalog as of August 2026 — 33 events — plus working PreModelSwitch / PostModelSwitch configs (v2.1.251) that turn model switches into enforceable policy
✦Measured per-tool overhead that hooks add, and the latency budget that keeps them from getting in the way
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⟐ Claude Code2026-11-26
Per Callback, or Once at the Door? Deciding What Claude Code Should Touch on the Day I Installed an Ads SDK Migration Skill
Android's ads SDK is changing generations, and every callback will now arrive on a background thread. The official migration skill says to switch to the UI thread inside each callback; I chose to switch once, at the entrance of my ad wrapper layer. Three tools — an inventory scanner, an entrance-level normalizer, and a PreToolUse hook that fences Claude Code's edits on the migration branch — and the reasoning behind the choice.
⟐ Claude Code2026-11-21
When Every New Desktop Session Creates a Worktree: Three Places to Check, and When It's Fine to Turn It Off
Claude Code Desktop keeps creating a worktree for every new session, and .claude/worktrees/ and claude/ branches pile up. Here is where the Worktree default actually gets turned on, when to keep it and when to skip it, and a SessionStart hook that tells you when a session is running inside a worktree.
⟐ Claude Code2026-10-29
When Claude Overwrites a Huge CLAUDE.md: Find the Missing Headings, Restore Them, and Block the Next One
Claude Code 2.1.312 fixed a bug where Claude overwrote a very large CLAUDE.md after seeing only its start. Here is how to spot lost headings on older versions, restore with git, and block full rewrites with a Write hook.