Code Review & Debugging5.0 · 0 ratings
Legacy Code Comprehension And Bug Hunt
Explains an unfamiliar legacy file and surfaces latent bugs and risky areas before you change it.
Role-Based
Prompt
ROLE: You are an engineer onboarding onto an unfamiliar, undocumented legacy module and assessing its risk before modification. CONTEXT: The file below is from a legacy [LANGUAGE] codebase with little documentation. We need to [PLANNED_CHANGE] and want to understand it and find lurking bugs first. Known behavior: [WHAT_IT_DOES_AT_A_HIGH_LEVEL]. CODE: [PASTE_LEGACY_CODE] TASK: 1. Produce a plain-language explanation of what the module does, its inputs/outputs, and its key responsibilities. 2. Map the control flow and call relationships, noting any global/shared state and side effects. 3. Hunt for latent bugs: dead code, unreachable branches, swallowed errors, resource leaks, broken invariants, and assumptions that may no longer hold. 4. Identify the riskiest areas to touch for the planned change and what could break elsewhere (hidden coupling, implicit contracts). 5. Recommend safety nets to add before modifying: characterization tests, logging, or small refactors that reduce risk. OUTPUT FORMAT: - 'What this module does' (plain English). - 'Control flow / dependencies' (summary or diagram-in-text). - 'Latent bugs and smells' (location | issue | severity). - 'Risk map for the planned change' + 'Safety nets to add first'. CONSTRAINTS: Do not propose the change itself yet; focus on understanding and de-risking. Clearly separate confirmed facts from inferences about intent. Flag anything you cannot determine without seeing additional files.
Recommended models
claudegpt-4ogemini
More in Code Review & Debugging
Pull Request Review With Severity Triage
Reviews a pull request diff and returns issues bucketed by blocking, major, minor, and nit severity with concrete fixes.
Read prompt
Root-Cause Analysis From a Stack Trace
Walks a stack trace and surrounding code step by step to isolate the true root cause and propose a minimal verified fix.
Read prompt
Security-Focused Code Audit
Audits a code module against the OWASP Top 10 and common weakness patterns, reporting exploitability and remediation.
Read prompt
Concurrency And Race Condition Hunter
Inspects multithreaded or async code for races, deadlocks, and visibility bugs and proposes safe synchronization.
Read prompt