Does Your AI-Built App Need a Rebuild, or a Better Repair?
Refactor vs rewrite is not a decision to make from messy code alone. Compare a repair, component replacement, staged migration and full rebuild.
Nov 20, 2026 · 5 min read
Field Notes from Thunkle, a studio that takes AI-built apps from prototype to secure, production-ready software.
Messy code is a reason to investigate an app. It is not, by itself, a reason to build the product again. The refactor vs rewrite decision should follow the behaviour you need to change and the business you need to preserve.
A running SaaS contains decisions its screens do not explain: cancelled bookings, old subscriptions, refunds, staff exceptions and customer records that must survive the next release.
When I review a difficult application through Thunkle, I start with what the business cannot reasonably do today. Then I compare four options against the same requirements.
First, define the problem a replacement must solve
“Built with AI” describes part of the development process. It does not identify a defect. “Billing sometimes charges the wrong amount after a booking is edited” is something a developer can investigate.
Bring reproducible failures, operational limitations and the next business requirement. Separate discomfort with the code's appearance from behaviour that affects customers.
Agree a bounded investigation before a large implementation quote. Useful outputs include the reproduced problem, relevant dependencies, access constraints and the options worth estimating.
That work is not wasted if the eventual recommendation is a rebuild. It records what the replacement must preserve.
Option one: repair the specific defect
A contained cause often deserves a contained repair.
For a fictional appointment app with a working calendar and unreliable billing, two fee calculations might disagree. Correcting the pricing rule and its callers could leave the calendar, records and customer interface intact.
Ask where the wrong decision happens and how the repair will be tested. Include historical records where relevant. Changing a function is not enough if the earlier data still causes incorrect results.
If the failure cannot be reproduced, diagnose it first. Moving unexplained behaviour into a new repository does not make the behaviour understood.
Option two: replace a component
Billing may be tangled enough to replace without rebuilding the rest of the product.
Define the component's inputs, outputs, stored data and background work. A replacement checkout has to connect to the correct existing account, not merely complete a test payment in isolation.
Try a small complete slice: one booking type, one payment method and one cancellation rule. Compare the old and proposed behaviour using known test records.
If that slice forces changes across unrelated features, name the dependencies and revise the estimate. A label such as “technical debt” is not a specification.
Option three: migrate the limiting infrastructure
Sometimes the app works, but its hosting, background jobs or provider constraints prevent the next stage of the business.
A staged migration can preserve useful product code while changing those dependencies. It still needs an inventory of authentication, records, files, integrations, jobs and operational ownership.
Plan how writes made during the transfer reach the destination. Decide which system handles a purchase while both environments exist. Include the temporary overlap in the estimate.
The migration scope worksheet helps distinguish a code move from a working customer cutover.
Option four: rebuild with a defined preservation plan
A rebuild can be the right result. The proposal should explain why smaller options cannot meet the requirements at an acceptable cost.
It must include the business already running: accounts, subscription relationships, files, historical states and staff workflows. A list of new screens does not cover those obligations.
For the appointment example, copied booking rows without cancellation states could make the new application incorrect on its first day. A record count alone would not expose that.
Price new features separately from replacement. Otherwise, an architectural repair can quietly become a redesign, migration and product expansion under one deadline.
Compare quotes on the same basis
For every option, ask what happens to the existing app while development continues.
Who handles a production bug? If an urgent field is added to the current version, does the replacement need it too? Which environment receives new customers, and when does that change?
Compare required behaviour, data transfer, tests, temporary overlap, deployment, recovery and maintenance. A rebuild estimate can look cheaper simply because it excludes the running business.
Name the uncertain parts. “Authentication transfer not yet checked” is more useful than a large unexplained contingency figure.
Set an early decision point
Before committing to weeks of work, agree what would cause you to reconsider the approach.
Can the difficult workflow pass its acceptance test? Can existing records be preserved? Can another developer explain how the old and new parts fit together?
If the answer is no, reduce or change the scope before the promising new interface makes the decision harder. Billing might move now while reporting stays. A temporary repair might keep the service usable while a larger move is prepared.
There is no universal percentage of bad code that makes this decision. The question is whether the proposal can deliver the required product at a cost and disruption the business can support.
What I need for an independent review
Send the app URL, stack, recurring failures, relevant integrations and the requirement that is blocked. Do not send production credentials by email.
A Thunkle application review should explain what to keep as clearly as what to change. The investigation and any implementation should have distinct scope and acceptance criteria, so you can decide what to fund next.
Questions before a refactor or rewrite
When is refactoring better than rewriting?
A contained, understood defect may be repairable without replacing working features and records. Compare the required behaviour, dependencies, tests and operating overlap. Messiness alone does not establish that a new implementation is cheaper or safer.
What should an initial codebase review deliver?
A bounded investigation should establish the failure, relevant dependencies, options and uncertainties, followed by an implementation estimate where there is enough evidence. It should explain what to retain as well as what to change.
Get a recommendation before funding the rebuild.
I can investigate the failures and dependencies, explain what is worth keeping, and scope the next implementation step around the business already running.
