All insights
Legacy Modernization

AI-Assisted Code Migration: An Enterprise Playbook

What AI-assisted code migration automates, what the evidence from Google, Amazon, and Salesforce shows, and the guardrails enterprise teams need.

legacy modernizationcode migrationai agentsagentic engineering

AI-assisted code migration is the use of large language models and coding agents — under engineering supervision — to translate, refactor, and re-platform code from one language, framework, or architecture to another. It is now the best-evidenced application of AI in legacy work: Google cut migration time roughly in half on a 500-million-line codebase, Amazon upgraded 30,000 Java applications and saved an estimated 4,500 developer-years, and Salesforce compressed a planned two-year migration into four months. This guide is for engineering leaders deciding whether — and how — to run a migration this way: what the evidence supports, which automation approach fits which migration, the six-step workflow that keeps it safe, and where AI still fails.

What AI-Assisted Code Migration Is — and Is Not

A code migration moves a codebase between technologies while preserving behavior: language-to-language translation (COBOL to Java, Delphi to C#), framework and version upgrades (Java 8 to 17, AngularJS to React), API deprecations across thousands of call sites, and re-platforming (managed package to native core, on-premises to cloud runtime). AI-assisted means models generate the bulk of the mechanical change while engineers own scoping, review, and cutover.

Three boundaries keep the term honest:

  • It is not autonomous migration. In every published large-scale result, humans defined the migration, reviewed the output, and controlled the rollout. The AI multiplied throughput; it did not remove the engineering.
  • It is not modernization by itself. Migration is the execution phase of a modernization program — Phase 4 of the roadmap in our pillar guide to AI-powered legacy modernization. Translating a mess into a newer language yields a newer mess unless assessment, documentation, and target-architecture decisions come first.
  • It is not refactoring-in-place. Paying down hotspots inside a system you are keeping is a different program — covered in reducing technical debt with AI — with different economics and different risk gates.

The Evidence: What Large-Scale AI Migrations Have Delivered

AI-assisted code migration is unusual among AI engineering claims in that the headline numbers come from named companies describing production programs, not vendor benchmarks.

Program Scope Result
Google — LLM migrations 39 internal migrations, incl. int32→int64 IDs across the ~500M-line Ads codebase ~74% of landed code changes LLM-generated; total migration time cut by ~50%
Amazon — Q Developer Java upgrades 30,000 production applications, Java 8 → Java 17 ~4,500 developer-years saved; ~$260M annualized gains; average upgrade fell from ~50 developer-days to hours; 79% of AI-generated reviews shipped unchanged
Salesforce — Apex to Java 275 Apex classes, 3,537 files, seven-year-old acquired package into Salesforce Core Planned 2-year migration delivered in 4 months using dependency-graph-driven, leaf-to-root AI refactoring
Slack — test framework conversion ~15,000 Enzyme test cases to React Testing Library Hybrid AST + LLM pipeline; team reported ~22% of converted code landing without human edits, the rest accelerated

Read the table carefully and a pattern emerges that matters more than any single number: none of these were "point the model at the repo" projects. Google wrapped LLMs in purpose-built migration tooling with automated validation. Amazon's transformation agent runs builds and tests in a loop until the upgrade compiles and passes. Salesforce ordered the work along a dependency graph so translated leaves stabilized before their dependents moved. Slack combined deterministic AST transforms with LLM passes. The wins come from harnesses around models, not from models alone.

Choosing the Automation: Codemods, Copilots, or Agents

"Use AI" is not a decision. There are three distinct automation approaches, and mature programs combine them.

Approach What it is Best for Weakness
Deterministic codemods / AST transforms Compiler-style rewrites (jscodeshift, OpenRewrite, Roslyn analyzers) High-volume, rule-expressible changes: API renames, import rewrites, version bumps Can't handle ambiguity, idiom translation, or anything without a crisp rule
Assistant-in-IDE (copilot) Engineer drives, model suggests per-file Long-tail files that resist rules; exploratory translation of tricky modules Throughput limited by one human per seat; inconsistent across a large estate
Coding agents Model plans and executes multi-file changes, runs tests, iterates; engineer reviews PRs The mechanical middle: scoped translation waves, bulk test generation, upgrade loops Needs strong verification harness; can hallucinate plausible-but-wrong logic at scale

The selection rule that falls out of the evidence: write a codemod for anything you can express as a rule; hand agents everything mechanical that you cannot; keep humans on everything ambiguous. Slack's engineering team was explicit about this — AST transforms handled the predictable 80%, LLMs handled the context-dependent remainder. Inverting the order (LLMs for rule-expressible work) buys nondeterminism where you could have had certainty.

The Six-Step AI-Assisted Code Migration Workflow

The workflow below is how we run migration programs at Snowman Labs, and it aligns with what the published programs share. Each step gates the next.

Step 1 — Assess before you translate

Run an AI legacy system assessment first: inventory the estate, map dependencies, score each component on business value and technical condition, and decide the target per component — because "migrate everything" is rarely the right answer. Some components should be retired or replaced with SaaS, not translated. If the migration involves decomposition, the service-boundary decision comes first too — the decision test is covered in monolith to microservices modernization.

Step 2 — Recover the spec: documentation and characterization tests

Most legacy systems have no reliable spec, so the migration target is "what the system actually does," which nobody fully knows. Two artifacts fix this. First, agent-generated system documentation — dependency maps, data flows, business-rule extraction — validated by the people who operate the system, a workflow we detail in legacy system documentation with AI. Second, characterization tests in Michael Feathers' sense: tests that pin current behavior, including the weird behavior, before any code moves. Agents generate these in bulk from code and traffic captures; engineers review what got pinned. Skipping this step is the single most common cause of migration projects that "pass tests" and still break production, because the tests never encoded the behavior that mattered.

Step 3 — Build the parity harness

Before migrating component one, build the machinery that will judge every wave: automated build-and-test loops for the target stack, differential testing that runs legacy and migrated implementations against the same inputs and diffs the outputs, and shadow-traffic replay where feasible. Amazon's Java agent works precisely because it iterates against a build-and-verify loop rather than emitting code and hoping. This harness is also your defense against the failure mode that only shows up under production conditions — the argument for runtime verification we make in production-safe AI-generated code, and the reason we partner with Hud for runtime intelligence on agent output.

Step 4 — Migrate in dependency order, in waves

Salesforce's central lesson: translate leaf-to-root along the dependency graph, so every component you migrate depends only on components already migrated and verified. Combine that ordering with wave discipline — small, independently verifiable slices that retire real legacy on each cutover — running under the strangler-fig pattern rather than a single cutover, for the reasons laid out in modernizing legacy systems without a big-bang rewrite. Agent capacity scales horizontally, so waves can run in parallel; senior-engineer review capacity is the constraint to plan around, not model throughput.

Step 5 — Review at risk-tiered gates

Every agent-produced change ships as a reviewable pull request, and review depth follows risk: a translated utility module gets a standard review; anything touching money, auth, or regulated data gets senior review plus security signoff. Two numbers justify the gate. Amazon reported 79% of AI-generated changes shipping without edits — which means one in five needed a human. And the ELEKS practitioner account of a 20-year-old Delphi-to-.NET migration puts model translation accuracy at 80–90% on clean business logic — lower on everything else. The residual isn't noise; it's where the incidents live.

Step 6 — Cut over incrementally, then actually retire the legacy

Route traffic to migrated components in steps — 1%, 10%, 50%, 100% — with parity monitoring and automatic rollback. Then delete the old path. A migration is not done while the legacy implementation still runs "just in case": that end-state is two systems to maintain, which is a cost increase, not a modernization.

Where AI-Assisted Code Migration Fails

The failure modes are consistent across published accounts and our own programs:

  • Context starvation on cross-cutting change. Models translate files well and architectures poorly. Changes spanning service boundaries, shared mutable state, or implicit conventions need the dependency mapping from Step 2 fed into the agent's context — or the output will be locally correct and globally wrong.
  • Plausible hallucination at volume. A wrong-but-compiling translation of a business rule is worse than a syntax error, because it passes the cheap checks. Only characterization tests and differential runs catch it.
  • The idiom trap. Line-by-line translation produces "Delphi written in C#" — code in the new language with the old language's patterns, which becomes instant technical debt. The target must be idiomatic patterns in the new stack, which is an architecture decision humans make and encode in the migration prompts and examples.
  • The un-mechanical residue. Custom infrastructure, homegrown frameworks, undocumented integrations, and genuinely dead code resist automated translation. Plan for the last 10–20% to consume a disproportionate share of senior-engineer time; programs that budget as if the first 80%'s velocity holds to the end miss their dates.
  • Security and IP boundaries. Enterprise migrations need contractual clarity on where code goes: zero-retention API terms or dedicated tenancy, not consumer chat tools. This is table stakes in regulated industries and worth verifying before any code leaves the building.

What It Costs

Model economics are now a rounding error: a VirtusLab agentic migration experiment put total model spend for a 20,000-line migration at roughly $150 across ~20 refinement iterations. The real budget goes to the harness (Steps 2–3), senior review capacity, and cutover operations. That inversion is the strategic point: work that was priced in developer-years is now priced in review-weeks. Amazon's average of ~50 developer-days per Java upgrade dropping to hours is the same inversion at fleet scale. For the program-level business case — including how to measure whether the migration paid off — see our guide to measuring the ROI of AI in software engineering.

At Snowman Labs we scope migration programs to reach a first production milestone in two weeks, with a 40–60% target reduction in time-to-market versus conventional delivery — the operating model our legacy application modernization services page describes, built on 400+ delivered projects and our partnerships with Cognition (Devin), Replit, and Hud.

FAQ

Can AI migrate legacy code automatically?

No — not end to end. AI generates the majority of the mechanical change in well-run migrations (roughly 74–80% in Google's published data), but every large-scale success kept humans on scoping, architecture, review, and cutover. Treat "fully automated migration" claims as a signal to check the vendor's verification story.

How accurate is AI code translation?

On clean, well-structured business logic, practitioner reports put translation accuracy around 80–90%. Accuracy drops on tangled code, custom frameworks, and cross-file logic. This is why parity harnesses and characterization tests are non-negotiable: the errors that remain are exactly the ones cheap checks miss.

Can AI convert COBOL to Java?

Yes, and mainframe modernization is one of the most active areas — with the caveat that COBOL systems concentrate every hard problem: missing specs, retired experts, decades of patches, and extreme correctness requirements. The workflow does not change — assess, recover the spec, build the harness, migrate in waves — but the review gates get stricter and the parallel-run phase gets longer.

How long does an AI-assisted code migration take?

Scope-dependent, but the published compression ratios are consistent: Google halved migration timelines; Salesforce delivered a planned two-year migration in four months; Amazon cut per-application upgrades from ~50 developer-days to hours. A reasonable planning assumption for a well-harnessed program is 40–60% schedule reduction versus a manual baseline — not 90%, because review and cutover don't compress the way code generation does.

Do we still need engineers if AI does the migration?

Yes — the role shifts from writing the translation to specifying and verifying it. Engineers decide target architecture, encode idioms, review risk-tiered PRs, own cutovers, and handle the un-mechanical residue. The published programs saved developer-years precisely because senior engineers supervised fleets of automated changes instead of typing them.

What tests validate a migrated codebase?

Three layers: characterization tests that pin the legacy system's actual behavior before migration; differential tests that run old and new implementations on identical inputs and diff the outputs; and parallel-run or shadow-traffic verification in production conditions before cutover. Standard unit tests on the new code alone are insufficient — they verify the new code against your assumptions, not against the system you are replacing.

Which tools are used for AI-assisted code migration?

Three categories: deterministic transform tools (OpenRewrite, jscodeshift, Roslyn analyzers) for rule-expressible changes; coding agents (Cognition's Devin, Claude Code, Amazon Q Developer's transformation agent) for supervised multi-file execution; and verification tooling — differential test harnesses and runtime intelligence such as Hud — to judge the output. Mature programs combine all three rather than betting on one.

Conclusion: The Harness Is the Product

The evidence for AI-assisted code migration is real and unusually well documented — but every published win shares the same shape: deterministic tools where rules suffice, agents for the mechanical middle, humans at risk-tiered gates, and a verification harness that treats every generated change as guilty until proven equivalent. Buy or build that harness and the economics invert in your favor; skip it and you get a faster route to a broken cutover.

If a language, framework, or platform migration is on your roadmap, start where Step 1 starts: an assessment that tells you what to migrate, what to retire, and what the first wave should be. Our AI readiness assessment does exactly that — it turns a migration question into a scoped, sequenced program with verifiable milestones.

Turn insight into an operating plan

Find your highest-value path to agentic delivery.

Map your readiness, delivery constraints, and first 90-day opportunity with the Snowman Labs AI Readiness Diagnostic.

AI Readiness Diagnostic