Programming Difficulty: Advanced

Code Analysis and Error Diagnosis

This prompt guides a seasoned programmer to analyze a specific piece of code that is causing an error. The programmer is tasked with diagnosing the error's root cause, understanding the code's intended functionality, and proposing a solution. The analysis includes a detailed walkthrough of the code, identification of bugs, and suggestions for improvements while adhering to best practices in software development.

The prompt

102 words2 blanks to fill in

Act as a seasoned programmer with over 20 years of commercial experience. Based on the provided [PIECE OF CODE], placeholder that is causing a specific [ERROR], placeholder, analyze the code to diagnose the root cause of the error. Understand the intended functionality and context of the code, and propose a solution to fix the issue. Include a step-by-step walkthrough of the code, identify any bugs or logical mistakes, and provide a detailed explanation of how to resolve them. Additionally, suggest improvements or optimizations to enhance performance, readability, or maintainability, ensuring adherence to best practices in software development and compatibility with the current development environment.

Highlighted text is a blank. Swap it for your own detail before you send the prompt.

What it produces

  • Identify the specific line of code causing the error and explain why it fails.
  • Provide a corrected version of the code with comments explaining the changes.
  • Suggest alternative approaches to achieve the same functionality more efficiently.

How to use this prompt

Four steps, about a minute. Nothing to install and no account needed.

  1. Copy the prompt

    Use the Copy button above. The whole prompt goes to your clipboard exactly as written. Nothing is trimmed.

  2. Fill in the blanks

    Replace [PIECE OF CODE] [ERROR] with your own details. Everything in square brackets is a blank for you to fill in.

  3. Paste it into your assistant

    Checked against Mistral, ChatGPT, Claude. It is written as plain instructions, so paste it into whichever of them you already use.

  4. Read the result, then push back

    Compare what you get to the example below. If it is close but not right, say what to change: shorter, warmer, more specific, then ask again in the same conversation.

More prompts like this one

Close neighbours in Programming, by shared subject and tagging.

Share Code Analysis and Error Diagnosis:

Reviews and questions

What other people got out of this prompt, and what they asked about it.

No reviews yet

Be the first to share how this prompt worked for you.