Insights & Blog

AI-Powered Legacy Code Discovery: Mapping Dependencies Before Application Migration

Most migration surprises are unknown dependencies. Map them first with parsers, a dependency graph and AI summaries backed by evidence.

By Hetal KSoftware Architecture, .NET & APIs

A legacy source inventory with COBOL, JCL, RPG, VB6, ASP, PL/SQL and SSIS items, a dependency scan table with unknown owners and documentation, and a COBOL snippet with COPY, CALL and EXEC SQL, flowing through parse to graph, AI with evidence and expert review into a dependency graph, summaries with evidence, expert review and a migration wave plan, with a JSON finding that cites its source line

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.

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

AreaQuestionsTypical sources
InventoryWhat programs, projects, screens, reports and jobs exist?Repositories, libraries, build files
Code dependenciesWhat calls what? What is shared?Parsers, call graphs, project references
Data dependenciesWhich code reads or writes which tables and files?SQL parsing, database catalogues, query logs
InterfacesWhat enters and leaves the system?Network flows, job schedulers, queues, file transfers
UsageWhat actually runs, how often, for whom?Logs, APM, job history, database statistics
Business rulesWhat decisions does the code make?Code plus AI summaries, validated by owners
RiskWhat is complex, fragile or untested?Complexity metrics, change history, defect data

Where AI helps and where it does not

TaskAI is good atUse deterministic tools for
Explaining unfamiliar codePlain-language summaries of programs and procedures–
Business rule candidatesSpotting conditions, calculations and validationsConfirming exact logic and edge cases
Dependency graphSuggesting likely links in dynamic codeBuilding the graph from parsed calls, SQL and configuration
DocumentationDrafting module and interface descriptionsVersion-controlled generation from the graph
Grouping into domainsProposing service or module boundariesMeasuring coupling and cohesion
Q&A over the estateAnswering questions with retrieved evidenceKeeping 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 typeExamplesNotes
Cloud vendor AI modernization servicesAWS Transform (mainframe, .NET), GitHub Copilot modernization (Java, .NET, C++)Assessment, dependency analysis, documentation and transformation help
Platform vendor toolsIBM AI-assisted tools for IBM Z applicationsProgram understanding, dependencies and documentation for COBOL and PL/I
Static analysis and parsersLanguage-specific parsers, code graph and architecture toolsDeterministic, repeatable dependency extraction
Runtime telemetryAPM, database query stores, job scheduler historyShows what actually runs
Custom pipelinesParsers plus a graph database plus an LLM with retrievalFits 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)
AI-powered legacy code discovery architecture: source repositories, database catalogues, job schedulers, interface configurations and runtime telemetry feed deterministic parsers and scanners that build a dependency graph in a graph store; a large language model with retrieval over code and the graph produces program summaries, business rule candidates and domain proposals with evidence links; subject matter experts review findings in a discovery portal; outputs are a validated inventory, dependency maps, rule catalogue and migration wave plan; all running in a private environment with access controls and no training on customer code
  1. Collect: code, database schemas and query logs, job schedules, interface configuration and runtime telemetry.
  2. Parse: deterministic scanners produce programs, calls, data access and interfaces as graph edges.
  3. Store: a graph or relational store becomes the single source of truth.
  4. Explain: an LLM with retrieval over code and the graph drafts summaries, rule candidates and domain groupings, each with evidence links.
  5. Review: owners and engineers accept, correct or reject findings in a shared portal.
  6. 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

  1. Scope the estate and agree what “done” looks like for discovery.
  2. Secure access to code, databases and logs in a controlled environment.
  3. Run deterministic extraction for every language and data store in scope.
  4. Add runtime evidence to separate live paths from dead code.
  5. Generate AI summaries and rule candidates with mandatory evidence links.
  6. Validate with owners in short review sessions; record decisions.
  7. Group into domains and propose migration waves based on coupling and value.
  8. 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

CheckHow
Evidence presentEvery finding cites files, lines, tables or logs
Graph agreementAI-mentioned dependencies match the parsed graph, or are flagged
Owner reviewSubject matter experts confirm business rules
Test confirmationCharacterization tests prove rule behaviour on real data
SamplingMeasure 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 platformGuide
1Visual Basic 6VB6 to .NET 10
2VB.NET on .NET FrameworkVB.NET to .NET 10
3Classic ASPClassic ASP to ASP.NET Core
4ASP.NET Web FormsWeb Forms to ASP.NET Core or Blazor
5ASP.NET MVC 5MVC 5 to ASP.NET Core MVC
6WCFWCF to Web API and gRPC
8SharePoint ServerSharePoint to SharePoint Online
9InfoPathInfoPath to Power Apps
10SQL Server 2008/2012SQL Server to Azure SQL
11DTS and SSISSSIS to Azure Data Factory
12BizTalk ServerBizTalk to Azure Integration Services
13On-premises data warehouseData warehouse to Microsoft Fabric
14Java 6/7/8Java 8 to Java 25
15Apache StrutsStruts to Spring Boot
16AngularJSAngularJS to Angular
17SilverlightSilverlight to Blazor or React
18PowerBuilderPowerBuilder to .NET 10
19Visual FoxProVisual FoxPro to .NET and SQL Server
20Oracle Forms and ReportsOracle Forms migration
21Lotus Notes and DominoNotes to Power Platform
22COBOL and CICSMainframe API integration
23IBM i RPGIBM 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

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.

From insight to implementation

Turn these ideas into a practical plan

Discuss how the ideas in this article apply to your business, systems and data. We’ll help you identify a focused first step.