Plan Before Code Prompt
A planning prompt that covers business, domain, tech design and steps, then lists the decisions it needs from you.
- Claude Code
- Cursor
- Claude.ai
1 file2.3 KB.md
A review prompt that reports bugs with file, line, a failure scenario, severity and a fix, and skips style nitpicks.
By Matthews WongUpdated
Key takeaway
Paste this with a diff, a branch or a pull request. The agent reads the changed files in full, then looks for bugs, broken edge cases, missing error handling, security issues and missing tests. Each finding has a severity, a file and line, a concrete failure scenario and a suggested fix. It leaves style alone unless the style hides a bug, and it says plainly when it finds nothing.
Exactly what the download contains. Read it first, then copy or download.
Review this change for correctness. I want the bugs, not a style pass.
What to review: [THE DIFF, BRANCH, PULL REQUEST OR FILES]
What the change is meant to do: [ONE OR TWO SENTENCES, OR THE TICKET TEXT]
## Before you judge
Read every changed file in full, not only the changed lines. Read the callers of anything whose behavior or signature changed, and the tests that cover it. If you only have the diff and need more to be sure, ask for the file instead of assuming what it contains.
## Look for, in this order
1. **Bugs:** wrong logic, wrong conditions, off-by-one errors, null or undefined values, wrong types, race conditions, broken callers.
2. **Broken edge cases:** empty input, zero, very large input, duplicates, retries, time zones, concurrent requests, partial failure.
3. **Missing error handling:** swallowed errors, unchecked results, no timeout, no rollback, failures the user never sees.
4. **Security:** unvalidated input, injection, missing authorization checks, secrets in code or logs, data shown to the wrong user.
5. **Missing tests:** changed behavior with no test, or tests that would still pass if the code were wrong.
6. **Intent:** compare the change with what it is meant to do, and name anything missing or extra.
## Report each finding like this
- **Severity:** blocker (wrong result, data loss, security), major (fails in a realistic case) or minor (unlikely, or low impact)
- **Where:** file path and line
- **What fails:** a concrete scenario: this input or this sequence, the result now, the result expected
- **Fix:** the smallest change that solves it, as a short snippet or a clear description
Start the reply with one line: the count per severity, and whether you would merge it. Then list the findings, blockers first.
## Do not
- No style, naming or formatting comments, unless the style hides a bug. If it does, say which bug.
- No finding without a failure scenario. If you cannot describe how it breaks, put it under "Questions", not under findings.
- Do not report a bug because you did not read the code that handles it. Check first.
- Do not pad the list. If you find nothing, say "No correctness problems found", then list what you checked.
- Do not edit any file. This is a review.
End with "Not verified": anything you could not confirm, such as code you could not see or tests you could not run.
In Claude Code or Cursor, name the branch or the commit range and let the agent read the files. In a chat window, paste the diff and, for anything that matters, the full changed files too.
Fill the second placeholder with one or two sentences or the ticket text. Without the intent, the agent can check whether the code is consistent, but not whether it does the right thing.
The reply opens with the count per severity and whether the agent would merge. Findings follow, blockers first. Each one gives a scenario you can turn into a test: the input, the result now and the result expected.
Try the failure scenario for each blocker and major finding. A review model can be wrong about code it read too quickly. Fix what you confirm, then run the prompt again on the new diff.
The agent reads each changed file in full, the callers of anything whose behavior changed, and the covering tests. Many real bugs sit outside the changed lines: a caller that still passes the old argument, or a test that no longer tests anything.
Bugs, edge cases, error handling, security, tests, then intent. The order puts the things that cause incidents ahead of everything else, and the lists under each one name concrete cases such as retries, time zones and partial failure.
Each finding must say which input or sequence breaks, the result now and the result expected. If the agent cannot describe how it breaks, the item goes under Questions. This rule removes most vague warnings from the list.
Blocker means a wrong result, data loss or a security problem. Major fails in a realistic case. Minor is unlikely or low impact. With definitions, the top of the list is what you must fix before merging.
The prompt tells the agent not to pad the list and to say No correctness problems found, followed by what it checked. A closing Not verified section lists what it could not confirm, so a clean result does not claim more than it covers.
Short answers before you download it.
Free lessons and articles on this site that explain the ideas behind it.
A planning prompt that covers business, domain, tech design and steps, then lists the decisions it needs from you.
1 file2.3 KB.md
A read-only prompt that maps an unfamiliar repository: what it does, how to run it, how a request flows, what is risky.
1 file2.3 KB.md
A debugging prompt that makes the agent reproduce the bug and prove the cause before it touches any code.
1 file2.3 KB.md