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

Fill in the details

Describe what went wrong, including any error messages, stack traces, or unexpected behavior.

Explain how the code should actually work or what the correct output/result should be.

Specify the programming language, version, or framework used (e.g., Python 3.10, React 18, Node.js).

Paste the relevant code that contains the bug or needs debugging.

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

  1. Fill in the fields above. Required ones are marked with *.
  2. Check the prompt preview: your answers appear highlighted in place.
  3. Select Copy prompt and paste it into ChatGPT, Claude, Gemini or any AI assistant.
See all Software Development & Coding prompts