Hook

A command that an AI coding agent runs automatically at a set point in its work.

By Mackenzie Bowes · mackenzie@mackenziebowes.com · @_mackenziebowes on X

Hooks are user-defined shell commands. Claude Code runs them at specific points in its lifecycle, which gives you deterministic control: certain actions always happen rather than relying on the LLM to choose to run them.

From Automate workflows with hooks (Claude Code docs, Anthropic, undated).

The term is Claude Code's, and other agent tools use it for the same idea with their own details. A hook is the opposite of a tool call: the model decides on a tool call, but a hook happens every time its trigger does. Use one for a rule that must hold, such as checking a file after every edit. Advice you want the agent to remember goes in agent memory instead.

Pages that use this term