DevelopmentFree Template
AI Python Debugging Prompt
Use this optimized AI prompt to create professional python debugging. Copy the template, customize it for your needs, and get better AI outputs instantly.
prompt-template.txt
You are a senior Python developer with 15 years of debugging experience. Task: Debug and fix Python code. Problem Description: [DESCRIBE THE ISSUE] Code: [PASTE YOUR CODE HERE] Expected Behavior: [WHAT SHOULD HAPPEN] Actual Behavior: [WHAT IS HAPPENING] Error Message (if any): [PASTE ERROR] Please provide: 1. Root Cause Analysis: - Identify the exact issue - Explain why it's happening - Common scenarios that cause this 2. Fix: - Corrected code with clear comments - Explanation of changes 3. Prevention: - How to avoid this in the future - Relevant best practices - Testing strategies 4. Related Issues: - Other potential bugs in the code - Performance considerations - Security concerns (if applicable) Explain your reasoning step by step. Assume I want to learn, not just get a fix.
๐ฌExample Output
Prompt Example:
[Fill in the placeholders with your specific details for python debugging]
Example Output:
DEBUG ANALYSIS
Problem: IndexError in list comprehension
Code Provided:
def process_users(users, scores):
return [users[i] + ": " + str(scores[i]) for i in range(len(users))]
Error: IndexError: list index out of range
1. ROOT CAUSE ANALYSIS
The Issue:
The code assumes users and scores lists have the same length, but they don't. When iterating over range(len(users)), if scores is shorter, accessing scores[i] fails.
Why It Happens:
- The function trusts input without validation
- range(len(users)) only considers one list's length
- This is a "silent assumption" bug - works sometimes, fails unexpectedly
2. THE FIX
Option A: Safe iteration with zip (Recommended)
def process_users(users, scores):
"""Pair users with their scores safely."""
# zip stops at shortest list - prevents IndexError
return [f"{user}: {score}" for user, score in zip(users, scores)]
[Continues with alternative solutions and tests...]๐Prompt Performance
Scores are estimated based on prompt characteristics (not live model calls).
Best Model:Claude
Best for:Code & technical docs
Confidence:High
Claude
100
ChatGPT
85
Gemini
82
Llama
72
Grok
66
๐Why Claude wins for this prompt
- โขExceptional code accuracy and best practices
- โขClear technical explanations
- โขStrong debugging capabilities
๐ฏWhat This Prompt Does
This prompt guides AI to create a professional python debugging. It provides structured instructions that help you get consistent, high-quality results from ChatGPT, Claude, Gemini, or any AI assistant.
๐ When To Use This Prompt
- Code development
- Technical documentation
- Debugging
- Code reviews
- System design
- API development
โ๏ธPrompt Customization
Replace these placeholders with your specific information:
[DESCRIBE THE ISSUE]Replace with your specific describe the issue[PASTE YOUR CODE HERE]Replace with your specific paste your code here[WHAT SHOULD HAPPEN]Replace with your specific what should happen[WHAT IS HAPPENING]Replace with your specific what is happening[PASTE ERROR]Replace with your specific paste error๐กWhy This Prompt Works
- โIdentifies exact root cause, not just the symptom
- โProvides multiple solutions for different use cases
- โExplains the "why" behind each fix
- โIncludes prevention strategies for learning
- โAdds tests to prevent regression
- โSuggests related improvements (performance, types)
๐Related Prompts
Tags
DevelopmentPython DebuggingAI PromptsChatGPTClaudePrompt Template
