AI Code Review Prompt — Get Sorted, Actionable Feedback

Coding prompt

AI Code Review Prompt — Get Sorted, Actionable Feedback

Most ‘review this code’ prompts return surface-level praise followed by a wall of unsorted style nits. This template — built from senior-developer review patterns — gets you structured feedback sorted by severity, with specific line numbers and code-snippet fixes you can apply directly.

✓ Works in ChatGPT, Claude, Gemini ✓ Tested template ✓ Copy + paste ready

The template

Replace the [bracketed] fields with your specifics. Send to any AI chat.

Review this code as a senior [language] dev would.

For each issue:
- Severity: critical / major / minor / nitpick
- What's wrong (specific line)
- Why it's wrong (the principle, not just the rule)
- The fix as a code snippet

Sort the output by severity. Skip stylistic-only nits unless they obscure intent.

CODE:
[paste your code here]

How to use it

  1. Replace `[language]` with your actual language (Python, JavaScript, Go, Rust, etc.) so the model picks up language-specific conventions.
  2. Paste your code block where it says `[paste your code here]`. Keep it focused — under 200 lines per request gets better results than dumping a whole file.
  3. Send to ChatGPT, Claude, or Gemini. Per developer-focused reviews, Claude tends to give the best code reviews; ChatGPT is close behind.

Example output

Here’s an example of what a quality AI returns when you run this template:

🔴 CRITICAL — Line 14: Unhandled None case in `parse_input()` The function returns None when the input string contains only whitespace, but the caller on line 32 calls `.upper()` on the result. AttributeError waiting to happen. Fix: “`python def parse_input(s: str) -> str: s = s.strip() if not s: raise ValueError(“input cannot be empty or whitespace-only”) return s “` 🟡 MAJOR — Line 47: SQL string interpolation You’re using f-string to insert `user_id` directly into SQL. Even though `user_id` looks numeric, this is the pattern that becomes a SQL injection 3 months from now when someone adds a string field. Fix: parameterized query. “`python cursor.execute(“SELECT * FROM users WHERE id = %s”, (user_id,)) “` 🟢 MINOR — Line 88: Magic number `if retries > 5:` — extract `MAX_RETRIES = 5` as a module constant.

Why this prompt works

Severity sorting matters more than completeness.

Without ‘sort by severity’, the model lists issues in code order — which buries the critical bugs under nitpicks. A senior reviewer always front-loads the dangerous stuff.

Naming the four severity levels disciplines the output.

Without explicit categories, models hedge with ‘this could be better’ for everything. Forcing critical/major/minor/nitpick forces a judgment call per issue.

‘Skip stylistic nits unless they obscure intent’ kills the noise.

The default model behavior is to mention every style violation. This line tells it that linter-level feedback is unwanted unless the style actively misleads a reader.

The ‘why’ constraint stops shallow reviews.

Asking for the principle (not just the rule) forces the model to demonstrate understanding rather than parroting standard advice.

Which AI to use

**Claude** is the consensus pick for code review per developer-focused reviews and the JetBrains research blog. **ChatGPT** is close behind and often better at agentic, multi-step debugging. **Gemini** trails on this specific task per the same reviewers.

Read the full comparison in ChatGPT vs Claude vs Gemini in 2026 →

Related prompts

Debug code prompt →When you have an error or bug, not just code to review.SQL query prompt →When you need to write a SQL query from an English description. All 27 prompt templates + free generator → Pick a category, fill in the blanks, copy your prompt.

Frequently asked questions

Which AI is best for code review?

Per developer-focused reviews (Simon Willison’s blog, JetBrains research, Latent Space podcast), Claude is the consensus pick for code review and refactoring. ChatGPT is close behind and better for multi-step agentic debugging. Gemini lags slightly on this task.

Can I use this for code I didn’t write?

Yes — it’s actually one of the best uses. The ‘review as a senior dev would’ framing helps the AI explain unfamiliar patterns and flag bugs without being defensive about authorship.

How long can my code block be?

Under 200 lines per request gets the sharpest review. For larger files, send 100-200 line chunks separately. Models lose attention on very long inputs even when the context window technically fits.

Can the AI fix my code automatically?

Yes — add ‘Apply your fixes and return the corrected code at the end’ to the prompt. But always read the diff before accepting; AI sometimes introduces new bugs while fixing old ones.

Does this work for code review of pull requests?

It works on the code itself. For PR-level review (commit history, dependency changes, integration concerns), use a more specific prompt that includes the PR context.

Build any prompt in 30 seconds

Free tool, no signup, runs in your browser. Pick a category, fill in the blanks, copy your prompt.

Try the prompt generator → Read the full guide