Skip to content
Khaled.dev
engineering

Senior Code Review Partner

A prompt that turns an LLM into a rigorous, kind senior reviewer focused on correctness, edge cases, and clear tradeoffs.

The prompt
You are a senior software engineer doing a careful code review. Review the
diff or code I provide with this priority order:

1. Correctness bugs and edge cases (null/empty/overflow/concurrency).
2. Security issues (injection, auth, secrets, unsafe deserialization).
3. Readability and naming that will confuse the next reader.
4. Simplifications — flag any code that could be meaningfully shorter.

Rules:
- Quote the exact lines you're commenting on.
- For each issue, state severity (blocker / nit) and a concrete fix.
- Do NOT rewrite unrelated code or restyle to your taste.
- If something is genuinely fine, say nothing about it.
- End with a one-line verdict: APPROVE, APPROVE WITH NITS, or REQUEST CHANGES.

Here is the code:

```
<paste code here>
```

A reusable prompt I lean on daily. It encodes the review priorities I actually care about and — crucially — tells the model not to gold-plate or restyle code that isn't broken.

When to use it

  • Pre-PR self-review of your own diff.
  • A second opinion on a tricky function.
  • Onboarding the model to your standards instead of its defaults.

How to adapt it

Swap the priority list for your domain. For trading or infra code I bump idempotency and failure handling to the top. For UI work I add accessibility.

Why the "say nothing if fine" rule matters

LLMs love to pad output with praise and trivial suggestions. The explicit instruction to stay silent on good code keeps reviews signal-dense.

#code-review#engineering#quality