# Code Review Prompt for Claude and ChatGPT: Free Copy-Paste

> Free code review prompt for Claude Code, Cursor and ChatGPT. It finds bugs, edge cases and security issues, each with file, line and a failure scenario.

URL: https://www.matthewswong.com/en/toolkit/code-review-prompt/

- Author: Matthews Wong (https://www.matthewswong.com/en/about/)
- Updated: 13 November 2026

> **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.

- Type: Prompt
- Works with: Claude Code, Cursor, Claude.ai, ChatGPT
- Download: [code-review-prompt.md](https://www.matthewswong.com/downloads/toolkit/code-review-prompt/code-review-prompt.md) (2.3 KB)
- License: Free to use, change and share, at work too.

## The file

Exactly what the download contains. Read it first, then copy or download.

### code-review-prompt.md

```markdown
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.
```

## Use it when

- You want a second pass on your own branch before you open a pull request.
- An agent wrote the change and you need a review that did not write it.
- AI reviews keep giving you naming and formatting comments and miss the bugs.
- You review a colleague's pull request and want a list of things to verify yourself.

## From download to working

1. **Give it the change.** 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.
2. **Say what the change is meant to do.** 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.
3. **Read the first line, then the blockers.** 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.
4. **Verify before you fix.** 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.

## Why it is written this way

- **It reads whole files, not only the 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.
- **A fixed order of concerns.** 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.
- **No finding without a failure scenario.** 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.
- **Severity has definitions.** 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.
- **It is allowed to find nothing.** 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.

## What goes wrong

- With only a pasted diff, the agent cannot see the callers or the tests. Expect more items under Not verified, and paste the files it asks for.
- A finding is a claim, not a fact. Run the failure scenario before you change code because of it.
- A review by the same session that wrote the code tends to agree with itself. Start a fresh session for the review.
- It does not replace a human reviewer, tests or CI. It does not run the code unless you ask, and it knows nothing about decisions that were never written down.

## FAQ

### What is a good prompt for AI code review?

One that says what to look for, in what order, and what a finding must contain. This prompt puts correctness first and requires a severity, a file and line, a concrete failure scenario and a suggested fix for every finding. It also tells the agent what to leave out.

### How do I stop the AI from nitpicking style in a review?

Say it in the prompt and give it a test for what counts. This one bans style, naming and formatting comments unless the style hides a bug, and requires a failure scenario for every finding. A comment about a variable name cannot pass that test.

### Should I paste the diff or the whole files?

Give it both where you can. The diff shows what changed, and the full files show whether the change is correct in its surroundings. In an agent that can read the repository, name the branch and it will read the files and their callers itself.

### Can I trust the result when it finds nothing?

Trust it for what it lists as checked, and no further. The reply ends with a Not verified section naming the code it could not see and the tests it could not run. A clean review of a diff is weaker than passing tests, so keep both.

## Learn what this file packages

- Free lesson: [Claude Code Subagents Examples: When to Delegate a Task](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-subagents-examples/)
- Free lesson: [Claude Code Git Workflow: Safe Commits, PRs and Push Rules](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-git-workflow-safe-commits/)
- Free lesson: [Claude Code Headless Mode: claude -p With a Pass/Fail Gate](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-headless-pass-fail-gate/)
- [AI Code Review as a CI Merge Gate: What Should Block](https://www.matthewswong.com/en/blog/ai-code-review-merge-gate-ci/)
- [AI Writer-Reviewer Pattern for Coding Agents](https://www.matthewswong.com/en/blog/ai-writer-reviewer-agent-pattern/)
- [Code Review That Actually Works: A Developer's Process Guide](https://www.matthewswong.com/en/blog/code-review-process-developer/)
- [AI Code Review Tools Compared for 2026](https://www.matthewswong.com/en/blog/ai-code-review-tools-compared/)

[All toolkit items](https://www.matthewswong.com/en/toolkit/)

---

- HTML version: https://www.matthewswong.com/en/toolkit/code-review-prompt/
- Bahasa Indonesia: https://www.matthewswong.com/id/toolkit/code-review-prompt/
- Site index for agents: https://www.matthewswong.com/llms.txt
- Sitemap: https://www.matthewswong.com/sitemap.xml
- API description (OpenAPI): https://www.matthewswong.com/openapi.json
