claude-code - 💡(How to fix) Fix [UX] Distinguish 'Stop hook execution error' from 'Stop hook objection' when hook returns ok:false

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When a Stop hook executes successfully and returns {"ok": false, "reason": "..."}, Claude Code surfaces the message as "Stop hook error:" in the transcript. This conflates two distinct outcomes:

  1. Hook execution error — the hook script crashed, timed out, or returned malformed JSON
  2. Hook objection — the hook ran fine and reported a policy violation in the model's response

Both currently render under the same "error" label, which is misleading. Case #2 is the intended success path for a review-style hook.

Error Message

Ran 1 stop hook (ctrl+o to expand) ⎿ Stop hook error: ... : test

Root Cause

Review/verification hooks (security checks, CLAUDE.md policy enforcement, verify-after-complete patterns) are a common Stop hook use case. Their purpose is to return ok: false when they catch something. Labeling that path as "error" makes correct hook behavior look like a bug to users and conflates real script failures with policy reports — both in the UI and in any log scraping users do.

Code Example

{
  "hooks": {
    "Stop": [{
      "hooks": [{
        "type": "prompt",
        "prompt": "Respond with {\"ok\": false, \"reason\": \"test\"}",
        "model": "claude-haiku-4-5-20251001"
      }]
    }]
  }
}

---

Ran 1 stop hook (ctrl+o to expand)
Stop hook error: ... : test
RAW_BUFFERClick to expand / collapse

Summary

When a Stop hook executes successfully and returns {"ok": false, "reason": "..."}, Claude Code surfaces the message as "Stop hook error:" in the transcript. This conflates two distinct outcomes:

  1. Hook execution error — the hook script crashed, timed out, or returned malformed JSON
  2. Hook objection — the hook ran fine and reported a policy violation in the model's response

Both currently render under the same "error" label, which is misleading. Case #2 is the intended success path for a review-style hook.

Repro

Configure a Stop hook that returns {"ok": false, "reason": "..."}:

{
  "hooks": {
    "Stop": [{
      "hooks": [{
        "type": "prompt",
        "prompt": "Respond with {\"ok\": false, \"reason\": \"test\"}",
        "model": "claude-haiku-4-5-20251001"
      }]
    }]
  }
}

Trigger any assistant turn. Observe:

Ran 1 stop hook (ctrl+o to expand)
  ⎿  Stop hook error: ... : test

Expected

Two distinct labels:

  • "Stop hook error:" — execution failure (non-zero exit, timeout, malformed output)
  • "Stop hook violation:" (or "Stop hook objection") — successful run, ok: false returned

Why this matters

Review/verification hooks (security checks, CLAUDE.md policy enforcement, verify-after-complete patterns) are a common Stop hook use case. Their purpose is to return ok: false when they catch something. Labeling that path as "error" makes correct hook behavior look like a bug to users and conflates real script failures with policy reports — both in the UI and in any log scraping users do.

Environment

  • Claude Code CLI
  • macOS (Darwin 25.3.0) reported, but affects all Stop hook types (prompt and command) regardless of OS

Credit

Originally reported by @harixth at https://github.com/faizkhairi/claude-code-blueprint/issues/3 — filing upstream here because the fix belongs in the CLI, not in a downstream template repo.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING