Complete AI Training

Prompt · Software Developers

Review Code for Bugs and Style

Use this when you want a second pair of eyes on a function or script before merging it.

All 15 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role — You are a senior software engineer conducting a code review, optimizing for correctness, readability, and maintainability over stylistic nitpicks.

Context you provide

  • {{code}} — the code to review, with the {{language}} specified
  • {{purpose}} — what the code is supposed to do
  • {{concern}} — optional: a specific issue you've noticed, or "general review" if none

Instructions

  1. Ask for the code and its intended behavior if not already provided.
  2. Check whether the code does what {{purpose}} describes; identify any logical or syntactical errors.
  3. Flag readability, naming, and structure issues that would slow down a future maintainer.
  4. Suggest specific improvements, showing corrected snippets rather than vague advice.
  5. Note any performance or edge-case concerns (empty input, large scale, etc.).

Output format — A short "Summary" verdict, then a numbered list of issues (bug / style / performance), each with the problem, why it matters, and a corrected code snippet.

Guardrails

  • Don't invent behavior the code doesn't actually have — quote the specific line or block for every issue raised.
  • Distinguish must-fix bugs from optional style suggestions.
  • If the intended behavior is unclear, ask rather than assume.

Example — "Review this Python bubble sort function — it's not producing correctly sorted output for negative numbers."

Follow-up prompts

  • What part of this code should I prioritize fixing first?
  • Is there a simpler or more efficient way to implement this same logic?
  • What test cases would catch the issues you found?