Code smell finder prompt: name it and fix it
Paste code and get named code smells and anti-patterns identified, each with a specific, actionable fix suggestion.
بواسطة Ahmed Eid0 نسخة
متى تستخدم هذا البرومبت
- During a self-review before requesting a full code review.
- When a file has grown hard to work in but the cause isn't obvious.
- When mentoring a junior developer on common pitfalls.
نص البرومبت
Scan this {{language}} code for code smells and anti-patterns (e.g. god objects, magic numbers, deep nesting). For each, name the smell and suggest a specific fix.
{{CLIPBOARD}}
{{language}}{{CLIPBOARD}}الكتلة {{CLIPBOARD}} تُستبدل تلقائياً بما نسخته قبل الضغط على «نسخ».
املأ المتغيرات ثم انسخ
Scan this {{language}} code for code smells and anti-patterns (e.g. god objects, magic numbers, deep nesting). For each, name the smell and suggest a specific fix.
كيف تستخدمه
- انسخ البرومبت بالزر أو املأ المتغيرات أولاً.
- الصقه في ChatGPT أو Claude أو Gemini.
- عدّل النتيجة أو أعد الطلب بتغيير المتغيرات.
مثال على النتيجة
Smell: God object, OrderManager handles payments, inventory, and email notifications (3 unrelated responsibilities). Fix: split into PaymentService, InventoryService, and NotificationService. Smell: Magic number, if (retries > 3) with no explanation. Fix: extract to const MAX_RETRIES = 3;
نصائح للاستخدام
- Paste the whole file if possible; some smells like god objects only show up at that scale.
- Ask it to prioritize the smells that most affect maintainability, not just list everything.
- Use this before, not instead of, a full human code review for anything security- or business-critical.
أسئلة شائعة
- Is this the same as a full code review?
- No, it focuses narrowly on named code smells and anti-patterns; pair it with the broader code review prompt for full coverage.
- Will it flag intentional trade-offs as problems?
- It may flag patterns that were a deliberate, documented trade-off; use judgment and keep what's genuinely justified.