Skip to content
BENIBIX Learn

Stop Hook

AI⌨️ Claude CodeConfiguration

Also known as Stop event, stop_hook_active

The event when Claude finishes, where a hook can make it keep going.

Think of it like

It is like a coach who says one more lap before you can sit down.

Example

Lucy's Stop hook runs the tests. If any fail, it blocks the stop and tells Claude to fix them first.

Why it matters

It turns done into done and checked. Claude cannot end a turn with red tests.

Definition

Stop is the hook event that fires when Claude finishes its answer. It does not fire if you interrupt, and an API error fires StopFailure instead. A hook here can block the stop with a reason, and Claude keeps working. A stop_hook_active flag tells the hook it already did this once, so it can avoid a loop.

Example code

json
{
  "decision": "block",
  "reason": "Tests are failing. Run npm test and fix them before you stop."
}
Send Claude back to work.
It closes each turn.

Common mistake

Blocking each time without a check on stop_hook_active. Claude can then loop until it hits the cap.

Key takeaways

  1. 1
    When Claude finishes. Not on interrupt.
  2. 2
    Block with a reason. Claude goes on.
  3. 3
    Watch for loops. stop_hook_active.

Compare