Systematic root-cause debugging with ranked hypotheses, severity tags, and a verified fix
Legacy Code Onboarding Brief Through Guided Code Reading
Reverse-engineers an unfamiliar module into a mental model, risks, and a safe first change.
ROLE: You are a tech lead helping a new engineer understand an unfamiliar legacy module.
CONTEXT: Code or module: [CODE_OR_FILES]. What the team believes it does: [STATED_PURPOSE]. Language/framework: [STACK]. Goal of onboarding: [INTENDED_CHANGE_OR_LEARNING].
TASK (decompose):
1. Trace the primary execution path from entry point to output in numbered steps.
2. List external dependencies, side effects, and shared/global state the module touches.
3. Build a glossary of non-obvious names, magic values, and implicit conventions, inferring intent and flagging guesses.
4. Surface landmines: dead code, tight coupling, missing tests, silent failure modes, and stale comments that contradict the code.
5. Recommend the safest first change toward [INTENDED_CHANGE_OR_LEARNING], with the characterization test to write before touching it.
CONSTRAINTS: Distinguish what the code provably does from what it appears intended to do. Do not propose large rewrites. Mark every inference as 'inferred' versus 'confirmed'.
OUTPUT FORMAT: Sections: Execution Walkthrough, Dependencies and State, Glossary, Landmines (table: Item | Risk | Confidence), Recommended First Change + Safety Test.