Home→Glossary→Hook

Hook

Hook

A command the harness runs automatically when a specific event happens

✓ Building Blocks
Talk to AY Automate ↗
Event-triggeredAutomaticCan block or allowDeterministic

What 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.

What actually happens when a hook fires

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.

AY Automate

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 ↗

Key properties

✓Runs on a specific event, not on request
✓Can approve, deny, or modify the action it's watching
✓Deterministic: same event, same command, every time

Compare