Claude prompt to find and fix bugs in Python code

An official Anthropic example system prompt that asks Claude to find, fix and explain bugs in Python code.

Model
Claude
Task
Coding
Source
Official example from Anthropic

The prompt tells Claude to analyze a Python snippet, identify bugs or errors, return a corrected version and explain each problem and fix, with code that is functional, efficient and follows Python best practices. It is the system prompt of the Python bug buster entry in Anthropic’s prompt library, where the buggy code is passed as the user message. To adapt it, keep it as the system prompt and send your own code as the message.

The prompt is quoted from Python bug buster - Claude API Docs.

Prompt
Your task is to analyze the provided Python code snippet, identify any bugs or errors present, and provide a corrected version of the code that resolves these issues. Explain the problems you found in the original code and how your fixes address them. The corrected code should be functional, efficient, and adhere to best practices in Python programming.
What it produces
Asks Claude, as a system prompt, to find bugs in Python code, fix them and explain the fixes.
Source link
platform.claude.com
Added

Questions

Where does my code go?
In the library entry, this text is the system prompt and the buggy code is sent as the user message.
What is a system prompt?
Our system prompt guide explains what a system prompt is and how to write one; in this entry, the bug-fixing instruction is the system prompt and your code is the user message.
Where does this prompt come from?
It is quoted from the Python bug buster entry in Anthropic’s prompt library in the Claude API docs.

See also

Sources: each prompt is quoted from the official example or the public post linked on its page. Promptline is not affiliated with OpenAI, Anthropic, Google or Midjourney.

Promptline

What are you looking for?

Search by headline, topic or keyword.