Legacy system modernization with AI: map it, then replace it in slices

Modernizing a legacy system with AI rarely means a big-bang rewrite. Start by mapping what the system really does, using AI to help read and document old code. Then replace it in small slices behind a stable interface while old and new run side by side. AI speeds up the code changes; people still review every one.

Why big-bang rewrites fail

Martin Fowler writes that the simple-sounding plan of building a new system that does exactly what the old one does has, in his experience, gone "down in flames most of the time". Replacements take a long time, users can't wait for new features, and the details of existing behavior are hard to pin down (https://martinfowler.com/bliki/StranglerFigApplication.html).

Joel Spolsky made the same point in 2000 about Netscape's decision to rewrite its browser from scratch: old code carries years of bug fixes, and throwing it away throws that knowledge away (https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/).

Replace it in slices instead

Fowler's alternative is gradual: build new pieces alongside the legacy code and move behavior across a bit at a time, so the business gets value earlier and learns as it goes. He calls this the Strangler Fig approach (https://martinfowler.com/bliki/StranglerFigApplication.html).

Microsoft's Azure Architecture Center describes the same pattern in practice: a facade sits in front of the old system, routes each request to either the old or the new code, shifts more traffic to the new code with each step, and the old system is retired once nothing depends on it (https://learn.microsoft.com/en-us/azure/architecture/patterns/strangler-fig).

It isn't always the right fit. Microsoft notes it may not suit a small system that is simple to replace whole, or a system whose requests can't be intercepted (https://learn.microsoft.com/en-us/azure/architecture/patterns/strangler-fig).

What AI actually helps with

Google published an experience report on using large language models (LLMs) for its own internal code migrations. It found LLMs can cut migration time significantly, but simple prompting alone wasn't enough for anything beyond the simplest migrations. Google combined the model with traditional code-analysis tools, automatic builds and tests, and normal human code review (https://arxiv.org/abs/2501.06972).

In one migration, engineers estimated total time fell by about 50% compared with a similar job done without LLMs, counting review and rollout. In another, the bottleneck was how fast engineers could review the changes (https://arxiv.org/abs/2501.06972).

In our experience the useful jobs for AI are reading and summarizing old code, drafting tests that pin down what the system does today, and making repetitive changes. It does not decide which features the business still needs.

A practical order

  1. Agree the outcome. Write down what modernizing should achieve, such as faster releases, lower hosting cost or retiring an unsupported platform.
  2. Map what the system does. Use AI to summarize modules and data flows, then have people who know the business confirm or correct it.
  3. Pin current behavior with tests. Tests on today's behavior show whether a new slice really matches the old one.
  4. Put a facade in front. Route traffic through one layer so each slice can switch over, and back, without users noticing.
  5. Move one slice at a time. Start with a piece that is valuable and low risk, then repeat.
  6. Retire as you go. Switch off old code once nothing calls it, so you don't run two systems forever.

Where we come in

A fractional CTO keeps the plan, the risks and the budget honest so the business doesn't stall mid-migration. See fractional CTO services, technical debt reduction, technical due diligence and signs you need a fractional CTO.

FAQ

Should we rewrite or refactor a legacy system?

Usually neither all at once. Replace it in slices, keeping the old system running, so you keep shipping and don't lose behavior nobody wrote down.

Can AI convert old code safely?

It can draft changes quickly, but only safely with automatic builds, tests and a person reviewing every change before it ships.

What is the strangler fig pattern?

A way to replace a system gradually: route requests through a facade, move features to new code one at a time, then retire the old system.

How long does legacy modernization take?

It depends on the system's size and how tangled it is. Working in slices means the business sees value from the first slice, not only at the end.

Do we have to stop new feature work?

No. New features can be built in the new code while the old system keeps running. That is the main reason to work in slices.

Who is CTO.LA?

CTO.LA is a technology and AI consulting firm in Beverly Hills, California, founded in 2025. Reach us at hello@cto.la.

Sources

Book a call