On this page
Yes, Claude can understand COBOL. It reads a single program line by line, explains what each paragraph does and can draft a translation. What it cannot do alone is see the rest of a mainframe codebase: the copybooks a program pulls in, the programs it calls, the JCL that runs it and the datasets it touches. Give Claude Code that structure first and the COBOL gets much easier to work with.
Part of the legacy code cluster.
Is Claude good at COBOL?
Claude handles COBOL the way it handles other languages: it reads the code and explains the logic. The syntax is verbose and regular, with named paragraphs, MOVE and PERFORM statements and a data division that spells out every field. That is easy text to read. Claude can summarize what a paragraph does, point out a rounding rule buried in a COMPUTE, and turn a short program into Java or Python that you then check.
We are not quoting a score here. Any single figure depends on which programs and dialect were tested, so run Claude on a program you already understand. If it explains that one correctly, you have your answer for your dialect and your style of code.
The problems start when the program is not the unit of work.
Where Claude struggles on a mainframe codebase
A COBOL program is rarely self-contained, so a model that only sees one file is missing most of the meaning. Five things sit outside the file.
| What is outside the program | Why it breaks a file-by-file read |
|---|---|
| Copybooks | A COPY CUSTREC line hides the record layout. Without the copybook, field names have no meaning. |
CALL chains | Business logic is split across programs. One screen's behavior can span a dozen of them. |
| JCL | The job decides which program runs, in what order, against which datasets. The program never says. |
Long PERFORM flow | Paragraphs jump around through PERFORM and GO TO, and a program can run to thousands of lines, so the control flow does not fit in one read. |
| Missing documentation | The comments are old, the authors have left and the real spec is the code. |
Scroll the table sideways to see every column.
None of these is a language problem. They are a context problem, and context is what tooling can supply. If you are new to this part of the stack, the overview of COBOL analysis tools covers the other products in the space.
How do I use Claude Code on a COBOL codebase?
Hand Claude Code the structure first, then work one program at a time. The order matters more than the prompt wording. The same advice applies to any large repository: choose what enters the context window instead of letting the model read until it runs out of room.
- Build the map. Get the program and copybook dependency graph, the entry points, and a list of who changed what and when. Entry points are the programs a JCL step or a CICS transaction starts.
- Pick one program. Start with an entry point or a program that many others call.
- Load its neighborhood. The program source, the copybooks it copies, the programs it calls and the JCL step that runs it. Nothing else.
- Ask for an explanation first. Paragraph by paragraph, in plain language, with the business rules called out. Check it against someone who knows the system.
- Translate only after the explanation holds up. Ask for a translation of that one program, with the copybook layouts as inputs, and diff the behavior against the original on real test data.
- Record what you learned. Write the explanation down so the next session does not start from zero.
Step 3 is where most sessions go wrong. Pasting a 4,000-line program with no copybooks produces a confident explanation of fields Claude has guessed at.
Giving Claude the structure with repowise
repowise parses COBOL source in git into a graph, and Claude Code queries that graph over MCP. The COBOL page and the language docs list what is covered. From the docs:
- Source in fixed or free reference format, with
.cbl,.cob,.coboland.cpyfiles read. COPYstatements andEXEC SQL INCLUDEresolve to the nearest copybook of that name. DB2 DCLGEN members count as copybooks.CALLbinds to a uniquePROGRAM-ID, andPERFORMbinds within its program and the copybooks it copies.- JCL steps link to the program or PROC they run, which makes that program an entry point.
- CICS
LINKandXCTLlink to a literal or constant program name. CSD definitions andTRANSIDlinks make programs entry points, and BMS mapsets link to the programs that send or receive their maps. - Paragraphs and sections are measured as functions, so the most complex paragraphs in a program stand out. The
cobol_unstructured_flowmarker flags paragraphs withALTER,GO TO ... DEPENDING ONor aGO TOthat does not jump forward to its own exit. - Git history adds hotspots and ownership, which show which programs change often and who still knows them.
Indexing needs no model and no mainframe connection:
uv tool install repowise
repowise init --yes --no-prose
repowise serve
repowise init also registers the MCP server with Claude Code. From there the questions from the workflow above become tool calls instead of file reads. Ask which programs copy a given copybook, what a JCL step runs, or who changed a program last, and the answer comes from the index with citations. --no-prose renders a documentation page per program and copybook from the parsed structure, so the missing-documentation problem has a first draft before Claude reads a line. See what the MCP protocol actually sends to Claude Code for what those calls look like on the wire.
The COBOL grammar downloads on first use. On an air-gapped machine, fetch it once with repowise grammars fetch and point REPOWISE_GRAMMAR_DIR at it.
Which programs should Claude explain first?
Start where the graph says the most depends on the least understood code. Three signals give you a short list:
- Entry points. Programs that JCL steps or CICS transactions start are where behavior begins, so their explanations anchor everything else.
- Fan-in. A program or copybook that many others call or copy is worth understanding once and reusing everywhere.
- Churn and ownership. Programs that change often, or whose only author has left, are where an explanation is worth the most. The same logic is behind finding untested hotspots in any language.
Work through the list in that order and keep each explanation. By the tenth program you are mostly confirming patterns you have already written down, and a migration plan stops being a guess.
FAQ
- Can Claude understand COBOL?
- Yes. Claude reads COBOL syntax, explains paragraphs and drafts translations to modern languages. Accuracy drops when it sees a program without its copybooks, called programs and JCL, so supply those with the program and verify the output against someone who knows the system.
- Can Claude Code convert COBOL to Java?
- Claude Code can draft a Java translation of a program you give it, and that draft is a starting point. Convert one program at a time with its copybook layouts as input, then compare behavior on real test data before trusting it. For managed conversion products, see the COBOL tools comparison.
- How do I give Claude Code a whole mainframe codebase?
- Do not paste it in. Index the repository so Claude Code can query the dependency graph, entry points and history, then load one program and its neighborhood per task. repowise does the indexing and serves it over MCP.
- Can Claude read JCL?
- Claude can read JCL text. What it lacks is the link between a job step and the program source in your repo. repowise links each JCL step to the program or PROC it runs and marks that program as an entry point, so the connection is in the graph.
- What does COBOL stand for?
- COBOL stands for Common Business-Oriented Language. It was designed for business data processing and it still runs batch and transaction systems at banks, insurers and government agencies.


