How to Fix AI Generated Code You Cannot Read
You can fix AI generated code without reading it: have your AI draw what is supposed to happen, find the spot where the game leaves that drawing, and only then change anything. If two fixes have already failed, stop correcting and choose between a fresh chat, a rebuilt part or an older saved version.
Why do fixes pile up?
Say you are making Lantern Drift, an invented river game. Your boat sticks to the bank. You ask for a fix, and the AI pushes the boat back. Now it shakes. The next fix calms the shaking, and the boat slides through the bank instead. After seven rounds there are seven patches on top of each other, and nobody can say what the first one was for.
Each fix treated what you could see. Nobody ever wrote down what should happen when a boat touches the bank.
What does a drawing add?
A drawing puts the intended behaviour in front of you, without any code. Here it is for the boat:
- Supposed to happen: sailing, touches bank, bounces off, sailing.
- What really happens: sailing, touches bank, pushed back, touches bank again, stuck.
Now the fault has an address: the step after "touches bank". You can judge that yourself, even if you have never read a line of code. Your AI can draw this with Mermaid, which turns plain text into diagrams. If your tool only shows you the text, Mermaid's docs point to a live editor for people who do not program.
Which way out should you take?
| Situation | What to do |
|---|---|
| First attempt, the cause is shown, the change is small | Fix it |
| Two corrections failed and the fault is still there | Start a fresh chat and put what you learned into one new prompt |
| Fixes keep causing new faults in the same part | Rebuild only that part, from its drawing |
| It worked yesterday and today's work is not worth keeping | Go back to a saved version, as in undoing AI changes |
The second row comes from the Claude Code docs. They say a third correction mostly adds to a chat that already contains two failed attempts, and that a fresh start with one better prompt "works better almost every time". A fresh chat also makes a good second opinion, because it has not seen the reasoning that led to the mess.
If the fix itself keeps taking working details with it, read why AI breaks working code.
Paste this to your AI
Use this in a fresh chat, and fill in the three lines:
Something in my game is wrong, and earlier fixes have not worked.
What I did: [one sentence]
What I expected: [one sentence]
What happened: [one sentence]
Do not change anything yet.
1. Draw what is supposed to happen as a small Mermaid diagram.
2. Find out what really happens, and show me the step where it leaves the drawing. Separate what you saw from what you suspect. If you cannot make the fault happen, say so.
3. List any earlier patches for this fault, and say which could be taken out once the real cause is gone.
4. Recommend one thing: a small fix, rebuilding this part, or going back to a saved version. Give your reason.
Wait for my yes. After the change, tell me what you tried and what happened. If the cause is still a guess, say "I do not know the cause yet" and do not call it fixed.
Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
How to check it worked
- Read both paths. Does "supposed to happen" match what you want? If not, correct that first.
- Repeat the fault five times. Faults that come and go often survive a single try.
- Check the neighbours. The other bank, the bridge, the fastest boat. What sits next to a fix often breaks.
- Ask what was removed. A good fix often takes patches away. If the pile only grows, the cause may still be there.
- Give it to someone who has not seen the bug. Let them play without a hint.