A code review prompt fits one situation: the code runs, but you are not sure whether it hides problems. Asking the AI to just take a look at the code usually gets praise, or a full rewrite. Put the scope, the severity levels, and the output format in the prompt, and it reviews like a reviewer: must-fix problems first, then things that could be better.
Copy this prompt first
You are now a senior code reviewer, familiar with [programming language], and you have reviewed code for [what the code does].
Review only the code pasted at the end. Do not guess about code that was not pasted.
Check in this order: 1) Correctness: logic errors, edge cases, null values, and exception handling; 2) Security: injection, excessive permissions, and sensitive data leaks; 3) Performance: clearly redundant loops, repeated queries, and unnecessary copies of large objects; 4) Readability and maintainability: naming, duplicated code, and overlong functions; 5) Test gaps: branches with no test coverage.
Give the list of issues first, then the fixes. For each issue, state its severity, location, problem, and fix. Use only these three severity levels: Must fix, Should fix, and Can wait. Write fix code only for Must fix issues; for the rest, describe the fix without rewriting the whole code. Mark anything uncertain as Uncertain and say what information would settle it. End by asking me the single most important background question.
Focus on [review focus] in this review, and use a [strictness level] standard.
Code:
[paste code]Fill the 5 placeholders like this
- [programming language]: give the specific language and version, such as Python 3.12, not just a generic label.
- [what the code does]: say what the code is for, such as order total calculation or a user login endpoint, because the review standard follows its purpose.
- [review focus]: pick one or two from security, performance, and readability. Picking everything is the same as having no focus.
- [strictness level]: strict means style issues are listed too; lenient means only correctness and security issues are listed.
- [paste code]: paste the complete function, not half of it. If it is over 200 lines, split it and review it in parts.
What a filled-in opening looks like
You are now a senior code reviewer, familiar with Python 3.12, and you have reviewed code for order total calculation.
Focus on security and edge cases in this review, and use a strict standard.When the output feels wrong, adjust it like this
- Too many minor issues: change the strictness level to lenient and look only at the Must fix items.
- Fixes too vague: paste where the code is called and one real input example, so it checks the real path.
- The AI rewrites the code: add the line Do not rewrite the code, only give issues and fixes, and send it again.
Fix the Must fix items first, run the tests, then look at Should fix. In that order, a review saves time.