Guide

Generative AI for legacy code and mainframe modernisation

What generative AI does well in legacy code and mainframe modernisation, where it fails, and a method built on tests and small steps.

By iFortis Worldwide ResearchPublished Updated 2 min read

On this page

SummaryGenerative AI helps legacy code and mainframe modernisation most with understanding and documenting old code, extracting business rules, generating tests and translating well-bounded modules. It struggles with whole-system translation, so build equivalence tests first and migrate in small steps.

Why the old code is still there

Many core systems in banking, insurance, government and logistics still run on decades-old code, much of it on mainframes. The people who wrote it have retired, documentation is thin and the business rules live only in the code. Generative AI has renewed interest in modernisation, because it can read and write code at a speed no team can match. Experience so far shows real gains and real limits. Knowing which is which decides whether a programme succeeds.

Where generative AI works well

  • Comprehension. Explaining what a program does, tracing data through jobs and files, and answering questions from engineers new to the system.
  • Documentation. Producing readable descriptions of modules, interfaces and data structures for review.
  • Business rule extraction. Pulling out the conditions and calculations buried in code, so business owners can confirm or correct them.
  • Test generation. Writing test cases from code paths and production data samples.
  • Bounded translation. Converting well-structured modules with clear inputs and outputs into a modern language, with engineers reviewing every change.

Where it struggles

Translating a whole system in one pass rarely works. Generated code may compile and still behave differently in edge cases, numeric precision or date handling. Batch scheduling, job control and the operational knowledge of how the system is run do not sit neatly in source files. Performance characteristics change when code moves platforms. And generated code that nobody understands is a new legacy problem, not a solution.

A method that holds up

  • Understand first. Use AI to map the system, its data flows and its dependencies, and validate the map with the people who run it.
  • Confirm the rules. Extract business rules and have business owners sign them off. Some will be obsolete and can be dropped.
  • Build the safety net. Create an equivalence test suite that records real inputs and outputs from the old system, so any new version can be checked against them.
  • Migrate in slices. Move one function at a time behind stable interfaces, running old and new in parallel until results match.
  • Review everything. Engineers own every merged change. AI drafts, people decide.

People and knowledge

The remaining experts on the old system are the scarcest resource. Use AI to make their time go further: let them review AI explanations rather than write documentation from scratch. Pair them with engineers who will own the new system, so knowledge moves before they leave. Mainframe modernisation AI tools are only as good as the people checking them.

Risks to manage

Source code is valuable and sometimes sensitive. Check where code is sent, whether providers retain it and whether models run in your environment. Scan generated code for security flaws and licence issues. Keep a record of which code was generated, reviewed and tested, for audit and future maintenance. Agree with the security team in advance which repositories and data samples may be shared with AI tools at all.

Measuring progress

Track functions migrated and verified, not lines translated. Watch defect rates found in parallel running, the share of business rules confirmed, and the cost of running old and new together. Retire old components as soon as the evidence allows, or the savings never arrive. For the wider approach, see enterprise modernisation and intelligent automation and AI engineering and the agentic SDLC.

All insights RSS feed

Tell us the outcome you need

The first meeting is a working session about your situation, with an engagement lead, not a sales call.

Contact us Submit an RFQ