← Back to blog
Blog

What AI agents can and cannot do in a legacy migration

"Can't AI just rewrite this?" The honest version of that question comes up more often than you'd think. The answer is yes and no, depending on what you mean. Time to clear the fog: what AI agents can do in a legacy migration, and where they stop being useful.

What AI agents do well

Three things where agents really are better than a team doing it by hand.

1. Speed at volume. An agent reads half a million lines of code in a morning. Four people take weeks. For mapping out a legacy codebase, that's a game changer.

2. Pattern recognition. Which modules talk to which? Which validation rules repeat? Where do the same anti-patterns show up? An agent sees that structure immediately, without bias.

3. Mechanical work. Converting boilerplate, adding types, generating tests for existing behaviour, formatting code in a modern style. Tedious work AI does fluently and consistently.

That alone is worth gold in a migration. The understanding phase that used to take months now takes days.

Where AI agents don't deliver

Three places where you can't do without a human.

1. What the intent was. Code describes what happens. Not why. Why is there an exception for customers in region X here? What regulation drove that? An agent can find the exception, but not explain why it belongs there. That needs someone with domain knowledge.

2. Deciding what can be dropped. A lot of legacy code is a collection of rules that once had a reason. Some of those reasons are gone, others aren't. An agent can't decide which is which on its own, that's human work, and usually the most important work in the entire project.

3. Final responsibility for what goes live. AI agents produce code. Humans sign off on production. When there's an audit, a bug, or a compliance question, there's always a human on the other end of the line.

How we use agents in practice

In the order it actually happens in our projects.

Phase 1: Inventory

Agents read the codebase, map out modules, identify patterns. Output: a report a human reads and validates. No rewriting yet, just understanding.

Phase 2: Locking in behaviour with tests

Before we touch anything, agents capture the existing behaviour in tests. Sometimes tests already exist, more often not. Those tests become the source of truth: new code only ships once it makes them green.

Phase 3: Modular rewrites

Module by module, with human review on every pull request. An agent proposes; an engineer reviews, adjusts, accepts. Like working with a junior colleague, just much faster.

Phase 4: Comparison on real data

Old and new run side by side. We compare outcomes on production-like data. A module is only "done" once they provably match (within margins you've accepted).

The golden rule

AI accelerates. Humans decide. Always.

Not because we distrust the technology, we work with it every day, but because the risks of business-critical software are too high for "looks fine to me". An agent shipping straight to production is an accident waiting to happen. An agent that makes an experienced engineer 4× faster is a serious accelerator.

Want to know what that means for your situation? Book a no-obligation intro call. We'll show you, on one module of your system, what agents actually do for us, and where our people take over.