Why this code review prompt works
"Why doesn't this work?" plus a code dump is the most common coding prompt, and it leaves the model guessing about the language version, what the code is supposed to do and what "doesn't work" means. A guessing model tends to rewrite everything in its own style, which makes the real problem harder to see.
This builder fixes the inputs that matter. The goal says what correct behaviour looks like, the error or unexpected behaviour gives the model the symptom, and the language and framework stop it from suggesting functions your version does not have. The code goes into a fenced block so the model cannot confuse it with your instructions.
The requirements are written the way a good senior reviewer works: findings ordered by severity, each with a line reference and a one-sentence reason, then the smallest change that fixes the issue instead of a full rewrite. The prompt also tells the model not to invent library functions and to say when it is unsure, which is the main source of plausible-looking but broken AI code.
Worked example
Say a small helper function crashes for new customers who have not ordered yet. These are the inputs:
- What do you need?
- Find and fix a bug
- Language and framework
- Python 3.12
- Focus
- correctness and edge cases
- What should the code do?
- Return the average order value for a list of orders
- Error message or unexpected behaviour
- ZeroDivisionError when the customer has no orders
- Your code
- def average_order_value(orders):; total = 0; for o in orders:; total += o["amount"]; return total / len(orders)
- Explanation level
- intermediate developer
- Constraints
- keep the function signature
The builder turns these inputs into the following prompt. Load it into the form above with the Python bug fix example chip and change anything you like.
You are a senior software engineer with deep experience in Python 3.12. You give precise, practical feedback.
## Task
Find the cause of the problem described below and fix it.
## Context
- Language and framework: Python 3.12
- What the code should do: Return the average order value for a list of orders
- Problem or error: ZeroDivisionError when the customer has no orders
- Focus on: correctness and edge cases
- Constraints: keep the function signature
- Explain at the level of: intermediate developer
## Requirements
- Reference line numbers or function names for every point.
- Prefer the smallest change that solves the problem; do not rewrite working code in a different style.
- Only use functions and APIs that exist in the stated language and version. If you are unsure whether something exists, say so.
- If information is missing to diagnose the problem, ask me up to 3 specific questions instead of guessing.
## Output format
1. The root cause in one or two sentences, with the line number.
2. The fixed code in a code block, changing as little as possible.
3. Why the fix works, and one test case that would have caught the bug.
## Code
```python
def average_order_value(orders):
total = 0
for o in orders:
total += o["amount"]
return total / len(orders)
```This page shows only the prompt. The answer depends on the AI tool you paste it into, so always review the result before you use it.
Tips to improve your results
- Paste the smallest piece of code that still shows the problem. A 40-line function gets a far better review than a 2,000-line file.
- Always include the exact error message and stack trace if you have one. It is the most valuable clue.
- Mention versions: "React 18" or "Python 3.8" changes which fixes are valid.
- Remove API keys, passwords and customer data before pasting code into any AI tool.
- Run the suggested fix and its tests yourself. Treat AI code like a pull request from a new colleague.
Frequently asked questions
Can ChatGPT or Claude really find bugs in my code?
They are good at spotting common mistakes such as off-by-one errors, missing null checks, unhandled edge cases and injection risks, especially in short, focused snippets. They can also be confidently wrong, so test every suggested fix before you merge it.
Is it safe to paste company code into an AI tool?
That depends on your employer's policy and the AI tool's data settings. This site never sees your code, because the prompt is built in your browser, but once you paste it into an AI service that service's terms apply. Remove secrets and check your company rules first.
Which mode should I choose?
Choose "Find and fix a bug" when something fails, "Review my code" before you open a pull request, "Explain this code" for unfamiliar code, "Refactor" when it works but is hard to read, and "Write unit tests" to cover existing behaviour.
Why does the prompt ask for a minimal fix?
Large rewrites hide the actual change and often introduce new bugs. A minimal diff shows exactly what was wrong and is easier to review, test and explain to your team.
Does it work for any programming language?
Yes. The prompt is language-agnostic. Name the language and framework so the model applies the right conventions and standard library.