Debugging by Explanation
Separating root cause from symptom prevents superficial fixes. Asking for a test case that catches the bug helps prevent regression and builds testing intuition.
My {{language}} code is not working as expected.\n\nCode:\n{{buggy_code}}\n\nExpected behavior: {{expected_behavior}}\nActual behavior: {{actual_behavior}}\nError message (if any): {{error_message}}\n\nPlease:\n1. Identify the root cause of the bug (not just the symptom)\n2. Explain WHY this bug occurs — what is the code actually doing vs. what I intended?\n3. Provide the fixed code with the minimal change needed\n4. Suggest a test case that would have caught this bug\n5. Note if this is a common mistake and how to avoid it in the future
Variables to customize
Why this prompt works
Separating root cause from symptom prevents superficial fixes. Asking for a test case that catches the bug helps prevent regression and builds testing intuition.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Forcing the agent to plan before acting prevents premature execution and wasted steps. Explicit dependency mapping enables parallel execution and catches logical gaps early.
Tool Selection AgentThe ReAct pattern (Reason + Act) creates an explicit reasoning trace that improves tool selection accuracy. The error-handling rule prevents infinite retry loops.
Prompt CompressorExplicitly requiring all functional requirements to be preserved prevents the model from over-compressing and losing critical instructions.
Memory Management AgentExplicit memory read/write instructions create agents that improve over time. Categorization keeps memories organized, and the deduplication rule prevents context bloat.