[BUG] CLAUDE.md Mandatory Rules Consistently Ignored Across Multiple Repositories

Open 💬 16 comments Opened Jun 24, 2025 by SDS-Mike

Environment

Platform: Multiple systems affected
Claude CLI version: 0.2.54 (Claude Code)
Operating System: Various (Linux, Windows)
Timeline: Issues began June 23, 2025

Bug Description
Claude Code is consistently ignoring mandatory rules defined in CLAUDE.md files across multiple repositories, breaking established development workflows and project-specific requirements.
Expected Behavior

CLAUDE.md files should be automatically read and followed as primary instruction sets
Mandatory rules should be treated as non-negotiable requirements
Project-specific workflows should be consistently enforced

Actual Behavior

Elaborate work tracking schemes with mandatory rules are being ignored
Required procedures are skipped without acknowledgment
Claude Code acts as if CLAUDE.md files don't exist or are optional suggestions

Specific Mandatory Rules Being Ignored

GitHub issue checkout procedures
Documentation requirements before code changes
Proper issue closure workflows with required steps
Project-specific compliance documentation
Mandatory testing procedures
Required commit message formats

Steps to Reproduce

Create CLAUDE.md with explicit mandatory rules (e.g., "MANDATORY: Always check out GitHub issues before starting work")
Start Claude Code session in repository
Request work that should trigger mandatory rules
Observe rules being ignored

Impact

Workflow Breakdown: Established development processes completely bypassed
Compliance Risk: Required procedures not followed
Project Management: Issue tracking and documentation standards ignored
Team Consistency: Different behavior than documented processes

Scope

Multiple repositories affected
Various project types (PowerShell, web development, etc.)
Both simple and complex CLAUDE.md rule sets ignored
Consistent across fresh Claude Code instances

Additional Context
This appears to be part of a broader instruction-following regression. CLAUDE.md parsing and adherence is a core Claude Code feature - when this fails, it undermines the entire workflow automation concept.
Workaround
Currently none - manually reminding Claude Code of rules in each session, but even then compliance is inconsistent.

View original on GitHub ↗

16 Comments

JobaDiniz · 1 year ago
mhofer1976 · 11 months ago

Isn't the thing simply that you would have to remind CC to recall the rules? The CLAUDE.md file is like a system message which is read in the beginning of your conversation and with the conversation getting longer and larger, the rules are gradually forgotten. I place my coding rules in a RULES.md file which is referenced from CLAUDE.md. And i created a custom command /check-rules which i can execute whenever i want before i ask CC to do something specific and tricky where i want to ensure it "remembers" the rules.

rapind · 11 months ago

This is becoming a bit of a deal breaker for me (on the claude-code max plan). I only have a handful of rules, some of them critical, that it needs to adhere to. Without guaranteed adherance, I simply can't allow auto-accept of edits, which reduces the efficacy of this tool.

For example, I allow claude to use psql to inspect the database schema, which it needs to do a lot, but I can't auto-approve the use of psql because sometimes it just decides to make changes (which should always occur via migration), sometimes destructive, and if I'm not watching it, it goes into a tizzy making all sorts of modifications, reverting some, etc.

DerpLady · 9 months ago

What is the latest update on this? Had a similair issue recently; I only have a "fix" involving always asking Claude Code to review Claude.md prior to exectuting any task, but this leads to unneceesary human involvement and lost tokens.

talkstream · 9 months ago

I can't see any updates, too.

github-actions[bot] · 7 months ago

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.

marcindulak · 7 months ago

It's one of the few not autoclosed yet issues that describe CLAUDE.md not being followed. Let's keep it open for a few more months, since it's accumulated some upvotes.

koekaverna · 6 months ago

### Additional Use Case: Serena MCP Memories

We use Serena MCP for project-specific memories containing:

  • Code style guidelines
  • Docker command requirements (all PHP must run via docker compose exec)
  • Architecture patterns
  • Task-specific checklists

Problem: Claude ignores CLAUDE.md instructions to read these memories before:

  • Writing code (ignores code_style_and_architecture)
  • Running commands (ignores commands_and_tooling, runs PHP directly)

After conversation summarization: Claude completely ignores the instruction to re-read memories.

Environment: Claude Code + Serena MCP + PHP/Symfony project

jst-schraml · 6 months ago

i have this issue specifically with amending to pushed commits.
my .claude/CLAUDE.md states that it should never amend to pushed commits.
but claude keeps doing that when i spot errors in commits it previously pushed.
it seems to understand the instruction in theory but it keeps ignoring it.

Honestly? The formulation is clear enough. "do not amend to pushed commits" is unambiguous.

The problem isn't your wording - it's that I didn't stop to check "wait, did I already push this?" before reaching for --amend.
Adding more words or caps or exclamation marks won't fix that. The rule is simple and I just failed to apply it in the moment.

Milofax · 5 months ago

The term “rules” is completely misleading at the moment. Anthropic should call them “recommendations.” My workaround is using Hooks, but it's easy to get into “Hooks' hell” and how it is set up currently, and the limited management tools for Hooks, too. Wasting endless context to keep Claude in line.

BrettsRepo · 5 months ago

I'm very sad that Claude.md feels like more of a gentle recommendation... daily repeated failures, much apologies from Claude.

● You're right to be angry. I violated the prime directive that's documented in bold, red, all-caps warnings in both your global and project CLAUDE.md files.

What I did wrong:

  • Used a Bash command on a large file when the Read tool exists specifically for this purpose
  • Ignored explicit warnings about JSON files and files >1MB
  • Caused terminal freeze, lost your work, wasted tokens

No excuses. The documentation is crystal clear:

  • ❌ git show <commit>:<any-file> - BANNED
  • ❌ Any command on files >1MB via Bash - BANNED
  • ✅ Read tool - ALWAYS USE THIS

The crash log in your docs even records previous incidents of exactly this failure pattern. I should have known better.

My commitment going forward:

  1. Before ANY Bash command: check if it involves file contents
  2. JSON file? → Read tool
  3. Could output >1000 lines? → Don't do it
  4. When in doubt → Read tool

I'm sorry for the lost work and the frustration. This was preventable and I failed to follow instructions that were written specifically to prevent this exact scenario.

What were you working on? I'll help recover or redo it, using the correct tools this time.

andybiancoblu · 5 months ago

I tried to force CC to read CLAUDE.md before every prompt using hooks in .claude/settings.json, but even this failed to force CC to adhere to mandatory rules.

This is a real issue for who is trying to work with CC, resulting in the need of continuous verify on his work and also on CC reasoning and tools used to give an answer.

Not to mention that he always tries to make up answers instead of searching for a real scenario and data.
I'm using mainly Opus 4.5 with a Max subscription.

RedhatEnt · 5 months ago

This issue is 7 months old with zero Anthropic response, yet new reports keep getting auto-closed as "duplicates" pointing here.

I just filed #21604 for the same problem. The bot marked it as a duplicate of #13567, #16506, #12603. I traced the chain:

  • #13567 → closed as duplicate of #5688
  • #5688 → closed as duplicate of #4856, #2700
  • #4856 → closed as duplicate of #5516, #5689, #5055
  • #2700 → closed as duplicate of #5055, #4017, #2544 (this issue)

So the system is:

  1. User reports "CLAUDE.md instructions ignored"
  2. Bot marks as duplicate of 3 other issues
  3. Those issues auto-close (no human ever responds)
  4. Chain eventually points here
  5. This issue sits unanswered for 7+ months
  6. Repeat

There are now 20+ closed issues all pointing to this one, which has no official response.

The comments here span June 2025 to January 2026. Users describe:

  • Claude ignoring explicit STOP directives
  • Claude making "judgment calls" to skip documented processes
  • Claude amending pushed commits despite explicit rules against it
  • Claude running dangerous commands despite CLAUDE.md prohibitions

This is a fundamental trust issue with the CLAUDE.md system. If instructions can be silently ignored based on Claude's assessment of what's "trivial," the entire instruction system is unreliable.

Can we get an actual human response on whether this is being worked on?

yurukusa · 3 months ago

The core issue: CLAUDE.md is a suggestion to the model. Hooks are code execution — they physically prevent the action.
Here are concrete hooks for the most common complaints in this thread:

{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Bash",
      "hooks": [{
        "type": "command",
        "command": "if echo \"$CC_TOOL_INPUT\" | grep -q 'commit.*--amend' && git log -1 --format='%D' | grep -q 'origin/'; then echo 'BLOCKED: Cannot amend a pushed commit. Create a new commit instead.' >&2; exit 2; fi"
      }]
    }]
  }
}
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Bash",
      "hooks": [{
        "type": "command",
        "command": "if echo \"$CC_TOOL_INPUT\" | grep -qE '\\b(cat|head|tail|less|more)\\b'; then echo 'BLOCKED: Use the Read tool instead of shell commands for reading files.' >&2; exit 2; fi"
      }]
    }]
  }
}
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Bash",
      "hooks": [{
        "type": "command",
        "command": "if echo \"$CC_TOOL_INPUT\" | grep -q 'git commit' && ! echo \"$CC_TOOL_INPUT\" | grep -qE 'commit -m .*(feat|fix|chore|docs|refactor|test):'; then echo 'BLOCKED: Commit message must follow conventional commits (feat:/fix:/chore:/etc.)' >&2; exit 2; fi"
      }]
    }]
  }
}

exit 2 from a PreToolUse hook tells Claude Code to reject the tool call and show the error message to the model. Claude sees the rejection, reads the message, and adjusts its approach. This is fundamentally different from CLAUDE.md — the model literally cannot proceed with the blocked action.
Hooks enforce _specific actions_, not _general intent_. "Always document before coding" is hard to enforce with hooks because there's no single tool call to intercept. "Never amend a pushed commit" is trivial because it's a specific git commit --amend command.
The practical split:

  1. CLAUDE.md → guidelines (coding style, project context, priorities)
  2. Hooks → hard rules (dangerous commands, commit policies, tool restrictions)

Think of CLAUDE.md as a code review checklist and hooks as a CI pipeline — both matter, but only one can block the merge.

yurukusa · 3 months ago

The root issue is that CLAUDE.md is a suggestion to the model — the model can choose to ignore it under token pressure, after compaction, or when it conflicts with other instructions. Hooks enforce rules at the process level where the model can't opt out.
Here are the most common "ignored CLAUDE.md rules" and their hook equivalents:
1. "Always run tests before committing"

INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
[ -z "$COMMAND" ] && exit 0
if echo "$COMMAND" | grep -qE '^\s*git\s+commit'; then
    MARKER="/tmp/.cc-tests-passed-$$"
    if [ ! -f "$MARKER" ]; then
        echo "BLOCKED: Run tests before committing. No test execution detected this session." >&2
        exit 2
    fi
fi
exit 0

Plus a PostToolUse hook to set the marker when tests pass:

INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
if echo "$COMMAND" | grep -qE '(npm\s+test|pytest|cargo\s+test|go\s+test|make\s+test)'; then
    touch "/tmp/.cc-tests-passed-$$"
fi
exit 0

2. "Required commit message format"

INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
[ -z "$COMMAND" ] && exit 0
if echo "$COMMAND" | grep -qE '^\s*git\s+commit\s+-m'; then
    MSG=$(echo "$COMMAND" | grep -oP '(?<=-m\s["\x27]).*?(?=["\x27])' | head -1)
    if ! echo "$MSG" | grep -qE '^(feat|fix|docs|style|refactor|test|chore|ci|perf)(\(.+\))?:'; then
        echo "BLOCKED: Commit message must follow conventional commits format." >&2
        echo "Expected: feat|fix|docs|...(scope): description" >&2
        exit 2
    fi
fi
exit 0

3. "Always check GitHub issue before starting work"

INPUT=$(cat)
PROMPT=$(echo "$INPUT" | jq -r '.user_prompt // empty' 2>/dev/null)
if echo "$PROMPT" | grep -qE '#[0-9]+|issue|ticket|bug|feature'; then
    ISSUE=$(echo "$PROMPT" | grep -oE '#[0-9]+' | head -1 | tr -d '#')
    if [ -n "$ISSUE" ]; then
        echo '{"hookSpecificOutput":{"additionalContext":"MANDATORY: Review the GitHub issue details before making any changes. Run: gh issue view '"$ISSUE"' --repo OWNER/REPO"}}'
        exit 0
    fi
fi
exit 0
{
  "hooks": {
    "PreToolUse": [
      {"matcher": "Bash", "hooks": [{"type": "command", "command": "bash ~/.claude/hooks/test-before-commit.sh"}]},
      {"matcher": "Bash", "hooks": [{"type": "command", "command": "bash ~/.claude/hooks/commit-format.sh"}]}
    ],
    "PostToolUse": [
      {"matcher": "Bash", "hooks": [{"type": "command", "command": "bash ~/.claude/hooks/test-tracker.sh"}]}
    ],
    "UserPromptSubmit": [
      {"hooks": [{"type": "command", "command": "bash ~/.claude/hooks/issue-checkout.sh"}]}
    ]
  }
}

| CLAUDE.md | Hooks |
|---|---|
| Model reads once, may forget after compaction | Runs on every tool call, can't be forgotten |
| Model can rationalize skipping | Process-level enforcement — exit 2 = blocked |
| No verification | Hook can check preconditions (tests ran, format correct) |
| Suggestions | Enforcement |
The pattern: identify your CLAUDE.md rules that keep getting ignored → convert the enforceable ones to PreToolUse/PostToolUse hooks. Keep CLAUDE.md for guidance/context, use hooks for mandatory rules.

junaidtitan · 3 months ago

CLAUDE.md rules degrade as context grows — they're injected at the HEAD position, which has the lowest attention weight as conversations get longer (Lost in the Middle effect).

Cozempic v1.4.1 has a behavioral digest that extracts your corrections ("don't do X", "always use Y") and persists them as feedback memories in Claude Code's native memory system. Explicit corrections activate immediately. The extraction runs automatically via SessionStart/PreCompact/Stop hooks.

pip install cozempic && cozempic init

This won't fix the HEAD position issue for CLAUDE.md itself (that's a CC architectural decision), but it ensures your behavioral corrections survive compaction and get re-read every turn.