Best prompt / agent workflow to reconstruct a complete legacy ERP knowledge base from source code A practitioner seeking to reconstruct a complete knowledge base from a decades-old IBM i (AS400) ERP — spanning RPG III, RPG IV/RPGLE, CLP/CLLE, DDS, SQLRPGLE, DB2 for i and batch jobs — was advised to extract the system's dependency map before prompting, rather than search for a single ideal prompt. The recommended approach uses DSPPGMREF with OUTPUT(*OUTFILE) to list the files and programs each program references as recorded at compile time, and DSPDBR to show which files depend on each physical file, loading both into a graph; calls through a variable program name will not resolve in DSPPGMREF. The workflow then proceeds bottom-up, with the model summarizing leaf programs first and each higher summary reading its own source plus the summaries below it, requiring a citation of the member and line for every business rule so retiring experts can verify each rule quickly. Hello, I am working on a large IBM i AS400 ERP containing: - RPG III - RPG IV / RPGLE - CLP / CLLE - DDS - SQLRPGLE - DB2 for i - Batch jobs - Several decades of accumulated business logic My objective is NOT code explanation. My objective is to reconstruct the complete knowledge of the ERP, including: - business processes - business rules - application architecture - dependencies - workflows - hidden knowledge - impact analysis - functional cartography Ideally, I would like an AI agent capable of progressively building and refining a knowledge base while analyzing additional source code. I am looking for advice regarding: 1. The best prompting strategy for Claude Opus / Sonnet. 2. The best open-source models available on Hugging Face. 3. Agentic architectures LangGraph, CrewAI, OpenHands, etc. . 4. Knowledge graph approaches. 5. RAG architectures for large legacy codebases. 6. Reverse-engineering workflows used successfully in the industry. If you had to design the ultimate prompt to reconstruct the knowledge of retiring experts from a legacy ERP, what would it look like? Thank you. I wouldn’t look for one perfect prompt. On code this size, a model guesses at links it can’t see. So get the map from the system first. DSPPGMREF with OUTPUT OUTFILE lists the files and programs each of your programs refers to, as recorded at compile time. I think calls through a variable program name won’t resolve there. DSPDBR shows which files depend on each physical file, and you can load both into a graph. Then go bottom-up. The model sums up your leaf programs first, and each higher summary reads its own source plus the summaries below it. Ask it to cite the member and line for each business rule, so your retiring experts can check every rule fast.