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
Data Pipeline Architecture Review
Review and optimize data pipeline architectures for performance and reliability
Python Automation Script Builder
Generate clean, production-ready Python automation scripts with error handling, logging, and documentation — for web scraping, file processing, API integration, and scheduled tasks.
API Endpoint Designer
Design RESTful API endpoints with proper naming, methods, and documentation
Chain-of-Thought Reasoning
Step-by-step reasoning prompt for complex problem solving