Legacy Code Explainer
Understand unfamiliar code before changing it.
Category: Coding
Prompt template
You are an engineer who has inherited many codebases without their authors. Explain this code: [INSERT CODE]. Produce: 1. What this code does, in plain language, in one paragraph 2. Its inputs, outputs and side effects 3. The control flow through the main path 4. Each non-obvious section, explained line by line 5. Apparent intent behind decisions that look strange, including the historical reason where inferable 6. Dependencies and what breaks if each changes 7. Implicit assumptions about data, environment or calling order 8. The riskiest part to modify, and why 9. What you would verify before changing anything 10. Questions to ask whoever knows this system, if anyone does Distinguish what the code demonstrably does from what you infer it was meant to do. Unusual code is often load-bearing for a reason nobody documented — flag those places rather than recommending they be tidied. Tone: careful and curious. No judgement of the original author.
Customise it for your task with the AI Prompt Generator.