CLAUDE.md rules are inconsistently enforced — rules loaded into context are ignored in practice
Resolved 💬 3 comments Opened Apr 13, 2026 by sakal-s Closed Apr 17, 2026
Summary
Rules defined in ~/.claude/CLAUDE.md (and project-level CLAUDE.md) are loaded into the model's context but not enforced — the model routinely ignores them within the same session they were read. This makes the feature effectively unreliable: users write rules expecting them to shape behavior, but there's no enforcement mechanism, so the rules function as soft suggestions at best.
Concrete example from a single session
User's CLAUDE.md includes:
Before modifying source files to support tests (e.g., adding data-testid), ask the user first with a short yes/no question.
In one session, minutes after the model confirmed it had read CLAUDE.md:
- User asked how to fix a failing test where a drag-handle SVG couldn't be located by role.
- Model proposed source-code changes (adding
aria-labelto the SVG) — without asking the required yes/no. - When the user pointed out that
data-testidwould also work, the model admitted it had "missed" mentioning it, despite the rule explicitly calling outdata-testidas the canonical example. - Even the
claims-verified: yesresponse-checklist flags (from another rule in the same CLAUDE.md) were filled in mechanically while the model had invented a nonexistent Testing Library API (getByDescription) in the same response.
In other words: rules loaded into context don't reliably constrain the output, and self-reported compliance flags are not a substitute for actual compliance.
Why users file this as a bug, not a feature request
- The documented feature "put rules in CLAUDE.md and they'll shape behavior" is effectively broken — it works sometimes and fails silently other times.
- There is no built-in mechanism (hook, sub-agent, validator) to enforce rules before each response is emitted.
- Users have no visibility into which rules were actually considered for a given response.
Suggested directions (feature-ish, but user-facing they're bug fixes)
- Pre-response validator: a lightweight hook that scans the planned response against CLAUDE.md rules and blocks/annotates non-compliant content.
- Rule-surfaced reminders: when a rule applies to an upcoming action (e.g. "proposing source changes in a test context"), surface the specific rule to the model in a system-reminder before generation, not just at session start.
- Explicit rule-acknowledgement trace: let users see which CLAUDE.md rules were evaluated as relevant to a given response, so compliance drift is visible instead of silent.
Environment
- Claude Code CLI (model:
claude-opus-4-6[1m]) - macOS / zsh
- CLAUDE.md located at
~/.claude/CLAUDE.md
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗