Legacy Code Reading Guide
Understand unfamiliar code and map its dependencies.
The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.
Help me understand this legacy code: [CODE]. What it is supposed to do: [PURPOSE]. What I know about its history: [HISTORY]. Explain it in layers: purpose in two sentences; main flow in numbered steps; inputs, outputs and side effects; data structures; external dependencies; and anything surprising. Flag dead code, duplicated logic, hidden global state and comments that disagree with the code. Return a map of functions and what calls what, a list of questions to ask the original authors, the riskiest areas to change and a minimal set of tests to write first. Mark anything you inferred rather than saw. Do not guess behaviour of code I have not pasted. Add a worked example of reading a function: restate each block in a comment-like sentence, list its inputs and outputs, and note hidden dependencies such as global variables or time. Provide a template for a notes file that records what you learned so the next reader benefits. Suggest searching the version history for the reason behind odd code, and talking to users of the feature before changing it. Keep the explanation focused on the code I pasted.
Fill in before use
Optional: type your details and the prompt above updates. Nothing is saved or sent.
Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.