how to use AI to update legacy softwareAI legacy code modernizationlegacy system patching

How to Use AI Coding Tools to Resurrect Legacy Internal Systems: A How-To Guide

Skip the SaaS replacement. Learn the step-by-step process for using AI coding tools to patch, test, and keep owned legacy systems running.

Portrait of Luis Chavez-Mattos
Edited by Luis Chavez-Mattos, Director, Product··RSS
An open, organized geometric framework representing an AI coding tool maps and lowers a new structural patch into a dense, complex block representing a legacy codebase.

How do you update legacy software with AI instead of replacing it?

You update legacy software with AI by using coding agents to read the undocumented codebase, generate tests that pin down its current behavior, then write small, verified patches and drivers instead of a full rewrite. This lets teams keep systems they already own running securely for a fraction of what a SaaS replacement or a from-scratch rebuild costs. The average global enterprise wastes more than $370 million a year failing to modernize legacy systems efficiently, and nearly $134 million of that is tied to slow, resource-intensive transformation projects alone. AI-assisted patching gives you a third option between "suffer with it" and "buy a new platform."

TL;DR

  • AI-assisted patching is a third option between suffering with the old system and buying a new platform, letting you keep software you already own running.
  • The bottleneck AI removes is that nobody understands the old code, because an agent can read and explain a 20-year-old codebase and draft tests and patches in hours instead of weeks.
  • Before changing anything, have the AI generate characterization tests that record what the system does right now, so any patch that changes behavior fails immediately.
  • Keep changes small and reviewable, and run every patch through the test suite, static analysis, and security scanning, since AI-written code gets no exemption.
  • Roll out by running the patched system alongside the old path or canarying to a small slice of traffic, and feed surprises back into the tests.
  • Patching is not right for every system, but for internal tools that mostly work, it is now cheap enough to be the sane default.

Why are teams reaching for AI instead of a new SaaS contract?

Most internal systems don't die of old age. They die of neglect, because nobody wants to touch the code. The person who understood the billing reconciliation script left four years ago. The vendor of your inventory system stopped answering emails. So the default move becomes: buy a SaaS replacement, migrate the data, retrain the team, eat the new subscription forever.

That default is expensive. Enterprises typically spend 60 to 80 percent of their IT budget just keeping existing systems alive, according to industry benchmarks reported across multiple modernization studies. For the U.S. federal government alone, ten of the most critical legacy IT systems, ranging from 8 to 51 years old, cost about $337 million a year to operate and maintain. That's money spent standing still, not money spent replacing anything.

AI coding tools change the math because they attack the actual bottleneck: nobody understands the old code, and writing characterization tests and patches by hand takes too long. A coding agent can read a 20-year-old codebase, explain what it does, draft tests that pin its current behavior, and propose a scoped patch, in hours instead of weeks. That is genuinely new. It wasn't possible three years ago at this speed or this price.

Why patch and extend instead of rebuilding?

The angle here is simple. Instead of retiring an owned system and renting its replacement, use AI to keep the owned system alive: write the missing driver so it talks to a modern API, patch the dependency that's now end-of-life, generate the test suite that lets you touch the code safely again. You are treating the software as an asset worth maintaining, not a liability to escape.

This works because AI is disproportionately good at exactly the tasks that made legacy maintenance expensive: reading undocumented code, writing tests for code that has none, and doing mechanical refactors at scale. McKinsey's research on generative AI in IT modernization found 40 to 50 percent faster modernization timelines and roughly 40 percent lower technology-debt-related costs when generative AI takes on this manual work.

What is the step-by-step process?

1. Map the system before you touch it

Before any patch goes in, point an AI coding agent at the full codebase and ask it to produce a plain-language account of what each module does, what depends on what, and where the risk lives. This is the step manual modernization projects used to burn weeks or months on. Morgan Stanley's internal tool, built on GPT models, processed nine million lines of legacy COBOL and translated it into plain-English specifications, saving an estimated 280,000 developer hours in the process. You don't need Morgan Stanley's scale to benefit from the same technique on a much smaller internal tool.

2. Pin current behavior with characterization tests

This is the step most teams skip and later regret. Before changing anything, have the AI generate characterization tests, sometimes called golden-master tests, that record what the system does right now, bugs and all. This gives you a tripwire: any patch that changes observable behavior fails a test immediately instead of failing silently in production. Writing this suite by hand for a large, undocumented module used to take weeks. AI drafts it in hours by reading the code and enumerating the branches. A human still has to review the generated tests for whether they're actually meaningful, not just padding a coverage number.

3. Write the driver or patch in small batches

Once behavior is pinned, ask the agent to write the specific thing you need: a driver that lets the old system talk to a new payment processor, a patch that swaps a deprecated library, a wrapper that exposes an internal API modern tools can call. Keep changes small and reviewable. A five-thousand-line "AI cleanup" pull request is not reviewable and is therefore not safe. A few hundred lines with a clear scope is.

4. Gate everything in CI

Every patch runs through the characterization suite, static analysis, and security scanning before it ships. AI-written code gets no exemption from these checks. This is also where dependency and framework upgrades pay off fastest: an internal Amazon team of five people used an AI agent to upgrade one thousand production Java applications from version 8 to 17 in two days, with individual upgrades averaging about 10 minutes each, compared to the two to three days per application that manual upgrades used to take.

5. Roll out incrementally and monitor

Run the patched system alongside the old path where possible, or canary the change to a small slice of traffic first. Watch error rates and behavior diffs after release, and feed anything unexpected back into the test suite so the safety net gets tighter over time. Big-bang cutovers throw away the caution the previous four steps bought you.

What does this actually save you?

The cost comparison is the reason this approach is spreading. A mid-size legacy application, in the 200,000 to 500,000 line range, typically costs $400,000 to $1.2 million and takes 8 to 18 months to migrate manually. The same scope with AI assistance runs $200,000 to $600,000 over 4 to 10 months, according to industry cost tracking. That is before you even count what a new SaaS subscription would cost every year going forward, on top of the migration bill.

Where does this fit with build vs buy?

None of this means every legacy system deserves a patch instead of a rewrite. Some systems really have run out of runway: the business logic no longer matches how the business works, or the platform is a genuine security liability nobody can insure against. But for the internal tools that mostly work, that a small number of people depend on, and whose only real problem is that nobody dares open the code, AI-assisted patching is now cheap enough to be the sane default. Teams that treat their internal software as an asset worth maintaining rather than a rental to be swapped out are the ones getting the most mileage out of this shift, because they're not starting from zero every time a vendor raises prices or a library goes end-of-life.

Figure 1
Manual vs. AI-assisted modernization: mid-size application (200K-500K lines)
ManualAI-assisted
Estimated cost and duration
01k2kCost low ($K)Cost high ($K)Timeline low (months)Timeline high (months)
Project metric
Ranges reflect industry cost tracking for AI-augmented vs. traditional legacy application migration.
Illustrative figure. Constructed for explanation, not a measured source.

How we source, write, and correct our articles. Editorial standards

Related articles

Straight to your inbox.
New pieces as they publish. No noise.