Review a diff like a senior engineer
Looks for defects and consequences, not style opinions a linter already covers.
Review this change the way someone accountable for it in production would. ```diff [PASTE DIFF] ``` Context: [WHAT THIS CHANGE IS MEANT TO DO] Report only things that would change my decision to merge: - **Correctness** — inputs where this produces a wrong result or throws. Give the input. - **Consequences** — what else depends on the behaviour being changed here. - **Missing cases** — the error path, the empty case, the concurrent case. - **Tests** — what is now untested that matters. Not coverage percentages. Rules: no style comments — formatting and naming conventions are a linter's job. No praise. If a finding is a guess because you cannot see the rest of the codebase, mark it as a guess. If the change is fine, say it is fine and stop; padding a review with minor observations to look thorough is worse than a short review.
Highlighted parts are placeholders. Replace them before you send.
Worked example
The input is invented for this page. The output shows what the prompt asks for with that input.
Example input (invented)
Diff
--- a/pricing.py
+++ b/pricing.py
@@ -1,4 +1,9 @@
-def apply_discount(total, code):
- if code == "WELCOME10":
- return round(total * 0.9, 2)
- return total
+CODES = {"WELCOME10": 10, "SPRING25": 25}
+
+
+def apply_discount(total, code, used_codes=[]):
+ percent = CODES[code.upper()]
+ if code in used_codes:
+ return total
+ used_codes.append(code)
+ return round(total * (1 - percent / 100), 2)
Context: Add a second discount code, SPRING25, and stop a code from being used twice.
Example output
Correctness
apply_discount(50, "TYPO")raisesKeyError. Before this change an unknown code returned 50.apply_discount(50, None)raisesAttributeErroroncode.upper(). Before, it returned 50.- Without
used_codes, every call shares the one default list.apply_discount(100, "WELCOME10")returns 90.0 once and 100 on every later call, for any customer, until the process restarts. - The lookup upper-cases the code and the reuse check does not. With one list,
"welcome10"and then"WELCOME10"both return 90.0. The code is used twice, which is what this change is meant to stop.
Consequences
- A guess, because I cannot see the callers: a checkout that passes on what the customer typed now fails on a typo, where it used to charge the full price.
"welcome10"in lower case used to get no discount and now gets 10%. That looks intended. Confirm it.
Missing cases
- The error path. An unknown code,
Noneand an empty string all throw. - The concurrent case. Two requests that rely on the default list block each other's codes. A guess about your deployment: with several worker processes each has its own list, so the same code is refused in one and accepted in the next.
Tests
- An unknown code and a missing code return the total unchanged.
- Two calls without
used_codesboth get the discount. - One code typed in two cases, with one list, is discounted once.
apply_discount(100, "SPRING25", [])returns 75.0. Nothing covers the new code.
More Coding prompts
3 of the 7 other prompts filed under Coding.
Trace a performance problem to its cause
Separates the slow thing from the thing you noticed.
Turn a README into something someone can follow
Rewrites project docs around what a newcomer actually gets stuck on.
Write tests for this function
Table-driven tests covering the boundaries, not just the happy path.
Coding tools and skills
3 of the 9 tools and 3 of the 7 skills filed under Coding, the same category as this prompt.
Aider
Pair programming with an LLM in the terminal, wired directly to git.
Claude Code
Anthropic's agentic coding tool for the terminal and IDE.
Cline
An open-source coding agent that runs inside VS Code with your own API key.
Code reviewer
Reviews a diff for defects, and refuses to pad the list with style opinions.
Commit message writer
Writes commit messages that explain why, from the staged diff.
Pull request description writer
Writes the PR description from the branch diff, aimed at the reviewer.
Guides that use this prompt
3 guides list this prompt under "Used in this tutorial".
Reviewing code an AI wrote
It compiles, the tests pass, and it reads well. That combination is exactly why it needs a different kind of review.
Claude Code guide: setup, CLAUDE.md, permissions and skills
Install Claude Code, write a short CLAUDE.md, choose a permission mode, then add hooks, skills and MCP servers. Each step comes from Anthropic's docs and links to the page.
Writing prompts that survive reuse
The prompt that worked brilliantly once often fails the second time. Usually for one of four reasons.