Debug an Error
Diagnose an error by giving the AI the message, the code, what you tried and what you expected.
Get a prioritized code review that covers correctness, security, readability and tests.
Review the {language} code below.
<purpose>
{purpose}
</purpose>
<code>
{code}
</code>
<review_focus>
{review_focus}
Conventions to respect: {team_conventions}
</review_focus>
Review in this order and be specific. Refer to line numbers or function names.
1. Correctness: bugs, edge cases, wrong assumptions, off-by-one errors, unhandled null or empty values.
2. Security: input validation, injection risks, unsafe use of data, secrets in code.
3. Error handling and reliability: what happens when something fails.
4. Readability and maintainability: naming, structure, duplication.
5. Tests: what is missing, and the three most valuable test cases to add.
For each issue, give: severity (high, medium, low), what is wrong, why it matters, and a concrete fix with a short code example. Sort the issues from most to least severe.
Do not invent problems to look thorough. If something looks fine, say so in one line. If you need to see other files to be sure about an issue, tell me which ones instead of guessing. End with a one-paragraph summary: would you approve this change, and what must change first?| Variable | What to put in | Example |
|---|---|---|
| {language} | The programming language and framework. | TypeScript with Node.js |
| {code} | The code to review. | Paste the function, file or diff here. |
| {purpose} | What the code is supposed to do. | Validate an uploaded CSV and import valid rows into the database. |
| {review_focus} | What you care about most. | Correctness, error handling and security. |
| {team_conventions} | Style rules or conventions to respect. Write "none" if there are none. | Functions under 40 lines; no default exports. |
High: in importRows, an empty CSV leads to rows[0] being undefined, which throws before any validation runs. Fix: return early when rows.length === 0. Medium: file contents are written to the database without trimming or length checks. Add per-field validation before insert. Summary: do not approve yet. Fix the empty-file crash and add validation first.
Claude tends to explain trade-offs in reviews. For large changes, paste the diff and the files it touches rather than everything.
Works as-is. If your plan supports file upload, you can upload the file instead of pasting it.
If you can attach files or a repository export, name the files in the review focus so comments refer to the right place.
State the language and framework clearly. Ask it to flag any suggestion that depends on a library version, and check it yourself.
Rewrite only the high-severity fixes as a patch I can apply.Which of your suggestions are matters of taste rather than correctness?Write the three test cases as runnable code.Diagnose an error by giving the AI the message, the code, what you tried and what you expected.
Generate unit tests that cover normal cases, edge cases and failures, with the reasoning for each.
Improve the structure and naming of code without changing what it does, with a list of changes.