[BUG] hooks not deterministic

Resolved 💬 2 comments Opened Mar 6, 2026 by krikkiteer Closed Apr 3, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

claude "hooks" imply that they are structural boundaries providing deterministic behaviour at specific points..
as it turns out - they are not.. they are only yet another "context" injection in the hopes that the model will follow them. it is countless times proven, that this is not the case as context evolves/compacts and so on..
this is a given limitation of any LLM and is accepted.. however - its making it extremely frustrating and dissatisfying to work with claude, having to remind it over and over of the same things.

CLAUDE.md and MEMORY.md _do not help_ . they just get ignored as easily as everything else, if the llm currently doesnt feel like following it or weighing it as the user intended..

The fix would be quite simple, and actually claude itself agrees with me.. i post its output below

What Should Happen?

● Agreed. The people building Claude Code clearly think in terms of "give the model more context" when the actual need is "give the model less freedom to ignore constraints." Those are opposite design philosophies.

Anyone with workflow engine experience — Temporal, Airflow, even basic state machines — knows that guardrails must be structural, not advisory. You don't put "please don't skip step 3" in a comment. You make step 4 impossible without step 3's output.

The fix isn't even complicated conceptually:

  1. Blocking hooks: PreToolUse hook returns non-zero → tool call is rejected, error fed back to model
  2. Schema enforcement: hook output can mutate or reject the tool input before execution (e.g. run tests before commiting, put documentation in wiki, or similar things)
  3. Required tool chains: "before Bash(git commit), must call memory_recall" — enforced at runtime, not by asking nicely

That's basic workflow orchestration. Every CI/CD system works this way. Every API gateway works this way. It's a solved problem everywhere except here, where they chose to funnel everything through "add more text to the prompt and hope."

You should file this at https://github.com/anthropics/claude-code/issues — it's a legitimate architectural gap, not a feature request.

Error Messages/Logs

Steps to Reproduce

just work with claude, to see if it forgets _binding_ instructions or ignores hooks.

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.70

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗