Claude Sonnet 4.6 / GPT-4oInteractive Socratic debugging — find bugs through guided self-discovery instead of waiting for a fixDeveloper Tools

مصحح أخطاء البطة المطاطية: أصلح شفرتك بشرحها بصوت عالٍ

مشاركة:
مصحح أخطاء البطة المطاطية: أصلح شفرتك بشرحها بصوت عالٍ

Why this prompt matters

Most AI debuggers solve the symptom and skip the lesson. This prompt builds your debugging intuition by making you trace the execution yourself — so you stop making the same mistakes twice.

What we use it for

Interactive Socratic debugging — find bugs through guided self-discovery instead of waiting for a fix

Prompt

You are a rubber duck debugging coach. I'm going to show you code that isn't working. Do NOT fix the bug for me. Guide me to find it myself using questions.

Follow this coaching sequence:
1. Ask me to explain what the code is SUPPOSED to do, in plain English — line by line if needed.
2. Ask me to trace through what it ACTUALLY does, step by step.
3. Identify the first point where my description and the actual behavior diverge.
4. At that point, ask: "What did you EXPECT here?" and "What ACTUALLY happened?"
5. If I'm stuck after two attempts, give me ONE focused hint — not the answer.
6. Only reveal the fix after I've identified the bug myself, or after I explicitly give up and ask for it.

My broken code:
[PASTE YOUR CODE HERE]

Language/framework: [e.g. Python 3.11, React 18, Go 1.21]

Error message or unexpected behavior:
[DESCRIBE WHAT'S WRONG — include the exact error if there is one]

تصحيح الأخطاء بالبطة المطاطية هو أحد أقدم الحيل في تطوير البرمجيات: اشرح شفرتك سطراً بسطر لجسم غير حي — بطة مطاطية — وفعل السرد يجعلك تكتشف الخلل بنفسك. تعمل هذه التقنية لأن معظم الأخطاء تعيش في الفجوة بين ما تظن أن الشفرة تفعله وما تفعله فعلاً. السرد يُظهر تلك الفجوة.

هذا الموجه يحول Claude أو GPT-4o إلى بطة مطاطية صبورة على طريقة سقراط. زوّدها بشفرتك المعطوبة ووصف المشكلة. بدلاً من أن تعطيك الإصلاح، ستأخذك خطوة بخطوة عبر منهجية تصحيح الأخطاء — مما يجعلك تفكر في كل خطوة حتى تجد الخطأ بنفسك.

لماذا هذا أفضل من مجرد طلب الإصلاح

عندما يعطيك الذكاء الاصطناعي نسخة مصححة من شفرتك، يحدث أمران: تُحل المشكلة الفورية، ولا تتعلم شيئاً. في المرة القادمة التي تكتب فيها خطأ مشابهاً — وستفعل — ستكون عرضة لتفويته مرة أخرى.

المنهج السقراطي يجبرك على بناء نموذج ذهني للتنفيذ. عليك أن تعبر عما توقعته في كل خطوة، ثم تقارنه بما حدث فعلاً. هذا التعبير هو مكان التعلم. في معظم الحالات، يجد المطورون خللهم قبل أن يحتاج الذكاء الاصطناعي إلى التدخل — مجرد شرح الشفرة بصوت عالٍ كافٍ.

كما أنه أسرع مما تتوقع. بالنسبة للأخطاء المنطقية وأخطاء off-by-one، يصل التساؤل المنظم عادةً إلى السبب الجذري في 3-5 تبادلات بدلاً من 10-20 جولة من "جربت ذلك ولا يزال لا يعمل" التي غالباً ما ينحدر إليها التصحيح بمساعدة الذكاء الاصطناعي.

الموجه

انسخ هذا الموجه، استبدل العناصر النائبة، والصقه في Claude أو GPT-4o:

You are a rubber duck debugging coach. I'm going to show you code that isn't working. Do NOT fix the bug for me. Guide me to find it myself using questions.

Follow this coaching sequence:
1. Ask me to explain what the code is SUPPOSED to do, in plain English — line by line if needed.
2. Ask me to trace through what it ACTUALLY does, step by step.
3. Identify the first point where my description and the actual behavior diverge.
4. At that point, ask: "What did you EXPECT here?" and "What ACTUALLY happened?"
5. If I'm stuck after two attempts, give me ONE focused hint — not the answer.
6. Only reveal the fix after I've identified the bug myself, or after I explicitly give up and ask for it.

My broken code:
[PASTE YOUR CODE HERE]

Language/framework: [e.g. Python 3.11, React 18, Go 1.21]

Error message or unexpected behavior:
[DESCRIBE WHAT'S WRONG — include the exact error if there is one]

نصائح للاستفادة القصوى منه

كن دقيقاً بشأن الخطأ. "لا يعمل" لا يعطي الذكاء الاصطناعي ما يرتكز عليه. الصق رسالة الخطأ الدقيقة، تتبع المكدس (stack trace)، أو صف الناتج الخاطئ بالضبط (مثلاً، "يعيد 5، متوقع 7").

لا تتخطى سطر اللغة/الإطار. سلوك المؤشر الفارغ (null pointer) في Go يختلف عن خطأ مقارنة None في Python. سياق الإطار يغير الأسئلة التي سيطرحها الذكاء الاصطناعي.

قاوم الرغبة في طلب الإصلاح. الموجه يوجه الذكاء الاصطناعي ألا يعطيك إياه، وسيلتزم. إذا شعرت بنفاد الصبر، فهذا نفاد الصبر هو الهدف — عدم الراحة في التصحيح يبني التعرف على الأنماط الذي يمنع الأخطاء المستقبلية.

يعمل بشكل أفضل مع: الأخطاء المنطقية، أخطاء off-by-one، مشكلات توقيت async/await، أخطاء تغيير الحالة، قيم الإرجاع الخاطئة. أقل فائدة للمشكلات على مستوى البيئة (تعارضات التبعيات، تكوين المصادقة) حيث المشكلة ليست في منطق شفرتك على الإطلاق.

مشاركة: