Claude Code Basics Lesson 43 of 46
Where It Fires and What It Can Do
- You hook into moments in the loop: startup, before a tool, after, job done.
- The one before can block the move — and explain why.
- They're written in settings; /hooks shows the ones that are active.
- The most useful one to start with isn't technical: the job-done notification.
The moments you can hook into
There are quite a few; these four cover pretty much everything you'll want to do at the start.
At session startup. Before you've even typed anything. This is for putting fresh information in front of it — something that changes day to day and that would already be stale in the instructions file.
Before it uses a tool. The request has left the model but hasn't been executed yet. This is the most powerful moment, and we cover it below.
After it's used one. The change is already made: this is where you hook in automatic checks, backup copies, tidying up.
When it's done or waiting on you. The moment for notifications.
The moment that can say no
Recognize the "before it uses a tool" point? It's exactly the same point where the permission request is born: between the model asking and the tool executing.
A hook attached there doesn't just watch: it can block the move. And the elegant part is what happens next — Claude gets back the explanation for the refusal, so it doesn't try the same thing again: it changes course.
Which, if you think about it, is exactly how it would work with a person: not just "no," but "no, because that file doesn't get touched." That second piece of information is what makes it work well.
Where they're written, and how you look at them
Hooks live in settings, the same place as permissions. The /hooks command is a showcase: it shows you which events exist and what's attached where, but it's read-only — to add one you edit the file.
Or, as always in this course: you ask Claude. "Make me a hook that, after every edit to a file in this folder, makes a copy of it in the archive." It writes the configuration, you read it and approve it.
The first hook worth having
It's not the fancy one: it's the notification.
On a long job, the time you lose isn't the computer's — it's yours, spent checking every two minutes whether it's done or waiting for an answer. A hook attached to "done" or "waiting on you" gives you that time back: go do something else and it'll give you a shout.
Not very technical, not very flashy, and it's the one you'll use every single day.
What's next
Now you have three tools that look similar enough to confuse you: instructions, permission and hook. In the next lesson, the criterion for choosing which — and why it's completely fine to finish the course without having written a single one.
Did you get it?
Two minutes, no grade. Trying to answer — even getting it wrong — cements the concepts far more than rereading. Not in the mood? Skip it: the lesson still counts as complete.
At what point can a hook block a move?
It's the same point where the permission request is born: between the model asking and the tool executing. A hook attached there can say no — and explain why, so Claude changes course instead of trying the same thing again.
Where are hooks written?
They live in settings, alongside permissions. `/hooks` is a read-only showcase: it shows what's attached and where, but to add one you edit the file — or, more conveniently, you ask Claude to do it.
Why is a hook attached to "job done" useful even if it does nothing technical?
On a long job, the time you lose isn't the computer's — it's yours, spent checking whether it's done. A notification gives that time back, and it's the first hook worth having.
-
Chapter 1 Introduction
-
Chapter 2 What's Underneath
-
Chapter 3 You Choose the Engine
-
Chapter 4 First Time at the Controls
-
Chapter 5 What You Let It Touch
-
Chapter 6 What It Knows About You
-
Chapter 7 Skills
-
Chapter 8 How Many You Put to Work
-
Chapter 9 What It's Connected To
-
Chapter 10 Automating the Setup
-
Chapter 11 Wrap-Up