Skip to content
BENIBIX Learn

Hook JSON Output

AI⌨️ Claude CodeConfiguration

Also known as hookSpecificOutput, decision block, continue false

A JSON reply from a hook. It can say more than an exit code.

Think of it like

It is like you fill in a form. You do not just say yes or no.

Example

Jack's hook printed a JSON answer, but nothing happened. His shell profile echoed a line first. He silences it, and the JSON works.

Why it matters

Exit codes can only block or pass. JSON can allow, ask, add context or change input.

Definition

Hook JSON output is a JSON object a hook prints to stdout, with exit 0, to give a richer answer than an exit code. Some fields work on every event, such as continue set to false to stop Claude. Some events read decision and reason. PreToolUse and a few others use a hookSpecificOutput object. The JSON must be the only thing printed.

Example code

json
{
  "continue": false,
  "stopReason": "Build failed. Fix the errors before you go on."
}
Stop Claude, and say why.

Common mistake

Printing other text along with the JSON. Then it is read as plain text, not as JSON.

Key takeaways

  1. 1
    Exit 0 and print. One object.
  2. 2
    Shared and event fields. continue, decision.
  3. 3
    Nothing else on stdout. Or it is text.