When AI meets 65-year-old code

Mainframes running COBOL still process ATM transactions, insurance claims, and government records by the billions every day. The language itself predates the internet by decades, and roughly 200 billion lines of it remain in production. The problem is not the code — it's the expertise. The developers who wrote and maintained these systems are retiring, and replacements are scarce.

Microsoft Global Black Belt Julia Kordick has been attacking this problem from an unusual angle. She never learned COBOL. Instead, she pairs GitHub Copilot and AI agents with the domain knowledge of engineers who've spent careers inside these systems. The result is a modernization workflow that treats AI as a translation layer between legacy logic and modern architecture.

Three stages of legacy modernization

Kordick's team developed a framework that breaks legacy migration work into three phases. It applies to COBOL specifically, but the pattern generalizes to any aging codebase.

Reverse engineering the codebase

Most organizations running legacy systems have lost track of what their code actually does. The software works, but nobody can explain why. Before any migration can start, that knowledge needs to be recovered.

GitHub Copilot can do much of this archaeological work:

  • Extract business logic from legacy files
  • Generate markdown documentation for human review
  • Trace call chains and dependencies automatically
  • Strip out obsolete comments and log entries
  • Add clarifying comments where context is missing
💡Pro tip: Always have human experts review AI-generated analysis. AI is incredible at pattern recognition, but domain knowledge still matters for business context.

Copilot produces analysis artifacts that can be used as the foundation for all subsequent steps.

# Business Logic Analysis Generated by GitHub Copilot
## File Inventory
- listings.cobol: List management functionality (~100 lines)
- mainframe-example.cobol: Full mainframe program (~10K lines, high complexity)

## Business Purpose
Customer account validation with balance checking
- Validates account numbers against master file
- Performs balance calculations with overdraft protection
- Generates transaction logs for audit compliance

## Dependencies Discovered
- DB2 database connections via SQLCA
- External validation service calls
- Legacy print queue system

Enrichment: making legacy code AI-readable

Raw legacy code often lacks the context AI models need to work with it effectively. Kordick's team adds that context in three ways.

Translation. Non-English comments — Danish, German, whatever the original team used — get translated to English. Models produce better analysis when operating with English context.

Structural mapping. COBOL is unusually well-suited to AI analysis because its structure is rigid and predictable. Every program follows the same four-division layout: IDENTIFICATION DIVISION for program metadata, ENVIRONMENT DIVISION for file and system configuration, DATA DIVISION for variable declarations and data structures, and PROCEDURE DIVISION for the business logic itself.

"Identify all the divisions in this COBOL file and summarize what each one does"

"List all data structures defined in the DATA DIVISION and their purpose"

"Extract the main business logic flow from the PROCEDURE DIVISION"

Prompts that ask Copilot to identify and explain these divisions yield plain-English descriptions of program behavior without requiring the user to know COBOL syntax. The structure that makes COBOL feel archaic to modern developers is exactly what makes it tractable for AI.

Documentation as source of truth. Everything Copilot generates during preparation is saved as markdown files. These become the canonical reference for all downstream work. As Kordick put it: "Everything that you let Copilot generate as a preparation, write it down as a markdown file so that it can actually reference these markdown files as source of truth."

💡Pro tip: COBOL’s verbosity is actually an advantage here. Statements like ADD TOTAL-SALES TO ANNUAL-REVENUE are almost self-documenting. Ask Copilot to extract these business rules into natural language descriptions.

Orchestrating agents for scale

Analyzing individual files is interactive work — Copilot in your IDE, one conversation at a time. To handle an entire legacy system, Kordick's team built an orchestration layer on Microsoft Semantic Kernel that coordinates multiple specialized AI agents.

  • Call chain mapping. One agent reads COBOL files, another traces CALL statements between programs, and a third renders the results as a Mermaid diagram. The output is a full system map with no manual dependency tracing.
  • Test-driven modernization. Agent one extracts business logic, agent two generates test cases that validate that logic, and agent three produces modern code that passes the tests. The tests become the safety net for migration.
  • Dependency optimization. An agent identifies third-party COBOL libraries and utilities, checks whether modern equivalents exist, and flags opportunities to simplify the migration scope.

Individual Copilot sessions are conversations. This framework is assembly-line automation: each agent does one task well, and the orchestration layer manages the flow between them.

💡Pro tip: Use Mermaid diagrams to visualize complex dependencies before making any changes. It helps you catch edge cases early. You can generate these diagrams by asking Copilot to trace all CALL statements in your codebase and output them in Mermaid syntax. Mermaid chart example:
Flowchart showing the COBOL to Java modernization agent workflow. Seven boxes connected by arrows flow top to bottom: COBOLAnalyzerAgent, DependencyMapperAgent, Business Logic Extractor, Test Generator, JavaConverterAgent, Human Validation, and Production-Ready Java Quarkus Output.

The limits of automation

Kordick is blunt about what AI cannot yet do. "Everyone who's currently promising you, 'hey, I can solve all your mainframe problems with just one click' is lying to you," she says.

Human validation remains essential at every checkpoint. Every codebase is unique, agentic AI is still an emerging field, and full automation is likely at least five years out. That does not prevent substantial progress today.

An open-source starting point

The framework Kordick's team built is available as an Azure samples repository at aka.ms/cobol. Built on Microsoft Semantic Kernel, it includes specialized agents like DependencyMapperAgent, COBOLAnalyzerAgent, and JavaConverterAgent, plus built-in checkpoints for human expert review. Cost tracking reports approximately $2-5 per 1,000 lines analyzed. A doctor.sh script handles configuration validation and testing.

To get started: fork the repository, configure an Azure OpenAI endpoint (or local models for sensitive data), run ./doctor.sh doctor to validate the environment, then ./doctor.sh run to launch the automated workflow.

# Quick setup for the impatient developer

git clone https://github.com/Azure-Samples/Legacy-Modernization-Agents

cd Legacy-Modernization-Agents

./doctor.sh setup

./doctor.sh run

Beyond technical debt

COBOL expertise is disappearing at exactly the moment it is most needed. The traditional response — hiring consultants for five-plus years of manual conversion — often leaves organizations with auto-generated code their internal teams cannot maintain in a language they never mastered.

The AI-driven approach differs in a fundamental way: it keeps the work in-house. AI extracts the business knowledge, generates readable modern code, and the customer retains full control of its intellectual property. "What a lot of customers do not want to actually give all their intellectual property like a hundred percent to a partner anymore," Kordick observed. "They want to keep it in check."

The teams doing the migration learn the business logic as they go, and the code they end up with is code their developers can actually work with.

Starting points for your own legacy system

Any codebase counts. In an industry where six-month-old code is already legacy, most organizations have no shortage of candidates.

Start small

  • Pick a single legacy system under 5,000 lines
  • Ask Copilot to analyze one file
  • Record what you learn in markdown
  • Share the findings with your team

Build experience with the tooling

  • Experiment with the Azure Samples framework
  • Practice prompts like "Analyze this COBOL program and explain its business purpose in simple terms"
  • Work through iterative modernization on small components

Keep the target architecture in view

  • Plan for cloud-native design, not just language conversion
  • Design for distributed systems from the start
  • Remember most COBOL programs perform routine CRUD operations — work that maps cleanly onto modern, simpler architectures

AI is not a replacement for developer expertise; it is an amplifier. COBOL experts supply the domain knowledge, modern developers bring architecture best practices, and AI provides pattern recognition and translation at scale. Together they turn a supposedly impossible modernization project into something achievable — and the 200 billion lines of COBOL still running the world's critical systems start to look like an addressable problem instead of a dead end.