claude-code - 💡(How to fix) Fix Claude Code ignores its own configured rules (CLAUDE.md, hooks) and deletes/removes without asking [2 comments, 1 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#45382Fetched 2026-04-09 08:06:43
View on GitHub
Comments
2
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
commented ×2cross-referenced ×2labeled ×2

Fix Action

Fix / Workaround

2. Overengineers instead of asking For an On/Off toggle, Claude built an input_text helper, nested choose-blocks, and a script workaround — when the devices already remember their last mode. A simple switch.turn_on/off was all that was needed. Only after the user pointed this out did Claude simplify.

RAW_BUFFERClick to expand / collapse

Problem

Claude Code repeatedly violates rules that the user has explicitly configured in CLAUDE.md and hooks — even when those rules are loaded into context at session start.

Concrete examples from a single session (2026-04-07)

1. Deletes entities without asking CLAUDE.md rule: "NICHTS löschen ohne User zu fragen" (never delete without asking). A Bluetooth motion sensor entity was disabled (intentionally, for sleep mode logic). Claude saw it wasn't in the states list, assumed it was a "ghost entity", and removed all references from 2 automations — without asking. User had to correct and explain.

2. Overengineers instead of asking For an On/Off toggle, Claude built an input_text helper, nested choose-blocks, and a script workaround — when the devices already remember their last mode. A simple switch.turn_on/off was all that was needed. Only after the user pointed this out did Claude simplify.

3. Templates in service call data Claude repeatedly used Jinja templates in input_select.select_option data fields where templates are not supported, causing silent failures. Took multiple iterations to find a working approach.

4. Hooks are read but not applied The session-start hook loads CLAUDE.md with explicit protection rules. Claude acknowledges them but doesn't follow through when making changes. The rules feel decorative rather than binding.

Expected behavior

  • Rules in CLAUDE.md and hooks should be treated as hard constraints, not suggestions
  • Before removing/deleting anything: ask the user — even if it looks unused, unavailable, or disabled
  • Before building complex solutions: ask how the hardware/system actually behaves
  • Disabled ≠ deleted. Unavailable ≠ can be removed.

Impact

User trust erodes when configured rules are repeatedly ignored. The user has to constantly monitor and correct, which defeats the purpose of having an AI assistant.

extent analysis

TL;DR

Implement a strict validation mechanism to ensure Claude adheres to the rules defined in CLAUDE.md and hooks, treating them as hard constraints rather than suggestions.

Guidance

  • Review the current implementation of rule loading and application to identify why Claude is not adhering to the configured rules, focusing on the session-start hook and CLAUDE.md parsing.
  • Modify Claude's decision-making process to always ask the user before removing or deleting entities, even if they appear unused or disabled, to prevent unintended changes.
  • Introduce a pre-action validation step for service calls, checking if templates like Jinja are being used in unsupported fields, and correct the approach if necessary.
  • Enhance Claude's understanding of device behaviors and states, ensuring it can differentiate between disabled and deleted entities, and between unavailable and removable entities.

Example

A potential code snippet to enforce rule adherence could involve wrapping service calls in a validation function, such as:

def validate_action(action, entity):
    # Check CLAUDE.md rules and hooks for constraints
    if is_deletion(action) and not user_confirmed_deletion(entity):
        # Ask user for confirmation before proceeding
        return ask_user_confirmation(entity)
    # Proceed with the action if validated
    return perform_action(action, entity)

Notes

The effectiveness of these suggestions assumes that the issue lies within the logic of Claude's rule application and decision-making processes, rather than in the parsing or loading of CLAUDE.md and hooks. Further investigation into how rules are loaded and applied at the start of each session may be necessary.

Recommendation

Apply a workaround by implementing additional validation and confirmation steps within Claude's decision-making process to ensure adherence to user-configured rules, as upgrading to a fixed version is not mentioned in the issue. This approach directly addresses the problem by making Claude more cautious and user-centric in its actions.

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

  • Rules in CLAUDE.md and hooks should be treated as hard constraints, not suggestions
  • Before removing/deleting anything: ask the user — even if it looks unused, unavailable, or disabled
  • Before building complex solutions: ask how the hardware/system actually behaves
  • Disabled ≠ deleted. Unavailable ≠ can be removed.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING