Skip to content

    Vibe coding

    Fix or rebuild? A decision framework for AI-generated codebases

    Author

    AI Cubed

    Published

    September 9, 2026

    Read time

    10 min

    Every founder with a messy AI-built app eventually asks the same question, and gets three different answers from three developers. One says it's fine. One says rebuild. One wants a retainer to find out. The reason the answers differ is that "fix or rebuild" isn't one decision — it's five signals and a scope question, and most people are guessing at all six.

    This is the framework we use in every audit. It's deliberately simple enough that a non-technical founder can follow the reasoning, and specific enough that two engineers applying it to the same codebase should land on the same answer.

    The five-signal test

    Score each signal 0, 1 or 2. Be honest — the framework only works if the scores are. If you can't assess a signal yourself, that's the one to ask an engineer to check; it's an hour, not a project.

    Scoring the five signals
    Signal0 — points to rebuild1 — mixed2 — points to fix
    Core user flowHas never worked end to end anywhereWorks in one environment with workaroundsWorks end to end for at least one real user
    Data modelSchema reshaped repeatedly; tables contradict the productRoughly right, missing constraints and indexesTables match the product; relationships make sense
    StackObscure, abandoned, or several frameworks glued togetherMainstream but mixed versions or conventionsMainstream, one version, current
    SecurityLeaks by design — everything runs client-side, no server boundaryGaps but fixable: missing RLS, keys in clientServer boundary exists; policies exist; gaps are small
    CoherenceContradictory patterns per file; huge duplication; nobody can find anythingTwo or three patterns per concern; readable with effortConsistent patterns; a competent engineer can navigate it in a day

    Add the five scores. Eight to ten: fix it — the foundation is real and the remaining work is additive. Zero to four: rebuild — you would spend more understanding it than writing it. Five to seven: neither answer is right for the whole app, which brings us to the part most people skip.

    The module-level decision (where most real apps land)

    A codebase is not one thing. It's an auth module, a data layer, a payments integration, a dozen screens, some background jobs. In a middling codebase, some of those are fine and some are disasters, and the right move is to decide for each one. Draw a table with one row per module and apply three tests.

    Keep, refactor, rewrite or delete — per module
    Does it work?Can an engineer read it?Is it cheap to test?Decision
    YesYesYesKeep. Don't spend money on code that isn't costing you anything.
    YesYesNoKeep, add a test around its edges.
    YesNoRefactor. It works; make it readable before the next change breaks it.
    NoYesFix. The bug is findable.
    NoNoRewrite. Cheaper to write it properly than to understand it.
    Unreachable from any route or jobDelete. Dead code is a cost with no benefit — usually 20–40% of an AI-built codebase.

    This is what an audit produces: that table, filled in, with a quote attached. It's also why cost tracks the number of rewrite rows rather than total lines. A large codebase where most modules are keep or refactor is cheaper than a small one where everything is tangled.

    Three illustrative cases

    These are composites, not client stories, chosen to show how the scoring plays out.

    • A Lovable-built CRM with real users. Core flow 2, data model 2, stack 2, security 1 (RLS missing on three tables), coherence 1 (the same list component exists four times). Total 8: fix. Security first, consolidate the components, add tests around contact creation. Two to three weeks.
    • A Cursor-built marketplace that never took a real order. Core flow 0, data model 1, stack 1 (Next 14 and 15 conventions mixed), security 1, coherence 0. Total 3: rebuild. Keep the schema idea and the UI screens as reference; rewrite from a clean scaffold. Four to eight weeks, first working version in two.
    • A Bolt-built internal tool with one branch using it. Core flow 2, data model 1, stack 2, security 0 (everything client-side against a public database), coherence 1. Total 6: per module. The UI is kept; the data layer is rewritten behind a server boundary with policies; the reporting job is deleted because nobody uses it. Three to four weeks.

    Why not just rebuild — it's cleaner?

    Because the AI's work is real and rebuilding discards it. Screens that users have validated, a data model that fits the product, integrations that took days to get right — all of it gets rewritten from memory, with new bugs. Rebuilds also take longer than anyone estimates, because the first version's requirements are now scattered across a codebase nobody wants to read. Rebuild when the test says rebuild. Not because it feels tidier.

    Why not just clean it up file by file?

    Because a large share of the files should be deleted, and cleaning them first is paying to polish garbage. The module map identifies what's reachable and what isn't before anyone touches a line. Cleanup without a map is how six-week engagements become sixteen.

    Whichever you choose, do these first

    1. Rotate any secret that was ever in the repo or the browser.
    2. Get the database behind access rules, even if you're going to rebuild — your current users' data is exposed now, not later.
    3. Put the code in real version control with a branch you can go back to.

    These are identical for fix and rebuild, they take a day or two, and they're the difference between a project and an incident.

    What AI Cubed does about this

    Our two-business-day audit applies this test and produces the module table with a fixed quote. Most apps we see are fix or per-module; we tell you on day two if yours is a rebuild. See vibe-coding rescue or AI-generated code cleanup.

    Frequently asked questions

    Start here

    See where your operation is losing time.

    Twenty minutes with an operator, not a salesperson. We'll name the one bottleneck costing you the most — and tell you whether it's worth fixing with software at all.

    Book your free 20-minute consult

    20 minutes · video call · no preparation needed