Back to all posts

What to Do When Your Cursor or ChatGPT Code Has Bugs You Can't Fix

Tips & Tricks February 22, 2026 7 min read

There's a pattern I see all the time. Someone builds an app with Cursor or ChatGPT. It mostly works but has a few bugs. They ask the AI to fix the bugs. It introduces new bugs. They ask it to fix those. Repeat until the codebase is a tangled mess that neither the AI nor the developer understands anymore.

If you're in this loop right now, here's how to break out of it.

Why AI Fixes Often Make Things Worse

AI coding tools don't have memory of your full project context the way a developer does. When you paste in a bug and ask for a fix, the AI is working with a narrow window. It might fix the symptom but break something else because it doesn't see the bigger picture.

It also tends to over-engineer fixes. You have a simple null check issue and the AI rewrites your entire component with three new abstractions. Now you have more code to debug, not less.

The fundamental problem: AI is great at writing new code. It's mediocre at debugging existing code, especially code it wrote in a previous session without the same context.

Strategy 1: Stop Asking the AI to Fix the AI

This is the most important mindset shift. After two failed fix attempts with the same AI tool, switch approaches entirely.

Instead, try:

Strategy 2: Undo Until It Works

If you're using Git, this is easy. Run git log --oneline to see your recent commits, find the last one where the app worked, and check it out. Then compare what changed.

If you're not using Git, start using it today. Even just running git init and committing before every major change gives you an undo button that will save you hours.

# See your recent history
git log --oneline

# Go back to a working state
git checkout abc1234

# Compare what changed
git diff abc1234 HEAD
Tip: Before asking the AI for any change, commit your current working state. That way you can always go back.

Strategy 3: Give the AI Better Context

If you're going to keep using AI to debug, at least give it a fighting chance. Most people paste in one file and say "fix this." That's not enough.

Include in your prompt:

The more context you give, the better the fix. Think of it like going to a doctor. "It hurts" gets you nothing. "Sharp pain in my lower right abdomen that started after eating, worse when I press on it" gets you a diagnosis.

Strategy 4: Fix One Thing at a Time

When you have multiple bugs, don't try to fix them all in one prompt. Fix one, test it, commit it, then move to the next. This way:

Strategy 5: Learn the Patterns

You don't need to become a full developer, but knowing a few common patterns will make you 10x better at working with AI tools.

Learn these concepts and you'll debug 80% of issues yourself:

When to Call in Backup

Sometimes the codebase is too far gone. If you've been going in circles for more than a day, the cost of your time is already more than what a developer would charge to fix it properly.

Things I commonly see that need professional help:

The goal isn't to be able to fix everything yourself. The goal is to know when to push through and when to hand it off.

Going in circles with AI-generated bugs?

Tell me what's happening. I'll take a look and let you know if it's a quick fix or something bigger.

Email David