Skip to main content

Claude/ChatGPT (or Cursor) Prompt to Run a Senior Code Review on a Diff

Senior-level code review of your git diff: prioritized must-fix blockers, follow-ups, and nits, each with file:line evidence and a minimal fix.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

It points a model at the output of git diff [base]..HEAD and asks for the review a tired-but-honest staff engineer would give: correctness, security against the OWASP Top 10, performance traps like N+1 queries and runaway memory, readability, and test coverage. Scoping to the diff is the whole trick — the model only judges what you actually changed, so it stays anchored to real lines instead of inventing problems in code it never saw.

The output contract is what makes it usable. Three ranked sections — Must fix (blocks merge), Should fix (follow-up PR), Nits — force triage instead of dumping every observation as equally urgent. Demanding file:line plus a minimal fix turns vague advice into something actionable in seconds, and "cite evidence, no praise, no filler, max 15 items" strips the congratulatory padding that makes most AI reviews unreadable.

When to use it

  • Before you open a PR, to catch blockers while the change is still cheap to fix.
  • As a second reviewer on a branch nobody else has time to look at.
  • On a large diff where you want the genuinely merge-blocking issues surfaced first.
  • During a security-sensitive change — auth, file uploads, query building, deserialization.
  • After an AI agent wrote the code, to audit it with a stricter, evidence-bound pass.
  • In CI as a pre-merge gate, piping the diff in and failing on any Must-fix item.

Example output

## Must fix (blocks merge)
1. app/Http/Controllers/OrderController.php:48 — raw `$request->id` interpolated
   into a DB::select string (SQL injection). Fix: bind it — `where('id', $id)`.
2. app/Services/Report.php:71 — N+1: `$orders` looped with `$o->customer->name`.
   Fix: eager load — `Order::with('customer')`.

## Should fix (follow-up PR)
3. app/Jobs/SyncFeed.php:33 — no retry/backoff on the HTTP call; a 500 loses the job.

## Nits
4. app/Models/Order.php:19 — `$casts` missing `total => 'decimal:2'`.

Pro tips

  • Set [base] to your real merge target — main, develop, or a release branch. The review is only as honest as the diff; the wrong base hides or invents changes.
  • For a feature branch, origin/main beats main so you compare against what's deployed, not a stale local ref.
  • If the diff is huge, run --stat first, then review the highest-risk files individually — context limits silently truncate giant diffs and you lose the tail.
  • Pair it with your test suite: take each Must-fix item, write a failing test that proves it, then fix. The review finds the bug; the test stops it returning.
  • Tune the lenses for the change — drop "performance" on a docs-only diff, or add "race conditions" and "idempotency" when touching queue jobs or webhooks.

Frequently Asked Questions

What should I put in the [base] variable?
The branch or ref you're merging into — usually main, develop, or origin/main for a feature branch. git diff [base]..HEAD then shows only your changes versus that target, which is exactly what the review judges. Pick the wrong base and you'll review unrelated commits or miss your own.
Do I paste the diff, or does the model run git itself?
Either, depending on your setup. In an agent or CLI with shell access (like Claude Code or Cursor), it runs git diff itself. In a plain chat window, run the command and paste the output. The prompt is written around the diff text, so as long as the model sees that output, it works.
Why cap it at 15 items and forbid praise?
To keep the report scannable and force ranking. Without a cap, models list every minor observation as if equal; the limit and the Must/Should/Nit buckets push the real blockers to the top. Banning praise and filler removes the 'looks great overall!' padding so you read fixes, not flattery.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Claude Code Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support