A hook is defined in the settings file and tied to an event, such as the moment just before a tool call or the start of a session. Whenever that event comes, the hook runs, and the agent can't skip it.
The agent follows a rule written in CLAUDE.md most of the time, but not every time. That's why I write anything that must never happen into a hook or the permission settings. A hook that runs before a tool call can look at the call and block it, and the agent gets the reason back.
A hook runs commands on your machine as you, so read a hook you got from someone else before you install it. I describe the session where we write your team's rules into the repo together on Work with me.