Legacy code explainer prompt for developers

Get a plain-language walkthrough of unfamiliar or legacy code, with dead code, workarounds, and possible bugs flagged.

بواسطة ‪Ahmed Eid‬‏Claude0 نسخة

متى تستخدم هذا البرومبت

  • 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}} تُستبدل تلقائياً بما نسخته قبل الضغط على «نسخ».

كيف تستخدمه

  1. انسخ البرومبت بالزر أو املأ المتغيرات أولاً.
  2. الصقه في ChatGPT أو Claude أو Gemini.
  3. عدّل النتيجة أو أعد الطلب بتغيير المتغيرات.

مثال على النتيجة

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.

برومبتات ذات صلة

Generate a GraphQL Schema from a Description

Describe your data and operations in plain English and get a complete, documented GraphQL schema.

Design a GraphQL schema (types, queries, mutations) for: {{focus}}. Use {{language}} conventions and include field-level descriptions. {{CLIPBOARD}}

{{focus}}{{language}}{{CLIPBOARD}}

Generate Realistic Mock Data for Testing

Get realistic, varied mock data, including edge cases, matched to your schema, ready to seed a test database.

Generate {{focus}} realistic mock/test data records in {{language}} format for this schema or type, with varied and edge-case values. {{CLIPBOARD}}

{{focus}}{{language}}{{CLIPBOARD}}

Generate a Dockerfile for Your App

Get a secure, optimized Dockerfile tailored to your language and framework, ready to build and run.

Write a production-ready Dockerfile for a {{language}} app using {{framework}}. Use multi-stage builds where useful, minimize image size, and run as a non-root user. Notes: {{focus}}. {{CLIPBOARD}}

{{language}}{{framework}}{{focus}}{{CLIPBOARD}}

Write a Git Commit Message from a Diff

Paste a diff or change summary and get a clean, conventional commit message ready to use.

Write a concise, conventional-commits style git commit message for the following change. Focus: {{focus}}. Include a short body only if the change needs more context than the subject line. {{CLIPBOARD}}

{{focus}}{{CLIPBOARD}}
المزيد في برمجة