--- name: cobol-rule-extraction description: Extract business rules from legacy COBOL programs (and copybooks/JCL) into a structured, testable catalog for modernization. Use when analyzing COBOL code for rewrite or migration to Java/Spring Boot or other modern stacks. --- # COBOL business rule extraction ## Inputs to gather first - The program, every COPY member it uses, and the JCL / scheduler entry that runs it. - DB2 tables and files it reads/writes (EXEC SQL, SELECT/ASSIGN, FD). - Real sample input and expected output, if available. ## Procedure 1. Map structure: PROCEDURE DIVISION paragraphs/sections, PERFORM graph, entry/exit points, CALLed programs. 2. Map data: copybook fields with PIC clauses, REDEFINES, OCCURS DEPENDING ON, COMP-3 packed decimals, 88-level conditions. 3. Extract rules - one rule per decision. For each rule record: - Rule ID, name, plain-English description - Trigger/conditions (with 88-level names translated to meaning) - Action / calculation (keep exact rounding and truncation semantics: ROUNDED, PIC scale, COMP-3) - Data in / data out (field, table, file) - Source location (program, paragraph, line range) - Confidence (High/Medium/Low) and open questions for a SME 4. Separate business rules from technical plumbing (file handling, restart/checkpoint, abend handling). 5. Flag dead code, hard-coded values (dates, rates, codes) and duplicated logic. 6. Produce test cases (given/when/then) per rule so the modern implementation can be verified against the legacy output. ## Output A markdown or spreadsheet rule catalog + a dependency diagram (Mermaid). Never invent behavior: if the code is ambiguous, mark it as an open question.