The Deska blog
Modernizing Legacy Systems with AI Agents and Mainframe Code
Explore how to integrate AI agents and mainframe code to refactor COBOL and PL/I. A guide on technical strategies and modern developer tooling.
12 min read
Modernizing infrastructure often requires a deep dive into the relationship between autonomous AI agents and mainframe code. Large enterprises continue to run critical operations on COBOL and PL/I, languages that are robust but increasingly difficult to maintain. As the pool of experienced mainframe engineers shrinks, developers are turning to large language models and autonomous agents to bridge the knowledge gap. These tools can parse legacy syntax, suggest documentation improvements, and assist in translating business logic into modern microservices.
The Challenge of Legacy Mainframe Environments
Mainframe environments present unique obstacles for modern development workflows. Unlike contemporary web stacks, COBOL applications often lack modularity. A single program might contain thousands of lines of procedural logic with complex GO TO statements and nested PERFORM loops. Furthermore, the integration between the mainframe and modern CI/CD pipelines is frequently manual or reliant on proprietary emulators.
AI agents offer a way to automate the parsing of these monolithic files. By analyzing data divisions and procedure divisions, an agent can map out the flow of information. This visibility is essential when planning a migration or simply trying to fix a bug in a production system that has not been touched in a decade.
Technical Strategies for AI and COBOL
When working with AI agents and mainframe code, the approach differs based on the goal. If the objective is maintenance, the agent acts as an advanced linter and documenter. If the goal is migration, the agent serves as a translator.
- Code Summarization: Agents can generate natural language descriptions of complex COBOL paragraphs. This helps new developers understand the business rules embedded in the code.
- Test Case Generation: Creating unit tests for COBOL is historically difficult. Agents can analyze logic branches and suggest inputs for JCL (Job Control Language) scripts to verify code behavior.
- Refactoring Suggestions: Agents can identify dead code or redundant variables in the DATA DIVISION, helping to prune the codebase before a major update.
Integrating Modern Tooling with Mainframe Tasks
Most mainframe developers are accustomed to 3270 emulators or specialized IDE plugins. However, a more flexible workspace can improve productivity when juggling legacy code alongside modern APIs. Tools like Deska offer a different approach by providing an infinite canvas workspace where you can organize multiple tasks visually.
In a typical modernization workflow, a developer might have a terminal session connected to a mainframe host, a code editor with the COBOL source, and an AI agent panel all visible at once. Deska allows you to run coding agents such as Claude Code or Codex CLI as dedicated panels within the environment. This means you can feed snippets of mainframe code directly to the agent without switching windows constantly.
Security and Privacy in Mainframe Modernization
Mainframe data is often highly sensitive, containing financial or personal records. Sending this code to a cloud based AI requires careful consideration of data residency and security policies. Many organizations prefer a local-first approach where the primary development environment resides on the machine rather than a third party server.
Deska supports this philosophy by keeping files and sessions local. While you provide your own API keys for the AI models, the workspace itself manages the context on your hardware. For developers who need to monitor long running refactoring jobs, the mobile app provides a secure way to check progress through a direct relay without exposing internal ports to the public internet.
Comparing AI Agent Approaches
Different agents have varying strengths when dealing with legacy syntax. It is useful to run multiple agents side by side to compare their logic.
| Agent Type | Mainframe Strength | Best Use Case |
|---|---|---|
| Claude Code | High reasoning for complex logic | Refactoring nested COBOL loops |
| Codex CLI | Rapid syntax completion | Writing JCL or basic scripts |
| OpenCode | Flexibility with local models | General code documentation |
Using these agents in parallel allows a developer to verify the output of one model against another. This cross referencing is vital when the stakes involve core banking or insurance systems.
Workflow Orchestration with Ask Deska
Managing a complex workspace with dozens of panels can become overwhelming. The Ask Deska assistant can help drive the workspace through chat or voice commands. A developer can ask the assistant to open a specific set of terminals for their mainframe environment or find a specific note related to a legacy bug.
This level of orchestration allows the developer to focus on the code rather than the window management. By placing panels for source code, documentation, and agent output on a single canvas, the mental overhead of tracking legacy dependencies is significantly reduced.
FAQ
How to use AI agents for COBOL refactoring?
To refactor COBOL, you should provide the agent with the specific Procedure Division segments and the relevant Data Division definitions. Using a tool that supports side by side panels allows you to keep the original source visible while the agent generates the refactored version in a separate editor.
Are AI agents safe for banking mainframe code?
Safety depends on how the data is handled. Using a local-first workspace ensures that your environment configuration and local files stay on your machine. Always ensure you are following your organization's policy regarding the use of external LLM providers via API.
Can AI agents write JCL scripts?
Yes, AI agents are generally capable of writing and debugging Job Control Language scripts. Because JCL is highly structured and declarative, agents can often generate the necessary statements for file allocation and program execution based on your specific requirements.
Modernize Your Workflow
Effective mainframe modernization requires a balance between legacy stability and modern agility. By utilizing an environment that supports autonomous agents alongside traditional development tools, you can navigate the complexities of old codebases with greater confidence.
You can explore these capabilities by downloading the app for free. The workspace is available for Mac, Windows, and Linux. Start organizing your legacy projects today at /download.