Fix, then fix the fix, then fix that. Every patch works, and the code gets a little more tangled, until nobody, including the AI, can safely change it.
Sometimes the right prompt isn't another fix, it's start over: throw the tangle away and rewrite from a clean spec.
Patch number four vs a clean restart
The same tangled function, two ways, from Claude, via Claude Code (26 Sep 2026). Verbatim.
it still allows spaces in the middle, patch that too
function cleanUsername(name) {
name = name.trim();
name = name.toLowerCase();
if (name.indexOf(' ') !== -1) name = name.split(' ').join('');
let out = '';
for (let i = 0; i < name.length; i++) {
if (/[a-z0-9_]/.test(name[i])) out += name[i];
}
out = out.replace(/ /g, ''); // strip spaces (from patch 3)
return out;
}worseIt works, but each patch left a layer: two different space-strippers, a loop, and a comment nobody trusts.
rewrite this cleanly: lowercase, trim, keep only a–z, 0–9 and underscore
function cleanUsername(name) {
return name.trim().toLowerCase().replace(/[^a-z0-9_]/g, '');
}betterOne line, does everything the four patches did, and you can actually check it at a glance.
What changed: When you're prompting patch-on-patch and the code keeps sprouting layers, the fastest fix is often to write the spec once and ask for a clean rewrite.
How to tell which you need. Patch when the change is small, local and you understand the current code. Restart when you've fixed the same thing more than twice, when you can no longer say what the code does, or when each fix breaks something else. Those are the signs a rewrite is cheaper than the next patch.
Restarting doesn't mean starting the whole app over, just the tangled piece. And it's easier the second time, because now you actually know the spec: everything you learned from the patches becomes the constraints in a single clean prompt.
Try it with the rules off. Picture the patched version above after three more “add one more rule” prompts. Now picture changing it safely. The one-line rewrite is the only one of the two you'd want to touch.
Check yourself
0/3 got itSaved on this device only. No account, no streaks.
Next in talking to it well: Which model for which job.




