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:

  1. User asked how to fix a failing test where a drag-handle SVG couldn't be located by role.
  2. Model proposed source-code changes (adding aria-label to the SVG) — without asking the required yes/no.
  3. When the user pointed out that data-testid would also work, the model admitted it had "missed" mentioning it, despite the rule explicitly calling out data-testid as the canonical example.
  4. Even the claims-verified: yes response-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)

  1. Pre-response validator: a lightweight hook that scans the planned response against CLAUDE.md rules and blocks/annotates non-compliant content.
  2. 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.
  3. 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

View original on GitHub ↗

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