claude-code - 💡(How to fix) Fix Feature request: hooks that can enforce/block assistant text responses (not just tool calls)

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…
RAW_BUFFERClick to expand / collapse

Problem

UserPromptSubmit hooks can inject advisory context into every turn, but they cannot enforce compliance — the assistant can (and does) ignore the injected instructions. PreToolUse hooks can block tool calls, but there is no equivalent mechanism for free-text assistant responses.

Use case

I use a UserPromptSubmit hook to inject a language rule ("respond in English by default"). Despite the rule appearing in context on every single turn, the assistant routinely ignores it — sometimes for entire multi-paragraph responses. This requires manual correction ~10 times/day.

The same gap applies to any behavioral rule: style constraints, process compliance, output format requirements. If the rule only applies to free-text output (not tool calls), there is currently no hook that can enforce it.

Current hook architecture

HookCan block?Scope
UserPromptSubmitNo — advisory onlyInjects context before assistant responds
PreToolUseYes — can reject tool callsTool calls only
PostToolUseNo — runs afterTool calls only
SessionStartNo — advisory onlySession init

Free-text assistant responses have no blocking hook at any stage.

Proposal

Add a hook event that can validate and reject/retry assistant responses:

  • PreAssistantResponse — fires after the assistant generates a response but before it's shown to the user. Hook can inspect the text and return block with a reason, causing a retry with the rejection feedback in context.
  • Or PostAssistantResponse — fires after display, flags violations for the next turn (weaker but simpler).

Either would close the enforcement gap for output-level rules that currently rely on the assistant choosing to comply.

Environment

  • Claude Code CLI (macOS)
  • Model: claude-opus-4-6
  • Hook config: UserPromptSubmit in ~/.claude/settings.json

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