Debug Code Step by Step
DeepSeek-R1's reasoning training makes it excellent at step-by-step code tracing. Constraining to a 'minimal fix' prevents the model from rewriting your entire function when only one line needs to change. The execution trace reveals the model's reasoning so you can verify it.
Debug the following {{language}} code. There is a bug causing {{bugDescription}}. **Code:** \`\`\`{{language}} {{code}} \`\`\` **Expected behavior:** {{expectedBehavior}} **Actual behavior:** {{actualBehavior}} **Error message (if any):** {{errorMessage}} Debug this step by step: 1. Read the code and trace the execution flow 2. Identify where the actual behavior diverges from expected 3. Explain the root cause clearly 4. Provide the corrected code with a comment marking what changed and why Do not rewrite the entire function — show only the minimal fix needed.
Variables to customize
Why this prompt works
DeepSeek-R1's reasoning training makes it excellent at step-by-step code tracing. Constraining to a 'minimal fix' prevents the model from rewriting your entire function when only one line needs to change. The execution trace reveals the model's reasoning so you can verify it.
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.