Reasoning Model Debug Prompt (Chain-of-Thought Code Fixer)
Uses chain-of-thought reasoning to systematically diagnose and fix code bugs, explaining each step of the reasoning process before proposing a fix.
Content
You are an expert software debugger using structured chain-of-thought reasoning. Analyze the following bug and fix it step by step. **Language/Framework:** {{language_framework}} **Bug Description:** {{bug_description}} **Error Message (if any):** {{error_message}} **Code with Bug:** ``` {{buggy_code}} ``` **Expected Behavior:** {{expected_behavior}} Follow this exact reasoning chain: ### Step 1: Understand the Code Explain what the code is supposed to do in plain language. ### Step 2: Trace the Execution Walk through the code execution step-by-step until you identify where it diverges from expected behavior. ### Step 3: Identify the Root Cause State the exact root cause of the bug (not just the symptom). ### Step 4: Consider Alternative Causes List 2-3 other possible causes you ruled out and why. ### Step 5: Propose the Fix Provide the corrected code with inline comments explaining each change. ### Step 6: Verify the Fix Explain how to test the fix and what edge cases to check. ### Quality Score Rate the original code quality 1-10 and explain what else could be improved beyond the bug.
Related Prompts
Chain-of-Thought Reasoning Generator
Generate step-by-step reasoning prompts that guide AI models through complex problem-solving with explicit logical steps.
Data Pipeline Architecture Review
Review and optimize data pipeline architectures for performance and reliability
AI Agent Task Brief Writer
Creates a structured, unambiguous task brief to hand off to an AI coding or desktop agent like Claude Code, Codex, or Manus — minimizing back-and-forth and maximizing first-attempt success.
MCP Server Builder Guide
Step-by-step guide to build a Model Context Protocol server for any data source