claude-code - 💡(How to fix) Fix PreToolUse hook "block" decisions are invisible to the user

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…
  • "ask" decisions with ANSI colors render correctly in the permission prompt (yellow text confirmed working)
  • "block" decisions produce ANSI output but it never reaches the user
  • Tested with nah 0.8.3 (main) + Claude Code 2.1.133

Error Message

When a PreToolUse hook returns permissionDecision: "block", the blocked command is silently suppressed — the user sees nothing in the TUI. The block reason (including any ANSI formatting) is only visible to the model in the tool error result. 2. Claude receives the block reason as a tool error

Root Cause

Safety guards like nah use "block" for hard-denied commands (e.g., credential exposure, obfuscated execution). Users should see when their guard catches something — both for trust in the tool and for awareness of what the model attempted.

Code Example

Hook PreToolUse:Bash blocked this command:
  az keyvault secret show --vault-name prod --name api-key
nah blocked: this hides what will run.
RAW_BUFFERClick to expand / collapse

Problem

When a PreToolUse hook returns permissionDecision: "block", the blocked command is silently suppressed — the user sees nothing in the TUI. The block reason (including any ANSI formatting) is only visible to the model in the tool error result.

This means users have no way to know that a safety guard blocked a command, what was blocked, or why.

Current behavior

  1. Hook returns {"hookSpecificOutput": {"permissionDecision": "block", "permissionDecisionReason": "\033[31mnah blocked: this hides what will run.\033[0m"}}
  2. Claude receives the block reason as a tool error
  3. User sees nothing — no prompt, no message, no indication anything happened

Expected behavior

Block decisions should be displayed to the user in the TUI, similar to how "ask" decisions show a permission prompt. For example:

Hook PreToolUse:Bash blocked this command:
  az keyvault secret show --vault-name prod --name api-key
nah blocked: this hides what will run.

ANSI escape codes in the reason should be rendered (they already work correctly in "ask" prompts).

Why this matters

Safety guards like nah use "block" for hard-denied commands (e.g., credential exposure, obfuscated execution). Users should see when their guard catches something — both for trust in the tool and for awareness of what the model attempted.

Context

  • "ask" decisions with ANSI colors render correctly in the permission prompt (yellow text confirmed working)
  • "block" decisions produce ANSI output but it never reaches the user
  • Tested with nah 0.8.3 (main) + Claude Code 2.1.133

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…

FAQ

Expected behavior

Block decisions should be displayed to the user in the TUI, similar to how "ask" decisions show a permission prompt. For example:

Hook PreToolUse:Bash blocked this command:
  az keyvault secret show --vault-name prod --name api-key
nah blocked: this hides what will run.

ANSI escape codes in the reason should be rendered (they already work correctly in "ask" prompts).

Still need to ship something?

×6

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

Back to top recommendations

TRENDING