The AI keeps breaking what it just fixed: getting a stuck build moving
You ask for one change and two other things break. You ask the AI to fix those, and the first bug comes back. The credits keep going and the app gets worse.
The loop has causes, and there is a way out. Here is what I do, in this order, when a build made with Lovable, Bolt, Replit, Cursor or Claude Code has stalled.
Are you in a loop?
- A bug you fixed last week is back.
- A change to one page touches files that have nothing to do with it.
- The AI says it fixed the problem, and nothing is different.
- You no longer know which version last worked.
Two of those, and more prompts won't help.
The AI can't see the whole app: in a long chat the early messages drop out of what it reads, so it guesses at code it no longer remembers. Nothing tells it when a change breaks something on another page. And each fix is written on top of the last failed attempt, so the patches pile up.
1. Go back to the last version that worked
Fixing forward from a broken state is how the loop starts. Going back is cheaper.
Lovable, Bolt and Replit keep a history of versions you can restore. In Cursor or Claude Code, that history is git.
Find the last version where the main flows worked, restore it, and write down what you were trying to add when things went wrong. That one feature is now your next task, and nothing else.
2. Save every working state
Connect the project to a GitHub repository you own, if it isn't already.
Each time something works, commit it, with a message that says what works. Small commits make going back a matter of minutes.
3. One change per request
Ask for one thing, name the page or file, and say what must not change: "On the pricing page, make the yearly plan the default. Don't change the checkout or the plans themselves."
Start a new chat for each new task, so the AI reads your request instead of a long, stale history.
Give it a short description of the app it reads every time: what the app does, the main pages, the database tables, the rules it must keep. Lovable calls this project knowledge, Cursor calls it rules, and Claude Code reads a CLAUDE.md file.
4. Look at what changed before you accept it
Every tool shows which files a change touched. You don't need to read code fluently to notice that a button colour changed twelve files.
If a fix to sign-in touched the payment page, undo it and ask again, smaller.
5. Give it something to check against
The AI breaks other pages because nothing tells it they broke. A few automated tests do.
Cover the flows the business depends on: sign up, sign in, pay, and the one action users come for. Ask the AI to write the tests (Playwright works well for this), then run them after every change.
When you find a bug, first ask for a test that shows it failing. Then ask for the fix. The test stays, so that bug can't come back without you knowing.
6. Ask for the cause, not another fix
After the second failed attempt, stop asking for fixes. Ask the AI to explain why the bug happens and which files are involved, without changing any code. Most tools have a mode that answers without editing.
Paste the actual error from the browser console or the server log. "It still doesn't work" gives it nothing to go on.
7. Know when to stop prompting
If the same bug survives three rounds, another round costs more than an hour of someone reading the code.
Some problems need a person: the same logic written twice in different places, files thousands of lines long, or code that disagrees with itself about what is in the database.
After the loop
None of this makes the AI smarter. It makes each change small enough to check, and gives you a way back when one goes wrong. Most stuck builds I see need the first three steps and an afternoon.
Once the app works again and you're getting ready to launch, the preview-to-production checklist covers what changes when it goes live.
If you've been round the loop too many times, that is the work I do: a half-day session to unstick an AI-built app. The first call is free.
Originally published at peterlada.com.
Comments
No comments yet. Start the discussion.