Code review prompt template
An AI code review prompt that finds real bugs and edge cases instead of style nitpicks: ranked issues, corrected snippets and one-line explanations.
You write
Review my TypeScript function that merges two user lists for bugs
"Review this code" gets you a polite list of twelve suggestions, half of them about variable names. The bug that will page someone at 3 a.m. is in there somewhere, ranked the same as a missing semicolon. A good code review prompt tells the model what kind of reviewer to be, where the code runs and what to ignore, so the important findings come first.
The prompt Promptay builds
Role: You are a senior TypeScript engineer doing a careful review before a production release. Task: Review the function below, which merges two lists of user records, for bugs, unhandled edge cases and data loss. Context: It runs in a Node.js service that syncs users from two sources about every 5 minutes. Lists can hold up to 50,000 records. Users are matched by email, and either source can have missing or differently cased emails. Format: A numbered list of issues ranked by severity (critical, major, minor). For each issue: one sentence on the problem, one sentence on its impact, and a corrected snippet of only the lines that change. Constraints: Focus on correctness, then performance. Skip formatting and naming unless it causes a bug. Do not rewrite the whole function. If the code is correct for a case, do not invent a problem.
Why this prompt works
- The runtime context finds the real bugs. Mentioning 50,000 records and mixed-case emails points the model at quadratic loops and case-sensitive matching, the two classic failures here.
- Severity ranking separates signal from noise. You can stop reading after the critical items if time is short.
- Small diffs, not rewrites. Asking only for the lines that change keeps fixes easy to verify and apply.
- Permission to find nothing. "Do not invent a problem" reduces the false positives models produce when they feel they must say something.
How to adapt it
Replace the language, the runtime and the scale with yours; those three details change the review more than anything else. For a security-sensitive change, add "check input validation, authorization and secrets handling first". For a pull request rather than a single function, paste the diff and ask for issues grouped by file. To review against your team's standards, include your checklist in the context.
Ideas to try next:
- "Review this SQL migration for locking problems on a large table"
- "Write unit tests for the edge cases you found in this function"
- "Explain this legacy Python module to a new team member before they change it"
Related guides and skills
· 9 min read
ChatGPT prompts for coding: debugging, code review and refactoring
Copy-ready ChatGPT prompts for coding: debugging, code review, refactoring, tests, SQL and regex, plus the context to include and the safety rules to follow.
Read article· 10 min read
Few-shot prompting: how to use examples to get consistent AI output
Few shot prompting examples you can copy: when examples beat instructions, how many to use, how to format them, and 5 worked templates for consistent output.
Read articlePR review checklist
Reviews a pull request or diff for correctness, security, tests and readability, and returns prioritized findings. Use when the user asks to review a PR, a diff, or changes before merging.
View the skill