AI-powered legacy code discovery combines static analysis, runtime data and large language models to map what a legacy system contains, how its parts depend on each other, and which business rules it implements, before anyone plans a migration. Every guide in this series starts with “inventory”. This final article shows how to do that inventory faster and more reliably with AI, where AI helps and where it does not, and how to turn the results into a migration plan you can trust.
Technically reviewed by Harshita Pipaliya.
This is the twenty-fourth and final article in our Legacy Modernization Series. It follows IBM i / AS400 RPG Modernization. A full index of the series is at the end.
Executive summary
- Discovery is the riskiest gap: most migration surprises come from unknown dependencies: a shared table, a batch job, a hidden interface, a rule buried in a form event.
- Static analysis finds facts; AI explains them: parsers and dependency scanners produce the reliable graph. Large language models summarize programs, suggest business rules and answer questions over that graph.
- Vendors now ship AI discovery tools: for example, AWS made AWS Transform for mainframe and for .NET generally available in May 2025, and Microsoft documents GitHub Copilot modernization for assessing Java, .NET and C++ applications. IBM offers AI-assisted understanding for IBM Z applications.
- Evidence over eloquence: every AI finding should link back to the source lines, logs or data that support it, and be reviewed by someone who knows the system.
- Our recommendation: build a dependency graph from code, databases, jobs and runtime telemetry first; use AI to summarize and question it; validate findings with owners and tests; then plan migration waves from the graph.
- Executive summary
- Why discovery decides migration success
- What to discover
- Where AI helps and where it does not
- Tools available today
- Code patterns: a discovery pipeline
- Recommended discovery architecture
- Discovery steps
- Security and governance
- Validating AI findings
- Request an estimate
- FAQs
- Series index
- Conclusion
Why discovery decides migration success
- Hidden coupling: shared databases and files link systems that look independent.
- Dead code: large parts of old systems are unused; migrating them wastes budget.
- Lost knowledge: original authors have left; documentation is out of date or missing.
- Embedded rules: business logic sits in UI events, stored procedures, triggers, reports and batch scripts.
- Interfaces nobody owns: file drops, FTP jobs, message queues and direct database links break silently when moved.
What to discover
| Area | Questions | Typical sources |
|---|---|---|
| Inventory | What programs, projects, screens, reports and jobs exist? | Repositories, libraries, build files |
| Code dependencies | What calls what? What is shared? | Parsers, call graphs, project references |
| Data dependencies | Which code reads or writes which tables and files? | SQL parsing, database catalogues, query logs |
| Interfaces | What enters and leaves the system? | Network flows, job schedulers, queues, file transfers |
| Usage | What actually runs, how often, for whom? | Logs, APM, job history, database statistics |
| Business rules | What decisions does the code make? | Code plus AI summaries, validated by owners |
| Risk | What is complex, fragile or untested? | Complexity metrics, change history, defect data |
Where AI helps and where it does not
| Task | AI is good at | Use deterministic tools for |
|---|---|---|
| Explaining unfamiliar code | Plain-language summaries of programs and procedures | – |
| Business rule candidates | Spotting conditions, calculations and validations | Confirming exact logic and edge cases |
| Dependency graph | Suggesting likely links in dynamic code | Building the graph from parsed calls, SQL and configuration |
| Documentation | Drafting module and interface descriptions | Version-controlled generation from the graph |
| Grouping into domains | Proposing service or module boundaries | Measuring coupling and cohesion |
| Q&A over the estate | Answering questions with retrieved evidence | Keeping the source of truth in the graph |
Large language models can be confidently wrong, especially with uncommon languages and dynamic code. Treat AI output as hypotheses with evidence, not as facts.
Tools available today
| Tool type | Examples | Notes |
|---|---|---|
| Cloud vendor AI modernization services | AWS Transform (mainframe, .NET), GitHub Copilot modernization (Java, .NET, C++) | Assessment, dependency analysis, documentation and transformation help |
| Platform vendor tools | IBM AI-assisted tools for IBM Z applications | Program understanding, dependencies and documentation for COBOL and PL/I |
| Static analysis and parsers | Language-specific parsers, code graph and architecture tools | Deterministic, repeatable dependency extraction |
| Runtime telemetry | APM, database query stores, job scheduler history | Shows what actually runs |
| Custom pipelines | Parsers plus a graph database plus an LLM with retrieval | Fits mixed estates and private data rules |
Choose tools by language coverage, data residency, how findings link back to source, and whether outputs can be exported into your own graph. Vendor productivity claims vary; test on a sample of your own code before relying on them. For a .NET example of AI tooling in day-to-day modernization work, see OpenAI Codex for legacy .NET modernization.
Code patterns: a discovery pipeline
The examples below are illustrative and simplified.
1. Extract dependencies deterministically: a simple scanner for COBOL CALL and COPY statements and embedded SQL tables.
import re, pathlib, json
CALL = re.compile(r"\bCALL\s+'([A-Z0-9-]+)'", re.I)
COPY = re.compile(r"\bCOPY\s+([A-Z0-9-]+)", re.I)
TABLE = re.compile(r"\b(?:FROM|JOIN|INTO|UPDATE)\s+([A-Z0-9_.]+)", re.I)
edges = []
for f in pathlib.Path("src").rglob("*.cbl"):
text = f.read_text(errors="ignore")
prog = f.stem.upper()
edges += [(prog, "calls", c.upper()) for c in CALL.findall(text)]
edges += [(prog, "includes", c.upper()) for c in COPY.findall(text)]
edges += [(prog, "uses_table", t.upper()) for t in TABLE.findall(text)]
json.dump(edges, open("edges.json", "w"), indent=1)
2. Store the graph and query impact: which programs touch a table you plan to move?
-- edges(source, relation, target) loaded from edges.json
SELECT DISTINCT source AS program
FROM edges
WHERE relation = 'uses_table' AND target = 'CUSTMAST'
ORDER BY program;
3. Ask AI for a summary that must cite evidence: a structured output contract.
{
"program": "ACCTENQ",
"purpose": "Returns account balance and last transaction date",
"business_rules": [
{
"rule": "Accounts flagged closed return code 08",
"evidence": "ACCTENQ.cbl lines 212-219",
"confidence": "high"
}
],
"dependencies_mentioned": ["ACCTCPY", "CUSTMAST"],
"open_questions": ["Where is the closed flag set?"]
}
4. Check AI claims against the graph: flag dependencies the model mentions that the scanner did not find.
graph = {(s, t) for s, _, t in json.load(open("edges.json"))}
summary = json.load(open("acctenq_summary.json"))
unverified = [d for d in summary["dependencies_mentioned"]
if (summary["program"], d) not in graph]
print("Needs review:", unverified)
Recommended discovery architecture

- Collect: code, database schemas and query logs, job schedules, interface configuration and runtime telemetry.
- Parse: deterministic scanners produce programs, calls, data access and interfaces as graph edges.
- Store: a graph or relational store becomes the single source of truth.
- Explain: an LLM with retrieval over code and the graph drafts summaries, rule candidates and domain groupings, each with evidence links.
- Review: owners and engineers accept, correct or reject findings in a shared portal.
- Plan: migration waves, retire lists and test scope come from the validated graph.
Planning a migration and unsure what the system really does? Talk to our modernization team about an AI-assisted discovery sprint.
Discovery steps
- Scope the estate and agree what “done” looks like for discovery.
- Secure access to code, databases and logs in a controlled environment.
- Run deterministic extraction for every language and data store in scope.
- Add runtime evidence to separate live paths from dead code.
- Generate AI summaries and rule candidates with mandatory evidence links.
- Validate with owners in short review sessions; record decisions.
- Group into domains and propose migration waves based on coupling and value.
- Publish the inventory, maps and rule catalogue, and keep them updated during migration.
Security and governance
- Data residency: run AI services in regions and tenants you control; check where prompts and code are processed.
- No training on your code: confirm contract terms for model providers.
- Least privilege: read-only access to repositories and databases; no production writes.
- Secrets: scan for and redact credentials found in legacy code before sending content to any model.
- Audit: log what was analysed, by which tool, and who approved each finding.
Validating AI findings
| Check | How |
|---|---|
| Evidence present | Every finding cites files, lines, tables or logs |
| Graph agreement | AI-mentioned dependencies match the parsed graph, or are flagged |
| Owner review | Subject matter experts confirm business rules |
| Test confirmation | Characterization tests prove rule behaviour on real data |
| Sampling | Measure accuracy on a reviewed sample before scaling |
The same human-review principle applies after discovery, when AI helps write the new code. See AI-assisted software development with human review.
Request an estimate
Cost and timeline depend on your application, data and integrations, so we estimate each project individually rather than publish price ranges. Tool and cloud consumption costs are extra.
Request an estimate for your application, or read legacy application modernization cost and ROI to build the business case.
FAQs
What is AI-powered legacy code discovery?
Using static analysis, runtime data and AI models together to inventory a legacy system, map its dependencies and explain its business rules before migration.
Can AI replace static analysis tools?
No. Parsers and scanners give repeatable, complete facts. AI adds explanations and suggestions on top, and its claims should be checked against that graph.
Which legacy languages can AI tools analyse?
Coverage varies by tool. Mainstream languages such as Java, C# and COBOL are widely supported; less common languages may need custom parsers plus AI.
Is it safe to send legacy code to AI services?
It can be, with private deployments, contractual guarantees that your code is not used for training, secret redaction and access controls.
How accurate are AI-generated business rules?
Accuracy varies. Treat them as candidates, require evidence links, and confirm with owners and characterization tests.
How long does AI-assisted discovery take?
A single application often takes three to six weeks. Large mixed estates take several months.
What do we get at the end of discovery?
A validated inventory, dependency maps, a business rule catalogue, a dead-code list and a proposed migration wave plan.
Series index
| # | Legacy platform | Guide |
|---|---|---|
| 1 | Visual Basic 6 | VB6 to .NET 10 |
| 2 | VB.NET on .NET Framework | VB.NET to .NET 10 |
| 3 | Classic ASP | Classic ASP to ASP.NET Core |
| 4 | ASP.NET Web Forms | Web Forms to ASP.NET Core or Blazor |
| 5 | ASP.NET MVC 5 | MVC 5 to ASP.NET Core MVC |
| 6 | WCF | WCF to Web API and gRPC |
| 8 | SharePoint Server | SharePoint to SharePoint Online |
| 9 | InfoPath | InfoPath to Power Apps |
| 10 | SQL Server 2008/2012 | SQL Server to Azure SQL |
| 11 | DTS and SSIS | SSIS to Azure Data Factory |
| 12 | BizTalk Server | BizTalk to Azure Integration Services |
| 13 | On-premises data warehouse | Data warehouse to Microsoft Fabric |
| 14 | Java 6/7/8 | Java 8 to Java 25 |
| 15 | Apache Struts | Struts to Spring Boot |
| 16 | AngularJS | AngularJS to Angular |
| 17 | Silverlight | Silverlight to Blazor or React |
| 18 | PowerBuilder | PowerBuilder to .NET 10 |
| 19 | Visual FoxPro | Visual FoxPro to .NET and SQL Server |
| 20 | Oracle Forms and Reports | Oracle Forms migration |
| 21 | Lotus Notes and Domino | Notes to Power Platform |
| 22 | COBOL and CICS | Mainframe API integration |
| 23 | IBM i RPG | IBM i RPG modernization |
Conclusion
Every successful migration starts with knowing what you have. Build a deterministic dependency graph from code, data, jobs and telemetry, use AI to explain and question it with evidence, validate findings with owners and tests, and plan migration waves from what is proven, not assumed.
Previous in this series: IBM i / AS400 RPG Modernization. This is the final article in the series; start from the beginning with VB6 to .NET 10.
Related services: Legacy Software Modernization · Enterprise AI Integration · .NET Development · Microsoft Azure · AWS
Sources
- AWS, AWS Transform for mainframe is now generally available (May 2025)
- AWS, AWS Transform for .NET is now generally available (May 2025)
- Microsoft Learn, Analyze applications and migrate to Azure by using GitHub Copilot modernization
- Microsoft .NET Blog, Your migration’s source of truth: the modernization assessment (April 2026)
- IBM, Mainframe modernization with IBM Bob
Plan your legacy code discovery
Prominent.tech helps teams map legacy estates before migration: deterministic parsing, dependency graphs, AI summaries with evidence, and expert review, leading to a migration wave plan you can trust. Talk to our modernization team or explore our legacy software modernization services.
