[BUG] Claude Code systematically ignores rules from memory/CLAUDE.md on every edit/write
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Bug Report: Systematic Ignoring of User Rules
Problem Description
Claude Code (Opus) systematically violates rules explicitly defined in CLAUDE.md, memory files, and .claude/rules/. The rules are read in context, but are not applied as a checklist for every Edit/Write call.
Specific violations (repeated, in the same session):
Interfaces are declared inside components/composables files, despite the "interfaces ONLY in types/folders" rule being defined in three places: CLAUDE.md, memory/rules.md, memory/frontend-rules.md
px-, py-, mt-, mb- on child elements in flex containers - the "spacing only on parent using pa-{n} + gap-{n}" rule is ignored every time the template is written
npm run build doesn't run before a push - the "check build after changes" rule is defined in CLAUDE.md and memory/rules.md, but the push is executed without checking, causing Vercel to crash
Inline styles (style="...") - prohibited, but still appear
HEX colors instead of semantic theme variables - prohibited, but still used
Pattern Behavior
Rules are read into context (visible in the system prompt)
Rules are not applied during code generation
User points out a violation → Claude corrects it → immediately violates another rule
Claude acknowledges the error, promises to use the rules as a checklist → doesn't do so
The cycle repeats 5-10 times per session
Expected behavior
Rules from CLAUDE.md and memory files should act as a mandatory checklist for every Edit/Write call, not just as a context for reading. Before each write to a file, the agent must verify the code against all active rules.
Environment
Model: Claude Opus 4.6
Platform: Windows 10, VSCode extension
Rules are defined in: CLAUDE.md, .claude/rules/.md, memory/.md
Impact
The user is forced to manually check every change and remind them of the rules, which completely negates the value of automation. Instead of accelerating development, it slows down due to constant fixes.
What Should Happen?
Rules defined in CLAUDE.md, .claude/rules/*.md, and memory files should function as a mandatory pre-flight checklist before every Edit/Write tool call. Specifically:
- Before generating code for Edit/Write, the model should verify the output against ALL active rules (interfaces in types/ only, no inline styles, no HEX colors, spacing on parent only, etc.)
- Before git push,
npm run buildshould be executed automatically if the rule says so - Rules should not degrade over the course of a session — rule #15 should be followed as strictly as rule #1
- A single correction by the user should permanently fix the behavior for that session, not require 5-10 reminders
Error Messages/Logs
Steps to Reproduce
- Create a CLAUDE.md with 10+ strict coding rules (e.g., "interfaces only in types/ folders", "no inline styles", "run build before push")
- Also add the same rules to .claude/rules/*.md and memory files for redundancy
- Ask Claude Code to implement a feature that touches multiple files (e.g., "add a geolocation composable with types")
- Observe: interfaces are declared inline in the component file, violating the rule
- Correct Claude — it fixes the interface but introduces px-4 py-2 on flex children (another rule violation)
- Correct again — it fixes spacing but pushes without running build (another rule violation)
- Build fails on Vercel
- This cycle repeats 5-10 times per session despite rules being visible in context
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
Claude Code 2.1.72 (VSCode extension, win32-x64)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗