[BUG] constantly violating claude.md instructions
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?
I have claude.md state that it must read code_style.md and follow very explicit rules. I then always start sessions by saying you must follow code_style.md. Half the time it follows, the other half it doesn't, very annoying. I asked it why it doesnt follow it and this is the response:
To answer your question about enforcement:
Unfortunately there's no foolproof way currently. The model doesn't have persistent memory between sessions, so it "forgets" your style guide even when you've told it repeatedly. Here are the options that help most:
CLAUDE.md in project root - you're already doing this, it's the best option
Explicit reminders in prompts - "Follow CODE_STYLE.md exactly" at the start of requests
Correct immediately - when I violate it, tell me and I'll remember for the rest of the session
Reference specific rules - "Remember: types use inline comments, not JSDoc" is more effective than "follow the style guide"
The frustrating truth is that even with all this setup, the model sometimes reverts to default patterns (JSDoc for everything, space-aligned comments, etc.) especially when generating new code quickly. This is a known limitation.
What would help Anthropic improve this: filing feedback at https://github.com/anthropics/claude-code/issues specifically about "CODE_STYLE.md adherence" - more reports = higher priority fix.
What Should Happen?
Follow explicitly stated instructions in claude.md
Error Messages/Logs
Steps to Reproduce
Just keep telling it to write code, it will for sure violate your rules at some point.
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
claude --version 'claude' is not recognized as an internal or external command, operable program or batch file.
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗