Journal
Tutorials

Claude Code Keeps Making the Same Mistake? Here's Why (and the Fix)

C

Clearly Team

Engineering

5 min read
Jul 9, 2026

Claude Code Keeps Making the Same Mistake? Here's Why (and the Fix)

You corrected it. It agreed. Three turns later it does the exact same thing. Nothing's more maddening in agentic coding than an agent that won't learn. The good news: it's almost never the model being dense — it's one of two fixable things.

Why it repeats

1. The mistake is anchored in the context. Once a wrong assumption is in the conversation — a misread of your schema, a hallucinated API — it sits there and re-anchors every turn, because the whole context is re-fed to the model each time. Your correction is also in there, but it's competing with the original mistake and everything built on top of it. In a long, messy session, the noise wins.

2. The rule isn't written down anywhere permanent. If the thing it keeps getting wrong is a project convention ("always use the repository pattern", "never touch the generated files"), telling it once in chat means the rule lives only in that session's context — and gets buried or dropped on the next /compact.

The fix

For a corrected-but-repeating mistake: stop correcting and reset. Explaining a third time just adds to the poisoned pile. /clear (or a fresh session), then re-prompt with the correction baked into the opening line as a constraint, not a fix-up: "Implement X. The config loads lazily, so read it inside the handler, never at import time." A clean context that starts with the rule doesn't relive the mistake. (More: stuck in a loop.)

For a recurring convention it keeps violating: put it in CLAUDE.md. That file is re-read at the start of every session and survives /clear, so the rule is present every time instead of just the once you mentioned it. Anything you find yourself correcting more than twice belongs there. Keep it tight, though — a bloated CLAUDE.md is re-sent every turn and gets skimmed. (Why that matters for tokens →)

When it still won't stick

If a fresh, well-prompted session with the rule in CLAUDE.md still repeats the mistake, the problem probably isn't the agent — the task may be genuinely ambiguous, or two parts of your codebase contradict each other. That's a "go read it yourself for two minutes" signal, not a prompting one.

But nine times out of ten it's a poisoned context. Reset it, write the rule down, and move on — and if a session's too far gone to save, put it down and open a clean one. Running several at once? Mwah shows you which is which.


Related: Shoot your Claude Code in the head · /clear vs /compact vs kill

#claude code#agentic coding#claude.md#context management#developer workflow