<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Peter Lada</title>
    <description>The latest articles on DEV Community by Peter Lada (@peterlada).</description>
    <link>https://dev.to/peterlada</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4218880%2F8cd1df6b-cc6f-44d2-9365-c35e42e6d898.jpg</url>
      <title>DEV Community: Peter Lada</title>
      <link>https://dev.to/peterlada</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/peterlada"/>
    <language>en</language>
    <item>
      <title>The AI keeps breaking what it just fixed: getting a stuck build moving</title>
      <dc:creator>Peter Lada</dc:creator>
      <pubDate>Mon, 16 Nov 2026 11:31:04 +0000</pubDate>
      <link>https://dev.to/peterlada/the-ai-keeps-breaking-what-it-just-fixed-getting-a-stuck-build-moving-33k6</link>
      <guid>https://dev.to/peterlada/the-ai-keeps-breaking-what-it-just-fixed-getting-a-stuck-build-moving-33k6</guid>
      <description>&lt;p&gt;You ask for one change and two other things break. You ask the AI to fix those, and the first bug comes back. The credits keep going and the app gets worse. The loop has causes, and there is a way out. Here is what I do, in this order, when a build made with Lovable, Bolt, Replit, Cursor or Claude Code has stalled.&lt;/p&gt;

&lt;h2&gt;
  
  
  Are you in a loop?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A bug you fixed last week is back.&lt;/li&gt;
&lt;li&gt;A change to one page touches files that have nothing to do with it.&lt;/li&gt;
&lt;li&gt;The AI says it fixed the problem, and nothing is different.&lt;/li&gt;
&lt;li&gt;You no longer know which version last worked.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two of those, and more prompts won't help. The AI can't see the whole app: in a long chat the early messages drop out of what it reads, so it guesses at code it no longer remembers. Nothing tells it when a change breaks something on another page. And each fix is written on top of the last failed attempt, so the patches pile up.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Go back to the last version that worked
&lt;/h2&gt;

&lt;p&gt;Fixing forward from a broken state is how the loop starts. Going back is cheaper.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lovable, Bolt and Replit keep a history of versions you can restore. In Cursor or Claude Code, that history is git.&lt;/li&gt;
&lt;li&gt;Find the last version where the main flows worked, restore it, and write down what you were trying to add when things went wrong. That one feature is now your next task, and nothing else.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Save every working state
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Connect the project to a GitHub repository you own, if it isn't already.&lt;/li&gt;
&lt;li&gt;Each time something works, commit it, with a message that says what works. Small commits make going back a matter of minutes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. One change per request
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Ask for one thing, name the page or file, and say what must not change: "On the pricing page, make the yearly plan the default. Don't change the checkout or the plans themselves."&lt;/li&gt;
&lt;li&gt;Start a new chat for each new task, so the AI reads your request instead of a long, stale history.&lt;/li&gt;
&lt;li&gt;Give it a short description of the app it reads every time: what the app does, the main pages, the database tables, the rules it must keep. Lovable calls this project knowledge, Cursor calls it rules, and Claude Code reads a &lt;code&gt;CLAUDE.md&lt;/code&gt; file.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Look at what changed before you accept it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Every tool shows which files a change touched. You don't need to read code fluently to notice that a button colour changed twelve files.&lt;/li&gt;
&lt;li&gt;If a fix to sign-in touched the payment page, undo it and ask again, smaller.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Give it something to check against
&lt;/h2&gt;

&lt;p&gt;The AI breaks other pages because nothing tells it they broke. A few automated tests do.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cover the flows the business depends on: sign up, sign in, pay, and the one action users come for. Ask the AI to write the tests (Playwright works well for this), then run them after every change.&lt;/li&gt;
&lt;li&gt;When you find a bug, first ask for a test that shows it failing. Then ask for the fix. The test stays, so that bug can't come back without you knowing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Ask for the cause, not another fix
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;After the second failed attempt, stop asking for fixes. Ask the AI to explain why the bug happens and which files are involved, without changing any code. Most tools have a mode that answers without editing.&lt;/li&gt;
&lt;li&gt;Paste the actual error from the browser console or the server log. "It still doesn't work" gives it nothing to go on.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7. Know when to stop prompting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If the same bug survives three rounds, another round costs more than an hour of someone reading the code.&lt;/li&gt;
&lt;li&gt;Some problems need a person: the same logic written twice in different places, files thousands of lines long, or code that disagrees with itself about what is in the database.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  After the loop
&lt;/h2&gt;

&lt;p&gt;None of this makes the AI smarter. It makes each change small enough to check, and gives you a way back when one goes wrong. Most stuck builds I see need the first three steps and an afternoon.&lt;/p&gt;

&lt;p&gt;Once the app works again and you're getting ready to launch, the &lt;a href="https://peterlada.com/notes/works-in-preview-breaks-in-production/" rel="noopener noreferrer"&gt;preview-to-production checklist&lt;/a&gt; covers what changes when it goes live.&lt;/p&gt;

&lt;p&gt;If you've been round the loop too many times, that is the work I do: a half-day session to &lt;a href="https://peterlada.com/cto/vibe-coding/" rel="noopener noreferrer"&gt;unstick an AI-built app&lt;/a&gt;. The first call is free.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://peterlada.com/notes/the-ai-keeps-breaking-what-it-fixed/" rel="noopener noreferrer"&gt;peterlada.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Works in preview, breaks in production: a checklist for AI-built apps</title>
      <dc:creator>Peter Lada</dc:creator>
      <pubDate>Sat, 31 Oct 2026 16:38:57 +0000</pubDate>
      <link>https://dev.to/peterlada/works-in-preview-breaks-in-production-a-checklist-for-ai-built-apps-2691</link>
      <guid>https://dev.to/peterlada/works-in-preview-breaks-in-production-a-checklist-for-ai-built-apps-2691</guid>
      <description>&lt;p&gt;The preview is a kind place. It has your keys, a database nobody else uses, and one user: you. Production has strangers, real money and a different server. Here is what I check, in this order, when an app built with Lovable, Bolt, v0, Replit, Cursor or Claude Code works in the preview and not live.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Environment variables
&lt;/h2&gt;

&lt;p&gt;The most common cause of a blank page after deploy. The builder kept your settings for you; the new host has never heard of them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;List every variable the code reads. Search for &lt;code&gt;process.env&lt;/code&gt; and &lt;code&gt;import.meta.env&lt;/code&gt;. Each one must be set on the host, for production and for any preview deploys.&lt;/li&gt;
&lt;li&gt;Variables with a public prefix (&lt;code&gt;VITE_&lt;/code&gt;, &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt;) are written into the JavaScript at build time. Changing one on the host does nothing until you build again.&lt;/li&gt;
&lt;li&gt;Payment and email providers give you test keys and live keys. Stripe’s start with &lt;code&gt;sk_test_&lt;/code&gt; and &lt;code&gt;sk_live_&lt;/code&gt;. The preview ran on test keys; production needs live ones, and live webhooks pointing at your real domain.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Secrets in the browser and in the repo
&lt;/h2&gt;

&lt;p&gt;Anything the browser downloads is public, prefix or not.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the deployed site, then the browser’s developer tools, and search the loaded scripts for &lt;code&gt;secret&lt;/code&gt;, &lt;code&gt;sk_&lt;/code&gt;, &lt;code&gt;service_role&lt;/code&gt; and your providers’ names. A key you find there belongs to everyone.&lt;/li&gt;
&lt;li&gt;Calls that need a secret key (payments, AI models, sending email) must go through a server function that holds the key. The browser calls your function, never the provider.&lt;/li&gt;
&lt;li&gt;Deleting a committed &lt;code&gt;.env&lt;/code&gt; file doesn’t remove it from the git history. Rotate every key that was ever in it, then turn on secret scanning (GitHub has it built in; &lt;code&gt;gitleaks&lt;/code&gt; runs anywhere).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Who can read which rows
&lt;/h2&gt;

&lt;p&gt;With Supabase or Firebase, the browser talks to the database directly. The public key is meant to be public, so the only thing between a visitor and your tables is the database’s own rules.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Supabase: check that row-level security is on for every table, and that each policy ties rows to the signed-in user (&lt;code&gt;auth.uid()&lt;/code&gt;). A table created from SQL may start with it off. Firebase: read your security rules and look for anything still open from test mode.&lt;/li&gt;
&lt;li&gt;Try it. Sign in as one user, then ask the API for another user’s data with the public key, outside the app. If it answers, so will it for anyone.&lt;/li&gt;
&lt;li&gt;Hiding a button is not access control. An admin page needs a check on the server or in the database, not only in the interface.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;service_role&lt;/code&gt; key skips every rule. It lives on the server only.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Sign-in on the real domain
&lt;/h2&gt;

&lt;p&gt;Sign-in that works in the preview and loops or fails live is almost always a list of allowed URLs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your auth provider has a site URL and a list of allowed redirect URLs (in Supabase: Authentication, URL Configuration). Add the production domain, with and without &lt;code&gt;www&lt;/code&gt; if you use both.&lt;/li&gt;
&lt;li&gt;Google, GitHub and other sign-in providers keep their own list of callback URLs, in their own console. Add production there too.&lt;/li&gt;
&lt;li&gt;Confirmation and password-reset emails: the built-in mailer (Supabase’s, for one) is meant for testing and sends only a few emails an hour. Connect a real email provider before launch, and check that the links in the emails point at production, not the preview.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. The database itself
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Is production a separate database from the one you tested with? If the preview and the live app share one, every test writes into your customers’ data.&lt;/li&gt;
&lt;li&gt;Schema changes belong in migration files in the repository, not in clicks in a dashboard. Otherwise nobody can rebuild the database, and the next AI change guesses at a schema it can’t see.&lt;/li&gt;
&lt;li&gt;Backups: check that your plan includes them, then restore one into a scratch project once. Until you’ve done that, you don’t know the backups work.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. The build and the host
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run the production build on your machine (&lt;code&gt;npm run build&lt;/code&gt;, then &lt;code&gt;npm run preview&lt;/code&gt; or &lt;code&gt;npm start&lt;/code&gt;). Development servers forgive type errors and missing files that a build doesn’t.&lt;/li&gt;
&lt;li&gt;Search the code for &lt;code&gt;localhost&lt;/code&gt; and the preview’s own address. Both still turn up in API calls and redirects.&lt;/li&gt;
&lt;li&gt;File names: macOS and Windows ignore case, Linux servers don’t. &lt;code&gt;import Header from './header'&lt;/code&gt; works on your laptop and fails on the host if the file is &lt;code&gt;Header.tsx&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A single-page app needs a rule that sends every unknown path to &lt;code&gt;index.html&lt;/code&gt;. Without it, reloading any page except the home page gives a 404.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7. Limits and costs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Rate-limit sign-up, sign-in and anything that calls a paid API. An AI feature with no limit is a bill anyone on the internet can run up.&lt;/li&gt;
&lt;li&gt;Set spending caps or budget alerts with the host, the database and every AI provider, before launch.&lt;/li&gt;
&lt;li&gt;Estimate the monthly cost at a hundred and at a thousand users.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. Knowing when it breaks
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Error tracking in the browser and on the server (Sentry or similar), so you hear about errors before your users write to you.&lt;/li&gt;
&lt;li&gt;An uptime check on the home page and on one page that reads from the database.&lt;/li&gt;
&lt;li&gt;A staging copy of the app, with its own database, where each change goes first. Deploy there, click through the main flows, then promote.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  After the list
&lt;/h2&gt;

&lt;p&gt;None of this is advanced, and most of it is an afternoon’s work. It gets skipped because the AI tools are built to make the preview work, and the preview never asks these questions.&lt;/p&gt;

&lt;p&gt;If you’ve been through the list and you’re still stuck, that is the work I do: &lt;a href="https://peterlada.com/cto/vibe-coding/" rel="noopener noreferrer"&gt;getting AI-built apps to production&lt;/a&gt;. The first call is free.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First published at &lt;a href="https://peterlada.com/notes/works-in-preview-breaks-in-production/" rel="noopener noreferrer"&gt;peterlada.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>supabase</category>
      <category>deployment</category>
    </item>
  </channel>
</rss>
