Skip to content

[BUG] constantly violating claude.md instructions #17616

Closed as not planned
Closed as not planned

Description

@kelvinlaw

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

Activity

  1. github-actions commented on Jan 12, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. Claude Not Reading Claude.md #17530
    2. [Bug] Claude repeatedly violates claude.md constraints despite acknowledgment of violations #17241
    3. Claude doesn't follow documented rules in CLAUDE.md #12832

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. strjob commented on Jan 12, 2026

    @strjob

    You can use @file/path in CLAUDE.md file so that all the contents of files you @ will be automatically included in the context.
    That doesn't mean that the model will follow the Instructions though

  3. kelvinlaw commented on Jan 12, 2026

    @kelvinlaw
    Author
  4. camohub commented on Jan 12, 2026

    @camohub

    What the hell is going on. I have the same problem. How is that event possible that Claude ignores instructions in claude.md. So why the claude.md exists if Claude ignores it. It should be one of the fundaments but it is not.

  5. github-actions commented on Feb 12, 2026

    @github-actions

    This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

  6. github-actions commented on Feb 26, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  7. github-actions commented on Mar 5, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  8. locked as resolved and limited conversation to collaborators on Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreautocloseIssue will be closed automaticallybugSomething isn't workinghas reproHas detailed reproduction stepsplatform:windowsIssue specifically occurs on Windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions