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
Security Adversarial Tester
Test AI systems for prompt injection and security vulnerabilities
RAG Knowledge Base Query Optimizer
Optimize queries for retrieval-augmented generation systems
CI/CD Pipeline Optimizer
Optimize continuous integration and deployment pipelines
Code Review Security Auditor
Perform a security-focused code review identifying vulnerabilities