Code reviewer

A prompt that asks an AI to review pasted code for bugs, security issues and readability, list issues by severity, and return an improved version.

  • 🤖 Claude, ChatGPT, Gemini
  • 🗂️ Coding

FoxaMind original · written and tested by the FoxaMind team

See examples
Code reviewer — prompt preview

The prompt

prompt
Review the following code for bugs, security issues and readability. List issues by severity, then show an improved version:

[paste code]

What it is

Code reviewer is a short AI prompt that takes a block of code and asks for a review covering three areas: bugs, security issues and readability. The response should list the issues ordered by severity and then show an improved version of the code. It has a single placeholder, [paste code], where the code to review goes.

Who it's for

  • Developers who want a quick second look at code before committing or opening a pull request
  • Anyone who wants issues ranked by severity so they can decide what to fix first
  • Learners who want to see an improved version of their code next to a list of its problems

Requirements

Requirements

  • Access to an AI chat assistant that can accept the prompt as text
  • The code you want reviewed, pasted in place of [paste code]

Examples

Python function building a SQL query

Prompt
prompt
Review the following code for bugs, security issues and readability. List issues by severity, then show an improved version:

def get_user(db, username):
    query = "SELECT * FROM users WHERE name = '" + username + "'"
    cursor = db.cursor()
    cursor.execute(query)
    return cursor.fetchone()

Expected output: A severity-ordered list of issues (such as building the query by string concatenation), followed by a revised version of the function.

JavaScript loop with unclear logic

Prompt
prompt
Review the following code for bugs, security issues and readability. List issues by severity, then show an improved version:

function f(a) {
  var r = [];
  for (var i = 0; i <= a.length; i++) {
    if (a[i] % 2 == 0) r.push(a[i] * 2);
  }
  return r;
}

Expected output: A list of issues ranked by severity (for example the loop bound and the unclear names), followed by a cleaner version of the function.

Node.js Express route handler

Prompt
prompt
Review the following code for bugs, security issues and readability. List issues by severity, then show an improved version:

app.post('/login', (req, res) => {
  const user = users.find(u => u.email == req.body.email);
  if (user && user.password == req.body.password) {
    res.send('Welcome ' + user.name);
  } else {
    res.send('Wrong');
  }
});

Expected output: Issues ordered by severity covering the bugs, security and readability aspects of the handler, then an improved version of the route.

Pros & cons

Pros

  • Pro:Covers bugs, security issues and readability in one request
  • Pro:Issues are listed by severity, which helps with prioritizing fixes
  • Pro:Includes an improved version of the code, not just a critique
  • Pro:Short and simple, with only one placeholder to fill in

Cons

  • Con:Does not specify a programming language, framework or context, so the review depends on what the code itself shows
  • Con:Does not define the severity scale or the output format
  • Con:Only the pasted code is reviewed; the prompt gives no way to supply surrounding project context

Tips

  • Paste the complete function or file section so the review has enough to work with
  • Put the code on separate lines after the instruction, as in the original prompt
  • Compare the improved version with your original before adopting changes

Variations

  • Replace the review areas in the instruction (bugs, security issues, readability) with a different set of concerns
  • Keep the same structure but change the output request, for example asking only for the issue list without the improved version