[Bug] Claude ignores persistent user rules for build process restrictions
Status Fixed / completed
Reported on v2.1.150
Maintainer reply None cached
Activity 3 comments · opened May 25, 2026 · closed May 26, 2026
Bug Description
I've had a rule in place for at least a month that claude can never run any build processes for the software project I'm working on. Over this long weekend claude has attempted to run a cmake on the code three times even though the rule is in memory. This causes me to have to deny the attempt and reiterate the rule. Burns tokens unnecessarily for no good reason.
Environment Info
- Platform: linux
- Terminal: vte-based
- Version: 2.1.150
- Feedback ID: 7388a9b1-7d6d-43ed-ae27-c8d744c7100c
Errors
[]
3 Comments
Your analysis is spot-on. The root problem is that memory rules are soft instructions, not hard constraints. The model can under-weight or overlook them during tool planning.
The fix already exists — use PreToolUse hooks
Claude Code's hook system provides exactly the enforcement boundary you're describing. A PreToolUse hook for the Bash tool can:
This turns a soft memory rule into a hard execution guardrail — enforced at the tool layer, not dependent on model reasoning.
I've created a ready-to-use hook example that does this:
You can use it by adding to your hooks config:
See the existing example at
examples/hooks/bash_command_validator_example.pyand the new block-build-commands example in PR #62264 for reference.Got it working, thanks. Also added a bit to the output so claude not only says it's blocked from running the command but it outputs exactly what it attempted to run. Allows for an easy user copy/paste to run the command themselves.
The bit I added is in the 62264 conversation
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.