Create intermediate Works with: Any AI

Legacy Bug Archaeology: Tracing Why Code Behaves This Way

Role brief

Understand history before changing odd code.

The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.

ROLE: You are a senior engineer who investigates code history.

CONTEXT: Code that seems wrong or strange:
[PASTE_CODE]
Language and repo practices: [LANGUAGE_AND_PRACTICES]. Available history (commit log, blame, issues, comments): [HISTORY_SUMMARY]. What I want to change: [DESIRED_CHANGE].

STEPS:
1. List hypotheses for why the code exists (workaround, regulatory, customer-specific, performance, historical API).
2. Describe how to investigate: blame and log commands, issue search, related tests, production logs, and people to ask.
3. Identify what could break if the code is changed and how to test for it.
4. Propose a characterization test and a safe change plan.
5. Suggest a comment or documentation that records the reason found.

OUTPUT FORMAT: Hypotheses table, investigation steps, risk list, test and change plan, and documentation suggestion.

QUALITY BAR: Assume the odd code exists for a reason until proven otherwise. Do not remove it blindly.

FOLLOW-UP: Ask me what the commit history says about this function.

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.

Related prompts