Legacy code explainer prompt for developers
Get a plain-language walkthrough of unfamiliar or legacy code, with dead code, workarounds, and possible bugs flagged.
متى تستخدم هذا البرومبت
- When inheriting a codebase with no documentation.
- When a function looks suspicious but no one remembers why it's written that way.
- Before modifying old code you don't fully trust yet.
نص البرومبت
Walk through this {{language}} code line by line and explain what it does, in plain language. Flag anything that looks like dead code, a workaround, or a potential bug.
{{CLIPBOARD}}{{language}}{{CLIPBOARD}}الكتلة {{CLIPBOARD}} تُستبدل تلقائياً بما نسخته قبل الضغط على «نسخ».
كيف تستخدمه
- انسخ البرومبت بالزر أو املأ المتغيرات أولاً.
- الصقه في ChatGPT أو Claude أو Gemini.
- عدّل النتيجة أو أعد الطلب بتغيير المتغيرات.
مثال على النتيجة
Lines 1-8 parse the config file, defaulting to prod if no environment variable is set. Lines 10-15: this loop appears to retry a failed request up to 3 times, but the retry counter is never incremented, likely a bug causing an infinite loop under failure. Line 20: a TODO comment marks this whole block as possible dead code from a completed migration.
نصائح للاستخدام
- Paste the whole function or file, since legacy code often depends on state set elsewhere.
- Ask it to separate what it does from what looks wrong so the two don't get mixed up.
- Cross-check any flagged bug with the actual git blame/history before assuming it's real.
النماذج الموصى بها
Claude
أسئلة شائعة
- Can it tell me why the code was written this way historically?
- Not from the code alone; check git blame or commit history for the why, the prompt covers only current behavior.
- Will it flag every possible bug?
- It surfaces the most visible issues from reading the code, not a guarantee of completeness; pair it with tests for confidence.