When it keeps trying the same fix: how to break a stuck session
I build Settl, an expense-splitting app, solo with Claude, and I once watched it patch the same duplicate expense four times, each patch a slightly different filter in the same render code. The cause was upstream. Saying "that didn't work" is what kept it there.
Why a failed attempt makes the next one worse
The model does not remember the last turn. It re-reads the whole conversation from the top, every turn, and predicts the most likely continuation. Nothing in a transcript is marked false.
So look at the page after attempt one: a confident paragraph on why a null guard is the right fix, the diff that applied it, and your four-word correction. Attempt two adds a second paragraph on the same theory, because that is what the surrounding text makes likely. By attempt four there are three arguments for the wrong layer and one line from you saying no. You are not persuading a mind, you are competing for space in a document.
"That didn't work" is also not evidence. It says the outcome was wrong and nothing about which step of the reasoning was, so the cheapest available edit is to keep the theory and vary the detail.
The signs you are in the loop
- Same shape, different spelling. Three diffs on one function: a guard, a check, a fallback.
- The apology grows and the diff shrinks. Longer preamble, smaller change.
- It patches where the symptom shows, not where the value is produced: a view-layer filter for a maths bug.
- It asks you to rerun the same command, suggests clearing a cache, or blames the environment.
- You have typed "no" more than twice. Two corrections is a conversation, four is a rut.
Once two are true, more turns are the expensive option.
Harvest the facts before you kill the session
Do not close the window yet. The session holds real observations tangled up with the wrong theory, and those cost you an hour. Pull them out first:
Stop proposing fixes. Summarise only what we established by running something:
every command and its actual output, every file and line we read and what it
contained, every behaviour we reproduced. No hypotheses, no explanations, no
next steps. Anything believed but never checked goes under UNVERIFIED.
Facts survive the restart. Theories are what got you stuck.
Ruled out is evidence, not a ban list
There is a wrong way to carry failures forward. "We tried a null check, don't do that again" plants the null check in the fresh context and spends your first turn on it. Naming a bad idea still puts it on the page. Write each ruled-out item as the observation that killed it:
Weak: we tried a null check in render, it didn't work
Strong: with a null guard at src/feed.tsx:52 the duplicate row still renders,
so the duplicate exists in the array before render
Weak: it's not a caching problem
Strong: the duplicate is in the raw response body, before any client cache
is read
The strong version narrows the search without naming a fix. It reads as cleared territory, not an idea worth another try.
The restart brief
New session, no transcript, one message:
Bug: the same expense appears twice in the group feed after a settle-up.
Reproduce: create expense, settle up, reload group. Happens every time.
Output (verbatim):
GET /groups/42/feed -> 200
body contains two items with id "exp_8f21"
Established by running:
- the duplicate is in the raw response body, before any client cache
- a null guard at src/feed.tsx:52 does not remove it
- the database holds exactly one row for exp_8f21
Unknown: which query or merge step produces the second copy.
Read the code that builds that response. Give me your top two candidate causes
and what you would run to tell them apart. Do not edit anything yet.
That last constraint is load-bearing. Without it the first reply is a fix, and a fresh theory lands in the context you cleaned.
Restart, or one more turn
- One more turn when the last attempt produced new output you have not used. A different error means the loop moved and the transcript is still mostly facts.
- Restart when two attempts returned the identical failure, or when its explanations cite earlier explanations instead of output.
- Always restart after three corrections. There is no fourth one that works, and a restart with a good brief costs ninety seconds.
This is the emergency version of a habit worth having anyway: the scheduled version is the fresh-session workflow, and the second-opinion version is the writer/reviewer loop.
Run this on your codebase
Paste this into the stuck session before you close it:
We are stuck. Stop proposing changes and write a handoff for a fresh session
that has never seen this conversation, in these five sections:
1. SYMPTOM: what is wrong in one sentence, plus steps to reproduce.
2. VERBATIM OUTPUT: every error, failing assertion, log line and HTTP response
we saw. Copied, not described.
3. RULED OUT: each thing we eliminated, written as the observation that
eliminated it: "with X in place, Y still happens, so Z is not the cause".
Never as "we tried X".
4. UNVERIFIED: what we assumed but never checked by running something.
5. NEXT: the two most likely places the cause lives, and for each, the command
or file read that settles it.
Include none of your earlier explanations or diffs. Output one block I can
paste into a new session.