Skip to content
BENIBIX Learn

Agent Hook

AI⌨️ Claude CodeConfiguration

Also known as type: agent

A hook that sends a helper to look at files. Then it answers.

Think of it like

It is like you send a helper to go and look. Then they say yes or no.

Example

Emma wants Claude to stop only when every new file has a test. Her agent hook looks through the folder before it says yes.

Why it matters

A prompt hook only sees the event. An agent hook can open files and check.

Definition

An agent hook is a hook whose type is agent, so it starts a subagent that can use tools such as Read, Grep and Glob to check something. After up to 50 turns it returns ok true or ok false with a reason. It suits checks that need to look at files, not just the event. Agent hooks are still experimental, and the default timeout is 60 seconds.

Example code

json
{
  "type": "agent",
  "prompt": "Check that every changed file has a matching test file."
}
Let a helper look before Claude stops.

Common mistake

Using it on an event that fires a lot. Each run can take many turns and many tokens.

Key takeaways

  1. 1
    Starts a helper. With tools.
  2. 2
    Up to 50 turns. Then ok or not.
  3. 3
    Experimental. May change.

Compare