Hooks | Blog

~/blog/tag/hooks

Hooks

The difference between asking the agent and making it so. What a hook is, when it beats a prompt, and where it bites back.

What I write about here

A hook is a script the harness runs at a fixed point in the agent's loop. Before a tool call, after an edit, when a session starts, when the model tries to stop. It runs whether or not the model was paying attention, and its exit code can refuse the thing that was about to happen.

That last part is the whole reason the tag exists. Almost everything else you can put in front of an agent is advice. A CLAUDE.md file is advice. A skill is advice with better packaging. A carefully worded instruction is advice you spent longer on. All of it is weighed by the model against everything else in the context, and any of it can lose.

A hook does not get weighed. This is the cheapest correctness win available in an agent setup, and it is the one people reach for last, usually after the third time the same rule got ignored on a long session.

The posts here cover both halves. What hooks are good for: enforcing a format, blocking a path, refusing a commit, keeping a check honest when the model would rather move on. And where they bite: a Stop hook that always blocks is an infinite loop, hooks over a certain size are silently skipped on some hosts, and a hook that runs on every tool call is a tax you pay all day.

If you are working out which mechanism fits a problem, the Agentic coding guide puts hooks next to skills, subagents and slash commands. What a hook may actually stop is a permissions question.

latest
toolinghooks
6 minClaude Pro #34

Your Claude Code session has no clock

Claude Code shows no timestamps and no elapsed time, so nobody can say how long a turn actually took. Here is a plugin that adds both, and what the numbers turn out to be worth.

read →