Debug Code Step by Step

General Productivitydeepseek-promptslanguagebugDescriptioncode

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.

Prompt
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

{{language}}{{bugDescription}}{{code}}{{expectedBehavior}}{{actualBehavior}}{{errorMessage}}

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.

What you get when you save this prompt

Your workspace unlocks powerful tools to iterate and improve.

AI OPTIMIZE

AI Optimization

One-click improvement with structure analysis and pattern suggestions.

VERSION DIFF

Version History

Track every edit. Compare versions side-by-side with word-level diffs.

ORGANIZE
Development
Code Review
Testing
Marketing

Folders & Tags

Organize your library with nested folders, tags, and drag-and-drop.

MCP
$ npm i -g @promptingbox/mcp
Claude · Cursor · ChatGPT

Use Everywhere

Access prompts from Claude, Cursor, ChatGPT & more via MCP integration.

Your prompts, organized

Save, version, and access your best prompts across ChatGPT, Claude, Cursor, and more.