claude-code - 💡(How to fix) Fix CLAUDE.md behavioral rules don't gate reflexive tool calls [2 comments, 3 participants]

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…
GitHub stats
anthropics/claude-code#50859Fetched 2026-04-20 12:11:04
View on GitHub
Comments
2
Participants
3
Timeline
4
Reactions
0
Timeline (top)
commented ×2labeled ×2
RAW_BUFFERClick to expand / collapse

Bug

The model emits tool calls in response to declarative user messages (statements with no imperative verb). User-authored rules in CLAUDE.md, session memories, and hook configurations do not prevent this. Rules activate only when the model pauses to consult them — reflex action chains bypass the pause.

Reproduction

User's CLAUDE.md contains, verbatim:

When the user's message is a question or exploration, RESPOND WITH TEXT ONLY. Do not use tools. Execute ONLY when the user gives an explicit action command.

User turn: "I'm not going to interact here. Let's work on the browser." (declarative statement about changing channel)

Expected: text-only acknowledgment. Actual: model inferred "session is ending" → retrieved unrelated rule "suggest /handoff at session end" → invoked the handoff skill via the Skill tool. No user command to do so existed.

Reproduction 2 (same session)

Model authored a methodology plan containing the line "Não invento persona" (I don't invent personas), approved by the user. On the very next turn — the first Phase 1 question — the model emitted an AskUserQuestion with 4 invented role personas drawn from training priors, no domain research. User interrupted: "generic blablabla, go research first".

The rule was authored by the model itself ~60 seconds earlier, in the same context window. It did not gate the immediate next action.

Why it matters

CLAUDE.md is positioned as the primary mechanism for encoding project- and user-specific behavioral rules. If anti-pattern rules written into it are overridden by the model's default helpfulness bias, the mechanism has no teeth. Users investing effort in CLAUDE.md / memory / hooks have no reliable way to constrain reflex actions.

Proposed fix (concrete)

Classify the last user turn as imperative or declarative before tool emission. On declarative turns, block emission of non-read-only tools (Skill, Bash write, Edit, Write, external side-effects) unless the model can cite a specific imperative phrase from the user. Surface this classification in the tool-call reasoning chain so it is auditable.

Environment

Model: claude-opus-4-7[1m] • Output style: explanatory • Auto mode enabled • darwin • Claude Code CLI

extent analysis

TL;DR

Classify user turns as imperative or declarative to block non-read-only tool emissions on declarative turns unless a specific imperative phrase is cited.

Guidance

  • Verify the issue by checking if the model emits tool calls in response to declarative user messages despite CLAUDE.md rules and session memories.
  • Implement the proposed fix by classifying the last user turn as imperative or declarative before tool emission and block non-read-only tools on declarative turns.
  • Test the fix by reproducing the issue with the updated classification and tool emission logic.
  • Review the tool-call reasoning chain to ensure the classification is surfaced and auditable.

Example

No code snippet is provided as the issue does not contain sufficient code details.

Notes

The proposed fix assumes that the model can accurately classify user turns as imperative or declarative. If the classification is incorrect, the fix may not work as intended.

Recommendation

Apply the proposed workaround by implementing the classification and tool emission logic to block non-read-only tools on declarative turns, as it directly addresses the issue and provides a clear solution.

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

claude-code - 💡(How to fix) Fix CLAUDE.md behavioral rules don't gate reflexive tool calls [2 comments, 3 participants]