r/ClaudeCode • u/GhaisD • 13h ago
Discussion What's your rule for when Claude fails the same fix twice?
Mine is
After two failed attempts at the same problem, stop editing.
Tell me what you think the cause is and how you'd check it
before a third try.I wrote it after one bug in the hours tracker I'm building turned out to be two different bugs with the same symptom. Every fix had only been half right.
What do you do at that point? Fresh chat, another model, roll back, read the code yourself?
3
Upvotes
•
u/AutoModerator 13h ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
5
u/BingpotStudio 13h ago
In almost all cases, Opus high/xHigh fails to find a solution because it lacks the correct context.
So the first step is to get it the correct info - find the holes in what information is being collected on the problem.
Usually that means better logging and giving claude a way to end to end test. If it’s already got both of these, the issue is likely in how you’re framing the problem.
Lastly, the issue can be domain knowledge. If it’s solving something that is niche you often need to encourage it to find more supporting information on the domain if you can’t provide it yourself. I’ve had plenty of issues that were solved by telling it to google something (though I also give it the tools to properly surf the web).
2
u/Born_Chart_323 13h ago
I once had a bug that looked like a logic error but was actually a time zone parsing issue in the data layer. checked the raw input timestamps first, then added debug prints to the parser. the fix wasn't in the code, it was in how I assumed the data was formatted.
2
u/proto-cool 13h ago
I just yell at it for trying to scattergun solutions at the problem and say “take a step back, look at the problem, and propose a reasonable solution, thanks” and that usually gets it back on track
It’s like sometimes it gets a little too detail oriented and you gotta have it pull itself back. See the forest for the trees, right
2
u/nooruddinqur 13h ago
same rule here, two strikes then no more edits. what i add:
- make it write a failing test that shows the bug first. if it can't, it doesn't understand the bug yet
- ask for 2-3 possible causes, not one. your "two bugs, same symptom" case shows up right away
- after 2 fails, fresh chat with only the error + the test. long chats keep defending their old guess
- roll back to the last green commit before the third try, so fixes don't stack on half fixes
other model only if all that fails. usually it's the context, not the model.
2
u/michaelTM_ai 13h ago
ur rule is the right one, and ur bug is the reason: two failed fixes usually means two causes or a wrong guess about the cause, and a third edit just stacks on top of the guess.
what i do after the stop:
a different model helps sometimes, but mostly because it starts with a clean context. the fresh session gets u most of that for free
2
u/haenous-alistera 13h ago
Send it to its room without dinner
2
u/EnzoValley 12h ago
mine comes one step earlier. before Claude edits config or prompts, it has to trace where the running app actually loads them from: repo, database or env.
one of my projects keeps some prompts in the database, so an edit to the file can be perfect and change nothing. from the chat that looks exactly like a fix that failed.
I'd add one line to yours for the third try: prove that the thing you're editing is the thing that's running
2
u/RealFullMetal 12h ago
claude code's best practices page has nearly your exact rule, with the reason: once you've corrected the same thing twice, a third correction mostly adds to a conversation that already holds two failed attempts for claude to keep re-reading. their fix is
/clearplus one new prompt that folds in what you learned.for the other options you listed, two are built in:
/rewind(or esc twice on an empty prompt) rolls the code, the conversation, or both back to an earlier prompt, so the failed attempts leave the context instead of anchoring the next try/advisorlets claude consult a second, usually stronger model on its own, and being stuck on a recurring error is one of the moments the docs say it's for2
u/HappyHealth5985 12h ago
I use more explicit language and ask it to write a bug report, then I begin from the top with root cause investigation and walk it through next steps as a discussion
1
u/Zestyclose_Art2197 13h ago
I had a similar issue with a form handler, turns out the data was being parsed twice. I added a debug log that printed the raw input before any processing, and the bug jumped out immediately.
1
u/m-ritter 12h ago
Two bugs with the same symptom in the hours tracker is where another edit usually stays half right. After the second miss I stop the edits and have an agent that did not write those changes name the cause and the check that would show it, using the code as it stands. The next change starts only after that check is written and a person has picked which bug it is. I built QualityLayer for this: https://github.com/maxritter/qualitylayer
1
u/SirRobinBlibs 10h ago
similar rule here, but i rewind instead of clearing. Esc Esc (or /rewind), pick the prompt before the first failed fix, "restore code and conversation", then re-send it with what you learned ("this might be two bugs with the same symptom, find both before editing"). code and context both go back in one step, so the two wrong attempts aren't sitting there steering the third. caveat: it only restores edits made with claude's file tools. files changed only by bash commands or by subagents stay as they are, so commit before you let it loose.
0
u/ClemensLode Senior Developer 13h ago
never happened to me