Engineering · 10 min read
AI Legacy Code Modernization: What Coding Agents Change for COBOL, Old .NET and PHP
Where AI coding agents speed up legacy modernization (code reading, docs, tests, translation), where they do not, and a safe plan for COBOL and .NET.

Short answer
AI coding agents make the most expensive part of legacy modernization cheaper: reading code nobody understands, mapping dependencies, writing documentation and characterisation tests. They do not remove the need to migrate in slices, verify behaviour against the old system, or have engineers decide what the business rules should be. Use them to shorten discovery and test-writing, then modernize module by module with the old system running.
Why legacy modernization stalls
Most legacy projects do not fail on the new code. They fail on understanding the old code. Systems written in COBOL, VB6, .NET Framework, early PHP or AngularJS have been changed for decades by people who have since left. The documentation describes a system that no longer exists. The business rules live in the code, sometimes in a single function of a thousand lines, and nobody can say with confidence what will break if it changes.
That is why so many modernization plans start with months of analysis by expensive specialists, and why so many are postponed. The analysis costs more than anyone wants to pay before seeing any new software.
What AI coding agents change
Coding agents such as Claude Code, Codex and Cursor can read an entire repository, follow calls across files and write structured output. That makes them well suited to the discovery work that used to dominate the budget.
Anthropic makes the strongest version of this argument in a February 2026 post on COBOL. It says Claude Code can map dependencies, document forgotten workflows and identify risks, and that with AI "teams can modernize their COBOL codebase in quarters instead of years". It also notes that COBOL is taught at only a handful of universities. Treat that as a vendor's claim about its own product: plausible for the analysis phase, unproven as a general timeline, and dependent on how much of the work is analysis versus migration and testing in your system.
| Modernization task | What an agent does well | What still needs an engineer |
|---|---|---|
| Code reading and inventory | Lists programs, entry points, call chains, shared files and database tables across thousands of files | Deciding which findings matter to the business |
| Documentation | Writes module summaries, data-flow descriptions and diagrams from the code | Checking them against how the business actually uses the system |
| Characterisation tests | Drafts tests that pin down current behaviour, including edge cases found in the code | Choosing realistic inputs and confirming that 'current behaviour' is not a bug |
| Translation (COBOL to Java, VB6 or WebForms to C# or TypeScript) | Produces a first draft quickly, module by module | Idiomatic design, performance, and proof that outputs match the old system |
| Refactoring | Splits large functions, renames, removes dead code under test | Architecture: service boundaries, data ownership, what to retire |
| Data migration | Writes mapping scripts and reconciliation queries | Cut-over plan, rollback, and sign-off on reconciled totals |
A safe plan for AI-assisted modernization
- Secure the environment. Agents run against a copy of the code in an environment you control, under commercial terms that do not allow training on your code. No production credentials, no customer data in prompts. For client work we agree this in writing first; see how we use Claude Code on client projects.
- Map the system with the agent, then review the map with the people who run it. The output is a module inventory, a dependency graph, the data each module owns and a list of risks.
- Pick the first slice. Choose a module with few dependencies and clear business value, not the scariest one.
- Write characterisation tests for that slice before changing anything. The agent drafts them; engineers choose the inputs, including real anonymised cases.
- Build the replacement beside the old module. Route a share of traffic or a set of users to it, or run both and compare outputs.
- Compare, then switch. When outputs match on real traffic for an agreed period, move the slice over and keep the old path available for rollback.
- Repeat, and retire what is no longer called.
This is the strangler pattern, and it predates AI. What changes is the cost of steps 2 and 4, which used to be the slowest. The pattern itself is what keeps the business running while the system is replaced.
COBOL, old .NET and PHP: what differs
COBOL on mainframes
The code is often the smaller problem. Batch schedules, JCL, copybooks, file formats such as EBCDIC and packed decimals, and the data held in VSAM or DB2 all have to be understood and migrated. Agents help read all of it. Exact numeric behaviour (rounding, overflow, fixed-point arithmetic) must be verified with tests on real records, because a translation that looks right can still change a total by a cent.
.NET Framework, WebForms and VB6
Moving to modern .NET is usually incremental: shared libraries first, then services, then the user interface. Agents are good at the mechanical parts, such as updating APIs that changed between versions and converting WebForms pages, provided each step is covered by tests. Windows-only dependencies (COM components, specific IIS features) need an engineer's decision early.
Old PHP and AngularJS
These systems are often less documented but easier to run locally, which suits agent-driven discovery. The usual route is an API in front of the existing database, then a new front end page by page. Agents speed up writing the API layer and the tests that prove each page behaves the same.
Risks to plan for
- Confident but wrong documentation. An agent's summary reads well even when it is mistaken. Every important claim about the old system is checked against code, data or a person who knows.
- Translated code that passes weak tests. If the tests only cover the happy path, a translation can pass and still be wrong. Invest in characterisation tests with real cases.
- Data sent where it should not go. Keep customer data out of prompts and use providers and settings your compliance team has approved.
- A rewrite by stealth. Fast translation makes it tempting to convert everything at once. Big-bang cut-overs are still the riskiest route; keep migrating in slices.
How we approach it
We modernize the way we rebuilt Paint Nite's events platform. That system had grown since 2014 into roughly 36 repositories and close to 29,600 commits, covering booking, a nine-processor checkout, tax handling in three countries and search. Five engineers built the new platform beside it, with dedicated sync services keeping the two aligned, so features moved over in slices while tickets kept selling. The legacy checkout lived in one function of about 1,200 lines; it became a six-stage pipeline with idempotent payments and 754 automated test files on every pull request.
Our legacy modernization work starts with an assessment ($5k to $15k) that produces the module map, risk list and migration plan, with coding agents doing much of the reading. Full modernization projects typically run $40k to $150k+, depending on the size of the system and how much of it is replaced rather than retired. If the system is smaller and the main problem is that the original team has gone, codebase takeover may be the better starting point.
Sources
- Anthropic (vendor), COBOL Modernization with AI: Breaking the Cost Barrier, 23 February 2026: https://claude.com/blog/how-ai-helps-break-cost-barrier-cobol-modernization
- Paint Nite case study: https://www.innovation-insight.com/case-studies/paint-nite
Need a number for your project?
Send a short brief and get a written estimate.
A senior engineer replies within one business day. No sales call required.

Zain Khalid Malik
CTO & Co-founder, Innovation Insight
Zain owns architecture, engineering standards and the platform team at Innovation Insight. He sets the bar for code quality, security and the tooling every squad ships with.
LinkedInRelated questions.
Can AI convert COBOL to Java?
Coding agents can produce a first draft of COBOL translated to Java quickly, module by module. The draft still needs engineers to design it properly and characterisation tests on real records to prove it behaves exactly like the original, especially for numeric rounding and file formats.
How much faster is AI-assisted legacy modernization?
The biggest savings are in discovery and test-writing, which used to take months. Anthropic claims modernization in quarters instead of years for COBOL; treat that as a vendor claim. Migration, verification and cut-over still take engineering time.
Is it safe to give legacy code to an AI tool?
It can be, under commercial terms that exclude training on your code, in an environment you control, and with no production credentials or customer data in prompts. Agree the rules in writing before any code is shared.
Should we rewrite the legacy system with AI in one go?
No. Faster translation does not make big-bang cut-overs safer. Replace the system in slices beside the old one, compare outputs on real traffic and switch each slice when it matches.
How much does legacy modernization cost?
With us, an assessment costs $5k to $15k and full modernization projects typically run $40k to $150k+, depending on size and how much is replaced rather than retired.