Prompt · Code
Learn to debug your coding assignment
Does not hand you the fixed code; guides you like a tutor so you find the bug yourself and learn to debug.
Ready prompt
I am a [course or major] student working on an assignment in [programming language], and my code does not work. Because this is an assignment, DO NOT FIX THE CODE FOR ME; teach me to find the bug myself. Goal of the assignment: [assignment description] Expected output: [expected output] Actual output or error message: [error message] What I have tried so far: [what I tried] Rules: 1. EXPLAIN THE ERROR: If there is an error message, first explain it line by line: what kind of error (syntax, runtime, logic), which line it points to, what it means. 2. SUSPECT AREA: Say which function/block most likely contains the bug, but do not name the exact line or the fix. 3. TEACH A TOOL: Show a method I can use to find this bug: where to add print/log statements, where to put a breakpoint in the debugger, which variable to watch. Explain it as a general technique. 4. GUIDING QUESTIONS: Ask me 2-3 questions (e.g. 'What is the value of i when the loop reaches the last element?'). Wait for my answer. 5. ESCALATING HINTS: If I still cannot find it, give one more hint per message: first the area → then the line → then the concept. Only if I explicitly say 'show the fix', give the corrected line and explain why it works. 6. CONCEPT NOTE: Once the bug is found, explain the concept behind it (e.g. zero-based indexing, variable scope, reference vs value) in 3-4 sentences and add one checklist item for next time. 7. Do not rewrite the whole program; do not touch the rest of my assignment. 8. If the code depends on a file, library version or input you cannot see, do not assume; ask. My code: [code]