Learning Objectives
- Understand what Claude Code hooks are and when they add value
- Know four common hook types and what triggers each one
- Identify hook opportunities in your own workflow
π― What You'll Learn: What hooks are, what business problem they solve, and how to spot opportunities to use them in your work
β±οΈ Time Required: 20 minutes
π‘ Beginner clarification:
In this course, hooks refer to Claude Code automation workflows triggered by files and events, not advanced API webhook infrastructure. You won't configure any hooks yourself, that's Claude's job. Your job is to recognise when one would help.
Riley's Problem
Riley's Monday margin report skill has been running for three weeks. But she noticed something unsettling:
"Every time Claude edits one of my data files, I have no record of what changed. And once, it overwrote a file I hadn't backed up. I also realised: if something goes wrong overnight, I'd have no audit trail. In a regulated environment, that's a problem."
β Riley Harper
This is exactly the problem hooks solve.
What a Hook Looks Like in Practice
When something happens inside a Claude session, Claude can automatically react to it.
For example, every time Claude writes a file:
This automatic reaction to an event is called a hook.
Claude writes a file
β
Hook fires automatically
β
File name + timestamp logged
β
You have a full audit trail
β
Compliance team is happy
What Hooks Actually Are
Hooks are standing rules that apply to everything Claude does during a session, before or after Claude takes an action, when a task finishes, or when Claude sends you a message.
Once set up, they run without you thinking about them.
The key difference from skills and agents:
| Skills / Agents | Hooks | |
|---|---|---|
| What they do | Tell Claude what to accomplish | React automatically to what Claude does |
| Who triggers them | You ask Claude to use them | Fire automatically, no prompting needed |
| Best for | Getting work done | Logging, validation, notifications, chaining |
Four Hook Types Worth Knowing
PreToolUse, fires before Claude takes an action
Good for: checking something is safe before it happens, logging what Claude is about to do.
PostToolUse, fires after Claude takes an action
Good for: recording what changed, triggering follow-on steps, notifying you when something specific happens.
Notification, fires when Claude sends you a status message
Good for: routing Claude's updates to Slack, email, or a log file instead of just the terminal.
Stop, fires when Claude finishes responding
Good for: triggering the next step in a pipeline, sending a completion alert, archiving outputs.
These four cover the most common needs. Claude Code has more hook events (for example, one that fires before context is compacted, or when a subagent finishes). You don't need them now, ask Claude what's available when a specific need comes up.
Business Use Cases
Hooks are particularly valuable in regulated, high-accountability environments:
Audit and compliance
Every time Claude edits a file β log the file name, timestamp, and session ID. Your compliance team gets a full record of what changed and when, without anyone maintaining it manually.
Notifications
When a long-running automation finishes β send a Slack message. You find out the moment it's done, not when you remember to check.
Chaining automations
When one task finishes β automatically start the next. Riley's pipeline: report runs β validation runs β notification sends. Nobody pressed a button.
Safety checks
Before Claude touches a critical file β verify a backup exists. If not, stop and alert you first.
Exercise: Spot Your Hook Opportunities
β±οΈ Total Time: 20 minutes
This is a thinking exercise, not a technical one. Your goal is to describe what you'd want, not to build it.
Step 1: Work through these questions (10 min)
After Claude does something:
Before Claude does something:
When Claude sends you a message:
Step 2: Write your hook opportunities in plain English (10 min)
For each opportunity you identified, write one sentence. Clear enough to hand to Claude or a developer.
Riley's examples:
Yours:
π‘ To set up a hook: Take your plain-English description to Claude Code and say: "I want to add a hook that does this: [your description]. Can you add it to my settings?" Claude writes the configuration, you verify it makes sense.
β Success Criteria:
What Riley Learned
"Hooks aren't about telling Claude what to do differently, they're about what happens around Claude's actions. The audit log gave me back confidence: I can see exactly what changed, when, and whether anything went wrong. In a regulated environment, that's not a nice-to-have. It's required."
Want to Go Deeper?
This lesson covers hooks at the conceptual level, enough to use them confidently in your work.
If you want to understand the full technical implementation, shell commands, JSON configuration, environment variables, Anthropic Academy covers that ground.
Next Up
Lesson 3.2: Scheduled Automation
Hooks respond to events inside a Claude session. Scheduling handles something different: making Claude run automatically at a specific time, Monday 8am, daily at 9am, whenever you need it, without anyone pressing a button.