Vibe Coding Debugging

How to Fix a Broken Vibe Coded App

Your app almost works. Something does, something doesn't. AI keeps trying fixes that introduce new problems. This guide covers the most common ways vibe-coded apps break — and how to actually fix them.

Last reviewed: Apr 25 2026


When "Almost Working" Is the Hardest State

A completely broken app is easy to deal with. You start over, or you ask AI to rebuild the failing piece from scratch. But "almost working" is different. 80% of the app is fine. One thing doesn't behave right. You ask AI to fix it, the fix breaks something else, you fix that, the original problem comes back. You're in a loop.

This is the most frustrating state in vibe coding, and it has specific causes. AI-generated code has predictable failure modes: it handles the happy path well and falls apart at edge cases, state transitions, authentication boundaries, and environment differences. Understanding which kind of failure you're dealing with points you to the right fix.

Before You Ask AI to Fix Anything

Describe the problem to AI precisely: what you expected, what actually happened, and any error message you see. Vague bug reports get vague fixes. Specific ones get targeted ones. And always save a copy of the current state before applying any fix — so you have something to go back to if the fix makes things worse.


AI Introduced a Bug

Something worked yesterday and doesn't today. You made a change, AI generated new code, and now a feature that was fine is broken. This is the most common category and also the most fixable.

Find What Changed

The single most useful thing you can do is identify the exact change that caused the regression. If you saved a working version (or have it in your conversation history), compare the two versions side by side. Look for:

If you don't have a saved version, look in your browser's developer tools. Open the console (F12, then click "Console"). Errors there — red text with file names and line numbers — tell you exactly where the code is failing.

Tell AI What the Error Says

Copy the full error message and give it to AI:

You

My app is showing this error in the browser console:

"TypeError: Cannot read properties of undefined (reading 'map') at renderList (app.js:47)"

This happened after we added the search feature. The list used to display fine. Here is my current app.js:

[paste the code]

The combination of the error message, the line number, and the context of when it started gives AI enough to find the actual cause rather than guess at it.

Isolate the Problem

If you're not sure which recent change caused the bug, tell AI to revert only the last change and test whether the bug disappears. Don't ask AI to fix the new feature and the regression at the same time — that produces code that patches both things together and becomes hard to understand. Fix the regression first, then re-add the feature more carefully.

The One-Undo Trick

Ask AI: "Revert only the [specific feature] changes and restore the previous version of [specific function or section]. Don't change anything else." This isolates the regression clearly and usually resolves it in one step.


Strange State Behavior

Your app does something unexpected. Data appears in the wrong place. A counter resets when it shouldn't. A list shows items from a previous session. A form submits twice. These are all state problems — the app's in-memory data is getting out of sync with what you see on screen, or with what's saved on disk.

Common State Bugs in AI-Generated Apps

How to Debug State Problems

Describe what you see, step by step, in exact terms:

You

When I click "Save", the item disappears from the list immediately but reappears when I reload the page. It seems like the save is working (the data is in localStorage when I check), but the displayed list isn't updating to reflect the save. Here is the save function and the render function:

[paste the relevant code]

Describing the exact symptom — not just "it's broken" — tells AI which part of the flow has the bug. In the example above, the symptom points clearly to the render step, not the save step.

The Console Log Check

When state is behaving strangely, ask AI to add console.log statements to the key functions — the save function, the render function, wherever data flows. Then open the browser console and watch what values are actually reaching each step. The log where the value goes wrong is where the bug lives.


Broken Auth Flows

Authentication is where AI-generated code most often breaks in subtle ways. Login forms that accept any input. Sessions that expire instantly. Protected pages that aren't actually protected. Users who can see other users' data. These bugs are often invisible until someone tries something unexpected.

Common Auth Problems

How to Fix Auth Issues

For each of the above, the fix is usually a targeted prompt asking AI to add the missing check explicitly:

You

I've noticed that if I type /dashboard directly in the browser address bar, I can reach it without being logged in. The app should redirect unauthenticated users to /login. Here is the current routing code:

[paste the routing code]

Add a route guard that checks whether the user is authenticated before allowing access to /dashboard. If not authenticated, redirect to /login. Don't change anything else.

Password Storage

If your app handles passwords, make sure AI is using an authentication service (Supabase Auth, Firebase Auth, Auth0) rather than storing passwords in your own database. Never store plain-text passwords. If you see AI generating code that saves a password field directly to a users table, stop and ask it to use a proper auth service instead.

Testing Your Auth

After any auth fix, test the unhappy paths explicitly — they're the ones AI is most likely to miss:


Deploy Issues

It works perfectly on your computer. You deploy it and something breaks. This is one of the most common and most disorienting problems in vibe coding, because the code you tested is the code you deployed — yet the result is different.

Why Things Work Locally But Break in Production

There are a few reliable culprits:

How to Diagnose Deploy Issues

Open the browser developer tools on the deployed version (F12), click the "Network" tab, and reproduce the failing action. Look for requests that return red status codes (4xx or 5xx) or that are blocked. The request URL and error response body tell you what's actually failing.

You

My app works locally but after deploying to Netlify, the data isn't loading. I checked the browser console and I see this error:

"Access to fetch at 'http://localhost:3001/api/items' from origin 'https://my-app.netlify.app' has been blocked by CORS policy."

Here is the code that makes the fetch request:

[paste the code]

The API is deployed at https://my-api.railway.app. Update the fetch URL to use the correct production URL and make it configurable via an environment variable.


Confusing Code Structure

Sometimes the app works but the code has become so tangled that every change you try to make breaks something. AI built everything in one giant file. Functions are nested inside other functions. The same logic is duplicated in three places and you don't know which one to change. You ask AI for help and it generates a fix that references something that doesn't exist anymore.

This is a structural problem, not a bug. The code works — but it's fragile, and it's getting harder to change over time.

When to Refactor vs. When to Rebuild

If the app is small (under a few hundred lines) and only partially working, rebuilding from a clean description is almost always faster. You've learned what works, your second attempt benefits from that knowledge, and you avoid inheriting accumulated mess.

If the app is larger and mostly working, ask AI to restructure specific pieces rather than the whole thing at once:

You

My app.js file has grown to 800 lines and is getting hard to change without breaking things. I'd like to separate the data-handling code from the display code. Can you identify which functions deal with loading/saving data and which ones deal with rendering the UI, and move them into separate sections with clear labels? Don't change any logic — only reorganize the file. Show me the result so I can review it before applying.

The key constraint is "don't change any logic." Reorganizing and fixing at the same time is how refactoring breaks working apps.

When the Conversation Gets Too Long

After 30–50 messages in a single chat, AI starts forgetting the earlier context. It may contradict previous decisions, undo things you already fixed, or generate code that doesn't match the current state of your app. The signs are: fixes that seem off, code that references things you removed, or suggestions that don't match what you described.

The fix is to start a fresh conversation. Paste the current version of your code and a clear description of where you are and what you're trying to do. Fresh context produces better results than extending a long, confused conversation.


When to Start Over

There's a point in every broken app where starting over is faster than continuing to fix. Recognizing that point early saves hours of frustration.

Consider starting over when:

Starting over doesn't mean losing your work. It means taking what you learned from the broken version and writing a cleaner description. The second attempt almost always comes together faster, because you know what the app actually needs now — not just what you thought it needed at the start.

Before You Start Over

Write one paragraph describing what the app does, what currently works, and what the one most important remaining problem is. Then start a new conversation with that description plus the code for the parts that work. You're not rebuilding from zero — you're rebuilding from a better foundation.


Quick Diagnosis Reference

Related Guides

7 Vibe Coding Mistakes That Waste Your Time

The habits that cause most vibe coding problems in the first place — and how to avoid them from the start.

Growing Your Vibe Coded App

How to add features safely to a live app, add a real database, and handle it when things break on live.

When Vibe Coding Isn't Enough

How to recognize when your project has outgrown AI-only building — and what to do about it.

Back to Home