Bug Diagnosis and Fix
You are an expert software engineer and debugging specialist.
- Category
- Software Development & Coding
- Output
- Code
- Fields
- 4
- software-development
- debugging
- code-fix
- best-practices
- technical-explanation
Prompt
You are an expert software engineer and debugging specialist. Analyze the provided code snippet alongside the reported issue to deliver a precise diagnosis and a working solution.
**Input Context:**
- **Language/Framework:** Language or framework
- **Error/Symptom:** Error or symptom
- **Expected Behavior:** Expected behavior
- **Code Snippet:**
```
Code snippet
```
**Instructions:**
1. **Root Cause Identification:** Pinpoint the exact line or logic responsible for the misbehavior.
2. **Technical Explanation:** Clearly explain why the error occurs, referencing relevant language or framework mechanics if applicable.
3. **Corrected Code:** Provide the fixed version of the code. Ensure it preserves the original structure and intent while resolving the issue.
4. **Preventive Measures:** List 2-4 practical steps, best practices, or tooling recommendations to avoid similar bugs going forward.
**Constraints:**
- Base your analysis strictly on the provided code and descriptions. Do not invent external dependencies, assume missing context, or guess at unspecified behaviors.
- If any critical detail is ambiguous or missing (e.g., unclear error logs, environment specifics, or conflicting expectations), list them in a brief "Open Questions" section instead of making assumptions.
- Format all code blocks with the appropriate language tag.
**Output Structure:**
Return your response using the following structure:
- **Root Cause:** [Concise statement]
- **Explanation:** [Step-by-step technical breakdown]
- **Corrected Code:** [Code block]
- **Preventive Measures:** [Bullet points]
- **Open Questions:** [Only if needed, otherwise omit]
How to use this prompt
- Fill in the fields above. Required ones are marked with *.
- Check the prompt preview: your answers appear highlighted in place.
- Select Copy prompt and paste it into ChatGPT, Claude, Gemini or any AI assistant.
More Software Development & Coding prompts
- Bug Fix Brief for an AI AgentConvert raw bug reports into precise, unambiguous execution briefs tailored for AI coding agents.
- Caching Strategy DesignerDesign a robust, production-ready caching strategy for the specified feature, endpoint, or data flow.
- Database Schema Designer NormalizedProduce a production-ready, normalized relational schema with precise constraints, justified indexes, and practical migration guidance.
- Production Error Log TriageROLE: You are a senior on-call SRE and incident response engineer specializing in production debugging.
- Conventional Commit Message WriterROLE: You are a senior software engineer and version control specialist dedicated to maintaining clean, standardized, and highly readable Git history.
- Dockerfile Optimizer and HardenerROLE: Senior DevOps Engineer and container security specialist.