AI changed the math of legacy modernization
- Written by
Tiago Coelho- Published
Key takeaways
- AI made moving code far cheaper: Airbnb migrated nearly 3,500 test files in six weeks against a 1.5-year estimate (opens in a new tab), so a rewrite ruled out on cost a few years ago deserves a second look.
- Agents read legacy code fast, but deciding whether a behavior is a business rule or a bug, and what the data means, still takes people who know the business.
- Tests decide the direction: where the old behavior can be pinned down as tests, a rewrite has become realistic, and where it lives in people's heads, slice-by-slice modernization is still the safer route.
- Incremental modernization got cheaper at the same time, so a cheaper rewrite doesn't win by default. Re-run the decision system by system instead of reopening one big rewrite.
For most of my career, the answer to "should we rewrite this legacy system?" was almost always no. A rewrite took years, froze the roadmap, and risked shipping something that did less than the system it replaced. AI has moved the first two of those costs a long way. If you ruled out a rewrite on cost a couple of years ago, that decision deserves a second look, with one caveat: the third cost, knowing what your system actually does, has moved far less.
Why "don't rewrite" was the right default for so long
For two decades, the cost and risk of a rewrite settled most legacy modernization questions before anyone got to the architecture. You funded two systems for as long as the rewrite ran, and the roadmap waited.
Teams that rewrote anyway found that most of the money went into rediscovering what the old code did: the discount rule added for one customer years ago, the report finance runs on the last day of the quarter, the validation nobody remembers adding. That's why incremental modernization became the sensible default. Moving a system slice by slice, as we describe in our guide to the migration of legacy systems without stopping the business, kept the business running and let teams learn the old behavior one piece at a time.
When I wrote about migrating legacy systems in September, I argued for incremental migration in nearly every case. I still think that's the right default for most systems carrying revenue. What's changed is the cost behind that advice.
What AI code migration made cheaper
AI code migration has turned projects that used to be planned in years into projects planned in weeks, and the public examples are hard to ignore.
Airbnb migrated nearly 3,500 React test files to a new testing library in six weeks (opens in a new tab), against its own estimate of 1.5 years of engineering time (opens in a new tab). Asana replaced an outdated testing system in about two weeks, with roughly $12K in model and infrastructure costs plus 1.5 weeks of engineering effort (opens in a new tab), against an estimated $6M for its previous staffing plan (opens in a new tab). At Anthropic, a million-line port of Bun from Zig to Rust took less than two weeks (opens in a new tab), with the full existing test suite passing before merge.
What these projects share matters more than their headline numbers. Each had a source of truth to check against: the old code, plus a test suite that said whether the new code behaved the same. Anthropic's write-up calls the old code "a great spec for the model". Even then, the last stretch stayed human. Airbnb's pipeline handled 97% of files automatically after four days of tuning (opens in a new tab), and engineers fixed the remaining hundred or so by hand. Asana's CTO, Amritansh Raghav, put it plainly: "Not every years-long project will collapse into weeks."
What AI didn't make cheaper: knowing what your system should do
AI made reading legacy code cheaper too, which is the part people underestimate. What it can't remove is the need for someone who can say what correct looks like. An agent can map dependencies and describe what a module does today. Whether that behavior is a rule the business depends on, or a bug customers learned to work around, is a question for people.
Anthropic argues that legacy modernization stalled because understanding legacy code cost more than rewriting it (opens in a new tab), and that agents now automate much of that exploration. I agree with the first half, and our teams use agents for exactly that work. The same post is clear that your team still decides which components move first and whether the tests are good enough. That second decision is where most of the risk now sits.
We see it on client work right now. On one SaaS client's admin portal, we're porting a legacy front end to React. A review of the port on a single settings page produced seven open questions about how that page is supposed to behave, and the code alone couldn't answer any of them. So the client's engineers and our designers now pair on each legacy screen, in a shared handoff document, before it moves.
However fast the code moves, the questions about behavior arrive at human speed. Data works the same way. Moving records is mechanical, while deciding what a half-migrated customer record means still needs someone with the authority to make the call.
It's also worth being careful with extrapolation. Even the researchers measuring AI's effect on experienced engineers in their own mature codebases haven't settled the size of the speedup: METR's latest update calls its own estimate likely a bad proxy for the real productivity impact (opens in a new tab). Migrations are the best case for agents, because the work is repetitive, parallel, and checkable. Most product work is messier.
Rewrite vs refactor: the threshold moved for both options
A cheaper rewrite doesn't make the rewrite the right call by default, because refactoring got cheaper at the same time. The same agents that port a codebase also write characterization tests, update call sites, and convert one screen at a time. Incremental modernization moves faster than it did, and it still keeps every step reversible.
The line between the two options has moved. A rewrite used to need an existential reason: the platform was out of support, nobody could hire for the language, or the architecture blocked the next three years of roadmap. Anthropic's migration guide says the case "no longer needs to be existential", and adds that it still needs a justifiable business case. That's the real shift for a CTO. A smaller reason can now justify a rewrite, and a smaller budget can now fund steady, slice-by-slice modernization. Which one fits depends on how well you can describe what the system should do.
How to re-run the legacy application modernization decision
Re-run the decision system by system, starting with whether agents will be able to check their own work. A rewrite has become realistic when most of these hold:
- The old system's behavior can be pinned down as tests, or you're willing to build those tests first.
- The old code is the spec. Nobody wants the new system to behave differently on day one.
- The data can move as it is, or through a mapping someone on your side can sign off.
- Someone can answer "is this a bug or a rule?" quickly, for every part of the system being moved.
Keep evolving the system slice by slice when:
- Business rules live in people's heads, or in workarounds that sit outside the code.
- The same screens keep getting product changes while they move, so a parallel rebuild would chase a moving target.
If you want the product to behave differently, the old code stops being the spec and a rewrite becomes a product rebuild. That's often the right call when the core experience no longer fits what your users expect, and it starts with product and design work, since AI saves less on translating code nobody wants to keep.
Most estates will have systems on both lists. Deciding the order across all of them is what an application modernization strategy is for, and that part hasn't gotten any easier.
Why a shelved rewrite deserves a second look
When a CTO brings us a legacy product, we assess it first and then recommend what's more cost-efficient for that product: a rewrite from scratch, or modernization piece by piece. That's how AI Product Modernization works, with one team of product managers, designers, and engineers building on Pixel AI™, our AI software development framework.
If a rewrite was ruled out two or three years ago, the reasons were probably right at the time, and some of them may not hold anymore. The question worth asking now is how much of your system someone can describe well enough for an agent to check its own work. That answer will shape the cost of your next modernization more than the size of the codebase.
Frequently asked questions
Rewriting legacy code with AI is much cheaper when the old system can serve as the spec and a test suite can check the new code. Airbnb finished a migration estimated at 1.5 years in six weeks (opens in a new tab). The cost that stays is deciding what the system should do, which still needs people who know the business rules and the data.
Neither wins by default, because AI made both cheaper. A rewrite fits when the old behavior can be pinned down as tests and nobody wants it to change on day one. Refactoring slice by slice fits when business rules are undocumented or the same screens keep shipping product updates while they move. When the behavior itself needs to change, the rewrite becomes a product rebuild that starts with product and design.
Yes, AI makes incremental modernization faster too, because the same agents that port a codebase can write characterization tests, update call sites, and convert one screen or service at a time. Each slice moves faster and stays reversible. So a cheaper rewrite doesn't win by default: the slice-by-slice route got cheaper in the same period, and the choice still depends on how well the system's behavior can be described and tested.
Legacy application modernization is updating an existing software product so it's cheaper to change, safer to run, and able to support what the business needs next. It can mean rehosting, replatforming, refactoring slice by slice, or rewriting. Most programs mix several of these across one estate, decided one system at a time.
Pixelmatters assesses the product first, from the first call and with a technical assessment when the project needs one, then recommends the more cost-efficient route: a rewrite from scratch or modernization piece by piece. The deciding questions are whether the old behavior can be tested, whether the data can move cleanly, and who on the client's side can confirm what correct looks like.
Written by

Tiago Coelho
CTO
As CTO of Pixelmatters, Tiago Coelho leads the engineering organization, wrote the handbook and quality standards it ships against, and is rebuilding delivery around AI. He writes on technology strategy and engineering leadership.