Hook
Hook
A command the harness runs automatically when a specific event happens
✓ Building BlocksWhat is a Hook
A hook is a command wired to a specific point in the agent's lifecycle, a tool being called, a file being edited, a session starting or ending, and it runs automatically whenever that event happens. Unlike a skill, which the model decides to reach for, a hook fires without the model choosing to invoke it. It is the harness enforcing a rule, not the agent exercising judgment.
This makes hooks the right tool for anything that must happen every time, no exceptions: blocking a commit that touches a secrets file, requiring a lock file before a write, running a linter after every edit. Because a hook is a real command with a real exit code, it can allow the action, deny it, or transform the input before the harness proceeds.
A hook is not a suggestion the model can talk itself out of. That is exactly its value and its limit: hooks are great at deterministic, always-apply rules, and bad at anything that needs judgment about context, which is what skills and the model itself are for.
The hook runs outside the model's control. Its exit code decides whether the harness proceeds, blocks, or asks the human, which is why hooks are used for rules that must never depend on the model's judgment.
Build your own agent skills, not just prompts.
We design, build, and ship the Claude Code skill libraries production teams actually run on.
Talk to AY Automate ↗