Rescue or rewrite an AI-built app: how to decide, and what to fix in what order

In short: most AI-built apps are cheaper to rescue in parts than to rewrite. A rewrite is justified when the data model is incoherent, when you cannot get access to your own code and infrastructure, or when the platform cannot support where the business is going. Decide on audit findings, not frustration, and fix in order of damage: data, money, backups, monitoring, then code.

9 min read

In short

  • A rewrite resets the clock: old bugs vanish, new ones appear, and features freeze for months.
  • Four criteria decide it: the data model, access to your infrastructure, how payments are confirmed, and whether anything is tested.
  • Missing tests and messy code are reasons to add tests, not to rewrite.
  • An incoherent data model or no access to your own accounts are the strongest reasons for a rewrite of the core.
  • Whichever you choose, the first weeks are the same: close data exposure, fix payments, add backups and monitoring.

The short answer

When an app built with Lovable, Bolt, Replit, Cursor or v0 starts failing under real users, the first instinct is often “let’s build it properly this time”. Sometimes that is right. More often the product is sound and the problems sit in a few invisible layers: access rules, payment handling, backups, monitoring. Those can be fixed without throwing away what already works — the screens, the flows customers have learned, the data they have entered.

The reliable way to decide is an audit that looks at specific criteria. Below are the four we use, what each looks like in a rescuable app and in one that needs a new core, and the order in which a rescue should run.

What a rewrite really costs

The price of a rewrite is not just the invoice. It is easy to underestimate the rest.

  • Frozen product. While the new version is built, the old one gets only emergency fixes. Competitors and customers do not wait.
  • Rediscovered edge cases. The current app, however messy, encodes months of small decisions: discounts, refunds, odd customer requests. A rewrite has to find them all again, usually through bugs.
  • Data migration. Customers, orders and payments have to move to the new structure without loss, and be verified.
  • Two systems at once. For a while you run, pay for and support both.
  • New bugs. Fresh code has not met real users yet. The old bugs are gone; the new ones have not been found.

None of this means never rewrite. It means a rewrite has to beat these costs, and that only happens when the foundation itself is wrong.

Four criteria that decide it

Criterion
Rescue if… / Rewrite the core if…
1. Data model
Rescue if each fact lives in one place, tables reference each other, and rows have a clear owner (a user_id or team_id). Rewrite if the same data sits in five places, key information is stuffed into free-form JSON, and nothing says which user a row belongs to — then access rules cannot even be written reliably.
2. Access to infrastructure
Rescue if the code is in a repository you control, and the database, hosting, domain and payment accounts are in your name or can be transferred. Rebuild if the code cannot be exported or the accounts belong to someone who will not hand them over; then the live product becomes the specification.
3. Payments
Rescue if payments go through a known provider and the fix is moving confirmation to the server: webhooks, a single place that marks orders paid, protection from duplicates. Rewrite that module if payment logic is scattered across many screens and the browser decides what was paid.
4. Tests
AI-built apps often have none, and that alone is not a reason to rewrite. The fix is to write tests around the critical flows — sign-up, sign-in, checkout, the main action of your product — before changing anything else. Rewrite only if the code is so tangled that even those flows cannot be isolated.

Two things often look like rewrite signals but are not. “The code is ugly” is a matter for refactoring, module by module, once tests exist. “The AI keeps breaking things when we ask for changes” usually points to missing tests and review, not to a broken foundation.

The usual answer: rescue in parts

Between “patch everything” and “start over” there is a third path that fits most projects. Keep the interface and the parts that work, put tests around them, and replace the dangerous modules one at a time behind the same screens. Users see the same app getting more reliable; you never have a months-long gap without releases.

Audit finding
Typical decision
Sensible data model, holes in RLS and integrations
Rescue: close vulnerabilities, fix payments, add backups and monitoring
Works, but every change breaks something else
Rescue in parts: tests first, then replace module by module
Incoherent data model
Rewrite the core, keep the interface, migrate customer data with verification
No access to code or accounts
Recover access; if impossible, rebuild using the live app as the specification
Platform limits block the roadmap
Move to your own infrastructure, using the current app as a working prototype

An ordered rescue plan

The order follows the damage, not the difficulty. The same first steps apply even if the final decision is a rewrite, because the current app keeps serving customers while the new one is built.

Rescue, step by step
  1. 01

    Inventory and access

    List every account: repository, database, hosting, domain, payment provider, app stores, the AI builder, email and AI APIs. Move each into the company’s name. Nothing else is safe until this is done.

  2. 02

    Close data exposure

    Enable RLS with correct policies, move secret keys off the client and rotate any that leaked. Our Supabase RLS checklist shows what to look at.

  3. 03

    Fix how money is confirmed

    Orders become paid only on server-side confirmation from the provider; duplicates are ignored; a daily reconciliation compares your orders with the provider’s records. Details in our article on payment idempotency.

  4. 04

    Backups you have restored

    Daily backups in separate storage and one real test restore. On Supabase, daily backups come with paid plans; on the Free plan, Supabase recommends exporting your data regularly yourself.

  5. 05

    Monitoring and alerts

    Uptime checks, error tracking and alerts on failed payments, so you hear about problems before customers do.

  6. 06

    Tests on critical flows

    Sign-up, sign-in, checkout and your core action, run automatically before every release — including releases made with AI help.

  7. 07

    Refactor or replace the worst modules

    Now, with a safety net in place, clean up or rewrite the parts that cause the most incidents, one at a time.

  8. 08

    Documentation and handover

    Where everything lives, how to deploy, how to restore. So the product no longer depends on any single person, us included.

What it costs with us

Our project rescue has three tiers. At 2026 prices: Diagnosis — a 5-day audit of code and access with a written plan — costs $1,500–3,500 and takes a week. Stabilization — critical bugs, vulnerabilities and monitoring — costs $6,000–15,000, about four weeks. Relaunch — refactoring, automated tests and new features — costs $15,000–50,000, about ten weeks. Our engineers work from Tashkent; every other range is on the pricing page.

The diagnosis report ends with a recommendation: rescue, rescue in parts, or rewrite the core, with the reasoning and the price of each option. It is yours to take to any team. If you are comparing offers, our guide on hiring someone to fix an AI-built app covers what a good proposal contains, and what to check first in a vibe-coded app gives a 15-minute self-check.

Frequently asked questions

Is it cheaper to rewrite an AI-built app from scratch?

Usually not. A rewrite looks cheaper because the old problems disappear, but it brings a feature freeze, data migration, rediscovered edge cases and new bugs. It pays off when the data model is incoherent or you cannot access your own code and accounts.

Our app has no tests. Does that mean a rewrite?

No. Many AI-built apps start without tests. The fix is to add tests around the critical flows first and then change the code under their protection.

Can we keep using Lovable, Bolt or Cursor after a rescue?

Often yes, as long as the code lives in your repository and changes go through tests and an engineer’s review before release. The tools are good at speed; the review covers what they do not see.

How long does a rescue take?

With us, the diagnosis takes a week, stabilization about four weeks, and a relaunch with refactoring and new features about ten weeks. The diagnosis tells you which of these you actually need.

What if the builder will not let us export the code?

Then the live app becomes the specification: its screens, flows and data define what the new version must do. Customer data is exported and migrated with verification, so users keep their history.

Sources

Every claim here can be checked: below are the primary sources, not a retelling.

  1. 01Lovable docs: GitHub integration — Two-way sync with GitHub, export to deploy outside Lovable, code download on paid plans
  2. 02Supabase docs: Database backups — Daily backups on Pro, Team and Enterprise; Free plan projects advised to export data regularly
  3. 03Supabase docs: Row Level Security — Policies depend on rows having an owner column such as user_id
dbit.one engineering desk
The engineers who build these systems

These articles are written by engineers working on the projects and published under the desk’s name. The studio and the desk’s published rules stand behind every text, not a single author; articles about our own open-source code carry the author’s name.

How we write and what we verify

Related services

Read next

Choices & process15 min read

Vibe-coded app broken after launch? What to check and what to fix first

In short: an app built with AI tools and no engineer rarely breaks in the interface. It breaks where nobody looks: a database anyone can read, secret keys shipped to the browser, payments that never become orders, no backups and no monitoring. Fix data first, then money, then backups and monitoring. A full rewrite is not always needed: most projects can be rescued in parts.

Choices & process15 min read

Supabase security checklist: check RLS, keys and storage in your own app

In short: in a Supabase app, the browser talks to the database directly, and Row Level Security (RLS) is the only thing deciding who sees which rows. Check four things in your own project: RLS is on for every exposed table, the policies limit users to their own data, no secret key ships to the browser, and storage buckets are not public by accident. The Security Advisor in the dashboard catches most of it. If a secret key leaked, fix the cause, then rotate.

Choices & process11 min read

How to hire someone to fix your AI-built app without losing control of it

In short: before anyone touches your app, make sure the code, database, domain and payment accounts are in your name. Give each person the narrowest role that lets them work, never your own passwords. Start with a fixed-price diagnosis that delivers a written, ranked list of problems and a plan with prices. Be wary of proposals that promise a rewrite or a timeline before anyone has looked at the code.

Questions about your project?

Describe your task — within 24 hours we’ll come back with an estimate, timeline and plan.

hello@dbit.one