AI-assisted legacy modernization uses AI coding agents to read, document, test and incrementally translate an old system, while engineers make every decision and review every change. In 2026 agents make the expensive groundwork cheaper: explaining code nobody remembers, mapping dependencies, writing characterisation tests and clearing upgrade toil. They do not remove the real risk, which sits in behaviour nobody documented, in data migration and in cut-over. The approach that works: assess, build a safety net of tests, move in small slices behind a strangler fig facade, migrate data with reconciliation, run old and new in parallel, then switch the old system off.
This playbook is for CTOs deciding how to modernize a system the business still runs on: a COBOL mainframe, an ageing .NET or Java monolith, a PHP application nobody wants to touch. For how coding agents change everyday delivery, see our article on AI coding agents in software projects; here we apply them to old code.
What AI changes in legacy modernization, and what it doesn't
For decades, the first months of a modernization programme went into archaeology: reading code, asking the few people who remember why it works, reconstructing data flows from batch runs and stored procedures. Budgets disappeared before a single function had moved.
AI coding agents can now read a large codebase, follow calls across modules and explain it in plain language in hours rather than weeks. That changes the economics of the early phases and makes incremental approaches, which need many tests and small mechanical changes, cheaper. It does not change where modernization programmes fail: the code was rarely the hardest part.
Cheaper with AI
- Understanding and documenting old code
- Mapping dependencies, data access and batch chains
- Writing characterisation tests and test data
- Framework and runtime upgrades, deprecated APIs
Still as hard as before
- Deciding which old behaviour the business still needs
- Cleaning and reconciling decades of data
- Cutting over without stopping operations
- Changing how people and teams work
AI makes it cheaper to understand the old system. It cannot tell you which of its behaviours the business still needs.
Legacy modernization options: the seven Rs compared
Modernization options are usually described as "R" strategies. Names and counts vary between frameworks; these seven cover the decisions you face. Decide per component, not for the whole estate: one system often gets three different answers.
| Strategy | What it means | When it fits | Main risk | Where AI helps |
|---|---|---|---|---|
| Retain | Keep it as it is, perhaps wrapped with an API | Stable, rarely changed, cheap to run | Skills and vendor support fade away | Documentation, so knowledge does not leave with people |
| Rehost | Move to new infrastructure unchanged ("lift and shift") | Data-centre exit, hardware end of life | Same code, same problems, new bill | Inventory of configuration, dependencies and infrastructure as code |
| Replatform | Small changes to run on a managed platform: containers, managed database, newer runtime | You want cloud operations without a rewrite | Hidden reliance on old runtime behaviour | Runtime upgrades and compatibility fixes |
| Refactor | Improve the internal structure without changing behaviour | The design is sound but the code is hard to change | Drifting into a rewrite without tests | Characterisation tests, mechanical refactorings, dead-code detection |
| Rearchitect | Change the architecture, for example split a monolith into modules or services | Parts must scale or change at different speeds | Distributed complexity, unclear data ownership | Dependency mapping, finding seams, generating adapters |
| Rebuild | Rewrite on a new stack, keeping the scope | Core to the business and beyond repair | Big-bang cut-over, missed behaviour | Turning old rules into specifications and tests; translating modules |
| Replace | Move to SaaS or packaged software | Commodity capability such as accounting, HR or CRM | Customisations and data that do not fit the product | Mapping customisations and data to the new product |
Add an eighth option to every assessment: retire. Usage logs often show screens, reports and batch runs nobody uses; every one you switch off is one you need not migrate.
To choose, score each component on business value and technical condition. High value, poor condition: refactor, rearchitect or rebuild incrementally. Low value, poor condition: replace or retire. High value, good condition: retain it behind an API. Rewriting the whole estate in one go is rarely right. Where a rebuild is justified, treat it as custom software development with an unusually precise specification: the old system.
Where AI genuinely helps with legacy code
Six tasks where agents earn their place, provided an engineer checks the output.
Code comprehension and documentation
Plain-language summaries per module, a glossary of domain terms, data flows and draft architecture documents, for COBOL, PL/SQL, Visual Basic or old Java. Someone who knows the system confirms them.
Characterisation and golden-master tests
Record what the system does today: feed it inputs, capture the outputs, assert that the new code produces the same. Agents write the harness and derive input cases from the branches they read. Current behaviour is captured, bugs included; that is the point.
Dependency mapping
Call graphs, which programs read and write which tables, batch chains, shared includes and copybooks, external interfaces. Cross-check the agent's map with static analysis and runtime logs; neither alone is complete.
Incremental translation
Module-by-module translation to the target language, once tests exist for the module. Ask for idiomatic target code rather than a line-by-line copy, and review it like any other code.
Upgrade toil
Framework and runtime upgrades, such as .NET Framework to current .NET, old Java to a current LTS release, or PHP 7 to 8: deprecated APIs, changed defaults, build scripts and dependency updates.
Knowledge capture
Turning conversations with the people who run the system into structured rules, open questions and test cases.
The catch is accuracy. In the Stack Overflow Developer Survey 2025, 66% of respondents named "AI solutions that are almost right, but not quite" as their biggest frustration, 45% said debugging AI-generated code is more time-consuming, and more developers distrust the accuracy of AI tools (46%) than trust it (33%). In new code, the author who knows what they meant catches "almost right". In legacy code nobody knows the right answer by heart, so the error can survive for months. Hence the rule: every AI output becomes a test that runs, code a person reviews, or documentation a person confirms.
Where AI does not remove the risk
An agent can explain what the code does. It cannot tell you whether the business still wants it to. Five risks stay with you and your partner.
| Risk | Why AI cannot settle it | What to do instead |
|---|---|---|
| Business rules nobody can confirm | The code may hold a workaround for a regulation that has changed, or a special case for a customer who left. Reading it does not reveal intent. | A rule inventory with a named owner per rule who decides: keep, change or drop |
| Data quality | Old data contains mixed encodings, magic values and orphaned records that the old code quietly tolerates | Profile the data early, agree cleansing rules, reconcile every migration run |
| Cut-over | Downtime windows, batch schedules, partner interfaces and rollback are operational decisions, not code | Rehearsals, runbooks, routing you can switch back, a tested rollback plan |
| Organisational change | Users have workarounds and downstream teams depend on old reports | Involve users early, map every report consumer, plan training and new ownership |
| Behaviour outside the repository | Scheduler settings, database triggers, configuration and manual operator steps are often not in the code the agent reads | Inventory the runtime environment and operations, not only the source code |
Mainframe and COBOL modernization with AI
COBOL estates add their own traps: shared copybooks, JCL batch chains, CICS transactions, packed-decimal arithmetic, EBCDIC data, VSAM files or Db2 tables. Agents explain COBOL well and draft useful Java or C# starting points. Decimal arithmetic is where translation goes "almost right": a different rounding mode in an interest calculation passes a casual review and fails reconciliation weeks later. Golden-master tests over real batch inputs and outputs are the only reliable check.
Decide early between translation and redesign: line-by-line translation is faster but produces Java that still reads like COBOL; redesign takes longer and gives you code your team can maintain. The target side is ordinary modern engineering; the mainframe side needs people who know the platform.
The strangler fig pattern: modernize without a big-bang rewrite
The strangler fig pattern replaces a legacy system step by step: new functionality is built in the new system, existing functions move over one at a time, and the old system is switched off once nothing depends on it. It avoids the three problems of a big-bang rewrite: the old system keeps changing while you rewrite it, the new one delivers nothing until full parity, and cut-over becomes one large, risky event.
- Put a facade in front: an API gateway, reverse proxy or interface in the code through which every call passes.
- Choose a thin slice: one capability with clear inputs and outputs, ideally one that changes often or causes pain.
- Build the slice in the new system behind the characterisation tests for that capability.
- Route a small share of traffic, or one group of users, to the new slice. Compare results; if something is wrong, switch the route back.
- Decide who owns the data. Keep old and new in sync with change data capture or events, with one source of truth per data set.
- Repeat, then remove. Delete old code once no route points to it, so the legacy system really shrinks.
AI helps at each step: finding seams in a monolith, generating adapters between old and new data models, and writing comparison tests. For batch-heavy systems, strangle by batch chain rather than by request: move one chain at a time and compare its output files.
A six-phase playbook for AI-assisted modernization
Each phase ends in a decision you can fund separately; phases 3 to 5 repeat per slice.
| Phase | What happens | AI's role | Exit criterion |
|---|---|---|---|
| 1. Assessment | Inventory, usage, value and condition scores, strategy per component, first slice and budget | Read the code, draft documentation, map dependencies | Strategy per component signed off; first slice chosen |
| 2. Safety net | Characterisation tests, CI, monitoring, test environments | Generate the test harness and input cases | Tests pass against the old system; coverage of the first slice agreed |
| 3. Incremental slices | Facade in place; slices built and switched on one by one | Translation, refactoring, upgrades, first-pass review | Per slice: tests green, live behind the routing layer |
| 4. Data migration | Profile, map, cleanse, migrate, reconcile, rehearse | Draft mappings and scripts, flag anomalies | Clean reconciliation on a rehearsal with production-size data |
| 5. Parallel run | Old and new process the same inputs; outputs are compared | Triage and group the differences | Every difference explained; the business owner signs off |
| 6. Decommission | Switch off, archive data, remove routes, end licences | Find remaining references to the old system | Old system off, archive accessible, run costs gone |
Do not skip phase 6: an old system left running "just in case" doubles the run cost and keeps every old risk alive. For an outside view of phase 1, our software consulting covers architecture and modernization assessments.
Get a legacy modernization assessment
We read your system with AI-assisted tooling and senior engineers, map dependencies and risks, recommend a strategy per component and define the first slice. You get a proposal within 24 hours of the first call.
Legacy modernization checklist
- Owners: a business owner for the system and for each slice.
- Inventory: components, interfaces, batch runs, reports and who uses them.
- Usage data: which functions are actually used, and which can be retired.
- Strategy: one of the seven Rs per component, with the reason written down.
- Rule inventory: every known business rule has an owner who can confirm or retire it.
- Safety net: characterisation tests run against the old system in CI.
- Facade: the routing layer is live before the first slice moves.
- Data: profiled, with cleansing and reconciliation rules agreed.
- Rollback: a plan for every release, tested at least once.
- Parallel run: comparison method and sign-off criteria defined upfront.
- AI policy: approved tools, data rules and review rules in writing.
- Decommission plan: data retention, archive access, licence and contract end dates.
Governing AI-generated changes
In modernization, AI output lands in systems that run billing, payroll or claims. Six rules:
Human review of every change
An engineer who understands the module reviews each AI-generated change in the normal pull-request process. Size slices to what people can review properly.
Tests are the contract
Characterisation tests are the acceptance criterion. An agent may not edit a test to make it pass without explicit sign-off; keep test changes and code changes in separate commits.
No secrets to tools
Old repositories often hold hard-coded passwords, connection strings and real customer records in test files. Clean them before any AI tool reads the code; never paste production data into a prompt.
Provider data terms
Know which AI services see your code, under which plan, whether it may be used for training, how long it is kept and where. Personal data in code or test data makes this a GDPR question too.
Prompt injection
Agents read comments, documents and tickets that can carry hidden instructions. Give them least-privilege access and never production credentials.
Measure, don't assume
Track lead time per slice, review time, escaped defects and reconciliation differences against the plan.
The OWASP Top 10 for LLM Applications lists prompt injection as the top risk (LLM01), which is why permissions belong in configuration, not in the prompt. On measurement: in a 2025 study by METR, which METR itself now describes as out of date, the speed-up developers felt with AI tools differed from what was measured. Perceived and measured gains can diverge, so measure.
If an external team will see personal data in the old system, plan for it. Kosovo, where our engineers work, is outside the EU and has no adequacy decision, so remote access to personal data needs a data processing agreement, the Standard Contractual Clauses and a transfer impact assessment; our GDPR outsourcing guide lists the steps. For a security review of the old and new systems, see our security services.
What legacy modernization costs and how to budget
No honest provider can price a modernization before seeing the system. What drives the cost:
- Size and tangle of the code: how much shares state, tables and includes, not the line count alone.
- Interfaces: every partner, file transfer and downstream report is a cut-over task.
- Existing tests: with none, the safety net is a phase of its own.
- Data volume and quality: migration and reconciliation are often the largest block.
- Access to experts: the time of people who know the system is the scarcest input.
- Constraints and parallel run: regulation, audit trails, downtime windows, and how long both systems must run.
- Strategy: rehosting costs a fraction of a rebuild, and delivers a fraction of the benefit.
AI lowers the cost of comprehension, test writing and mechanical change, not of expert time, reconciliation, parallel runs or change management. Be sceptical of any quote promising a fixed saving "from AI" before anyone has read your code.
Illustrative ranges at our published rates of €45–65 per engineer-hour, assuming 40-hour weeks: planning examples for one mid-sized application, not quotes. Licences and your own staff time come on top.
| Phase (illustrative) | Team and duration | Hours | Illustrative cost |
|---|---|---|---|
| Assessment and roadmap: inventory, dependency map, strategy per component, first slice | 2 engineers × 2 weeks | 160 h | €7,200–10,400 |
| Safety net: characterisation tests, CI, monitoring for the first area | 2 engineers × 3–4 weeks | 240–320 h | €10,800–20,800 |
| One incremental slice: build, tests, release behind the facade | 3 engineers × 4–6 weeks | 480–720 h | €21,600–46,800 |
| Data migration for that slice: mapping, scripts, reconciliation, rehearsals | 2 engineers × 3–5 weeks | 240–400 h | €10,800–26,000 |
| Parallel run and cut-over support | 2 engineers × 2–4 weeks | 160–320 h | €7,200–20,800 |
| Decommission: archive, remove routes, clean up | 1 engineer × 1–2 weeks | 40–80 h | €1,800–5,200 |
How to budget: fund the assessment on its own, since it decides whether to retain, replace or rebuild. Fund the safety net and first slice as the next decision; the first slice shows the real speed, review and reconciliation included. Budget the rest per slice on that basis, keep a reserve sized on what the assessment uncovered, and count both run costs, because the old system costs money until phase 6.
Most programmes run as time and materials with a fixed budget per slice; our guide to fixed price vs time and materials explains the trade-off. For a programme of several slices, a dedicated development team keeps the knowledge in one place; squads start from €15k a month. For a first range for your scope, use the cost estimator.
Choosing a legacy modernization partner
Six questions that separate a modernization partner from a rewrite shop:
- Do you start with an assessment, or with a rewrite proposal?
- How will you capture current behaviour before changing anything?
- Which AI tools will read our code, under which data terms, and who reviews their output?
- How do you migrate and reconcile data, and how many rehearsals do you plan?
- What is the rollback plan for each slice?
- Who owns the code, tests and documentation, and do you work in our repositories?
Our legacy modernization work covers splitting monoliths into services and upgrading outdated .NET, Java or PHP stacks step by step. Our answers: a proposal within 24 hours of the first call; NDA and IP assignment before work starts; we work in your repositories and cloud accounts, and you own the code. Engineers start about 48 hours after you approve their profiles, with a two-week trial you don't pay for if you're not satisfied and replacement at no extra cost, from Prishtina on CET/CEST, the same hours as Berlin and Paris.
Frequently asked questions
What is legacy application modernization?
Updating or replacing an old system the business still depends on so it becomes cheaper to run, safer and easier to change. Options range from retaining it, through moving, restructuring or rewriting it, to replacing it with packaged software.
Can AI rewrite a COBOL or legacy system automatically?
No. AI explains code, generates tests and drafts translations quickly, but people must confirm which rules still apply, reconcile the data and plan the cut-over. AI output is a draft that tests and reviewers must accept.
Should we refactor or rewrite?
Refactor when the design is sound but the code is hard to change; rebuild when the system is core and beyond repair. Either way, move in slices behind a strangler fig facade rather than in one big-bang release.
How long does legacy modernization take?
It depends on size, data and constraints. Illustratively, an assessment takes about two weeks and one slice a few weeks to a few months, including data migration and parallel run.
How much does legacy modernization cost?
Illustratively, at our rates of €45–65 per engineer-hour: an assessment €7,200–10,400, a safety net €10,800–20,800, and one slice with its data migration roughly €32,000–73,000. Your system, data and constraints decide the real figure.
Is it safe to give AI tools our legacy code?
Yes, with rules: approved tools under terms that exclude training, secrets and personal data removed first, least-privilege agents, and human review of every change.
Modernize your legacy system one safe slice at a time
Tell us about the system, its users and its data. We assess it, build the safety net of tests and move it step by step, with AI where it helps and senior engineers on every change.
Sources
- Stack Overflow, Developer Survey 2025, AI section: survey.stackoverflow.co/2025/ai
- METR, 10 July 2025: Measuring the impact of early-2025 AI on experienced open-source developer productivity
- OWASP: Top 10 for LLM Applications (2025)
