AI breaks working code because it patches the symptom it sees. It doesn't know what else depends on that line, and nothing tells it when an old feature stops working. Make it prove each bug with a failing test, fix the cause, and test your app the way a person uses it, and your fixes stop breaking things. The free AI starter kit we build our own products with holds every change to that bar.
Why does AI break code that already worked?
It patches where the bug shows up, which is rarely where it starts. A button that shows the wrong price gets a special case in the button, while the real problem sits in the code that works out the price, and every other screen that uses it stays wrong.
It also only sees the files in front of it. And when your tests mock your own code, they keep passing while the real app is broken, so the AI has no reason to think anything went wrong.
Make it reproduce the bug before it fixes anything
Ask for a test that fails because of the bug, before any fix. If it can't make the bug happen, it doesn't understand it yet, and any fix is a guess.
Once the test fails for the right reason, the fix is done when it passes. Keep that test forever, because it catches the bug the next time a change brings it back.
Fix the cause where it starts
Have the AI name the problem in general terms first, like "retry a failed network call" or "lay out the screen at any window size". Most of these have a proven answer already, in your codebase or a well-used library. Your code should use that answer instead of hand-writing a new one.
If the AI is patching the same spot for the second time, stop it there. That spot needs replacing with the proven piece.
Test your app the way a person uses it
The tests that catch real breakage open the real screen, tap the real button and check what a person would see. Fake only what you don't control, like the network, the clock, the disk or the device. Seed test data the way your app writes it, never by poking rows straight into the database.
When a test fails, that's a finding. Fix the cause, and never let the AI loosen the test or raise a timeout to make it pass.
Change in small steps you can undo
One change per commit, with only the files that change touched. Commit before each AI change so you can roll back in one step. Run the type check, lint and tests once the change is finished, and never let the AI skip your commit hooks with --no-verify.
What you see, and what fixes it
| What you see | Why it happens | Fix |
|---|---|---|
| Fixing one bug breaks another | The patch went where the bug showed up | Reproduce it, then fix the cause |
| Tests pass but the app is broken | Tests mock your own code | Test the real screen with real data paths |
| The same bug comes back | Nothing guards it | Keep the failing test for good |
| The AI goes in circles | A long session full of old guesses | Start fresh with the failing test as the brief |
| You can't tell which change broke it | Big mixed commits | One change per commit |
Get the testing set we use
The starter kit's testing set makes your AI reproduce every bug first, fix the cause, test like a user and commit in small checked steps. It works with Claude Code and Codex. Get the starter kit free on GitHub.
Questions
Why does Claude Code or Cursor break features that already worked?
It fixes the spot where the bug shows up and can't see everything that depends on that code. If your tests mock your own code, nothing tells it an old feature broke.
Should the AI write tests before fixing a bug?
Yes. Have it write a test that fails because of the bug, then fix the code until the test passes. The test stays and catches the bug if it ever comes back.
What do I do when the AI goes in circles on one bug?
Stop the session. Start a fresh one with the failing test and a one-line description of what should happen, so it works from the bug instead of its earlier guesses.
Originally published at wednesday.is.
Top comments (0)