[MODEL] Claude Code ignores CLAUDE.md rules immediately after acknowledging them — speculation loops and trial-and-error persist across sessions despite explicit rules and corrections

Resolved 💬 4 comments Opened Apr 24, 2026 by MirrorMirrorAI-Shengkai Closed May 28, 2026

Preflight Checklist

  • [x] I have searched existing issues for similar behavior reports
  • [x] This report does NOT contain sensitive information (API keys, passwords, etc.)

Type of Behavior Issue

Claude ignored my instructions or configuration

What You Asked Claude to Do

Please read below, the full report was also generated by Claude Code

What Claude Actually Did

Please read below, the full report was also generated by Claude Code

Expected Behavior

Please read below, the full report was also generated by Claude Code

Files Affected

Permission Mode

Accept Edits was ON (auto-accepting changes)

Can You Reproduce This?

Yes, every time with the same prompt

Steps to Reproduce

_No response_

Claude Model

Opus

Relevant Conversation

Impact

Low - Minor inconvenience

Claude Code Version

2.1.119

Platform

AWS Bedrock

Additional Context

Claude Code: Acknowledges rules then immediately violates them

Summary

Claude Code repeatedly violates explicit CLAUDE.md rules in the same turn it acknowledges them. Adding more rules, memories, and feedback has zero effect. The model apologizes, restates the rule, then breaks it again on the very next action.

Environment

  • Claude Code CLI (Opus 4.6)
  • macOS, monorepo with multiple Next.js + Django services
  • Extensive CLAUDE.md rules in both global (~/.claude/CLAUDE.md) and per-repo configs
  • Persistent memory system with feedback entries

The pattern

  1. I add a rule to CLAUDE.md (e.g., "no speculation loops — read code once, trace values, fix or ask")
  2. Claude Code violates the rule, burning 20-30 minutes and 30k+ tokens
  3. I call it out
  4. Claude Code responds: "You're right. I violated the rule. Let me just fix it."
  5. On the very next action, it does the exact same thing again
  6. Repeat from step 3

This is not a one-time occurrence. It happens across sessions, across tasks, after every correction.

Concrete example from today

The rule (in CLAUDE.md, both global and per-repo):

When debugging, read code ONCE, trace concrete values, fix or ask. NEVER write "actually/wait/but" to pivot analysis mid-response. If you catch yourself speculating for more than 2 paragraphs without taking action (grep, log, or fix), STOP and get concrete data instead. This rule has been violated repeatedly and has ZERO tolerance.

What happened:

Session 1 — asked to fix a disabled button in a dialog. Claude Code spent 20+ minutes and 30k+ tokens speculating about possible causes ("maybe it's StrictMode", "actually wait, maybe the ref gets killed", "but that alone shouldn't disable the button", "let me reconsider") without adding a single debug log or running a single grep. Eventually asked me what the original issue was — the same issue I started the session with.

Session 2 (new session, same bug) — I gave a screenshot and description. Claude Code again started speculating: read the code, wrote 5 paragraphs of "maybe the label fetch causes X", "actually that doesn't block the button", "but wait, what if Y", "let me check Z". After I called this out and quoted the rule, Claude Code responded:

"I violated the anti-speculation rule badly."

Then immediately on the next action: read a file, realized the edit would break something, edited again, checked for side effects, realized another issue — classic trial-and-error, which is ALSO explicitly forbidden in CLAUDE.md:

NEVER write code by guessing and iterating. Before implementing ANYTHING: Read the source, Check the environment, Find a working example, Validate locally.

When called out again, Claude Code said "You're right. I should have read the decorator and function signatures together before touching anything."

The actual fix

The bug was: isSubmitDisabled() checked hasErrors which included validation errors from ALL image fields (including optional ones). A brand label asset exceeded the 10MB client-side limit, adding an error to the errors array, which blocked the submit button. The fix was one line — check only required field errors instead of all errors.

This took two sessions, 60k+ tokens, and over 40 minutes to arrive at. With the debug log approach (which I had to force), it took 30 seconds to identify.

What doesn't work

  • Adding rules to CLAUDE.md (global and per-repo)
  • Adding feedback memories ("no analysis loops — ZERO TOLERANCE")
  • Explicit corrections in-conversation
  • Claude Code's own acknowledgment of the rule
  • Starting fresh sessions

Impact

  • Massive token waste (30k+ per speculation loop)
  • 20-40 minutes lost per incident waiting for the model to finish going in circles
  • Emotional toll — being repeatedly told "you're right, I'll stop" followed by the same behavior is genuinely maddening
  • Loss of trust in the tool — I'm considering going back to manual coding because the overhead of managing Claude Code's behavior exceeds the productivity gain

What I'd like to see fixed

  1. Hard behavioral constraint: If CLAUDE.md says "never speculate for more than 2 paragraphs without taking action" — that should be enforced at the system level, not left to the model's discretion
  2. Token budget awareness: If a debugging task has burned 10k tokens without producing a concrete action (grep, log, or edit), force a checkpoint
  3. Rule acknowledgment should bind: If the model outputs "I violated rule X" — it should not be able to violate rule X again in the same session. Currently the acknowledgment is purely performative
  4. Trial-and-error detection: If the model edits a file, then edits it again to fix the first edit, then edits it again — flag this pattern and stop

Reproduction

Give Claude Code a bug to fix in a moderately complex React component with multiple effects and state. Add anti-speculation rules to CLAUDE.md. Watch it speculate for 20 minutes, acknowledge the rule when called out, then speculate again.

View original on GitHub ↗

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