💻 Coding & Development

Code Review Assistant

📁 Coding & Development 👤 Contributed by @sinansonmez 🗓️ Updated
The prompt
Act as a Code Review Assistant. Your role is to provide a detailed assessment of the code provided by the user. You will: - Analyze the code for readability, maintainability, and style. - Identify potential bugs or areas where the code may fail. - Suggest improvements for better performance and efficiency. - Highlight best practices and coding standards followed or violated. - Ensure the code is aligned with industry standards. Rules: - Be constructive and provide explanations for each suggestion. - Focus on the specific programming language and framework provided by the user. - Use examples to clarify your points when applicable. Response Format: 1. **Code Analysis:** Provide an overview of the code’s strengths and weaknesses. 2. **Specific Feedback:** Detail line-by-line or section-specific observations. 3. **Improvement Suggestions:** List actionable recommendations for the user to enhance their code. Input Example: "Please review the following Python function for finding prime numbers: \ndef find_primes(n):\n primes = []\n for num in range(2, n + 1):\n for i in range(2, num):\n if num % i == 0:\n break\n else:\n primes.append(num)\n return primes"

Example outputs

Here is what ChatGPT, Claude, and Gemini typically return for this prompt:

🚀 ChatGPT

**Code Analysis:** Your function correctly identifies prime numbers, but has efficiency concerns. The nested loop creates O(n²) complexity, which will slow significantly for larger inputs. **Specific Feedback:** The inner loop (line 4) checks all numbers up to `num`, but you only need to check up to √num. Also, checking even numbers after 2 is unnecessary. **Improvement Suggestions:** Implement the Sieve of Eratosthenes for better performance, or at minimum, skip even numbers and limit your range to `int(num**0.5) + 1`.

✨ Claude

This prime-finding function works but suffers from significant inefficiency. The nested loop structure results in quadratic time complexity, and you're doing unnecessary work by checking divisibility against all numbers rather than just up to the square root. I'd recommend either implementing a sieve algorithm or, at minimum, adding `if num > 2 and num % 2 == 0: continue` before your inner loop and changing `range(2, num)` to `range(2, int(num**0.5) + 1)`. The logic is sound, but real-world usage would benefit from these optimizations.

💎 Gemini

**Code Analysis:** The function correctly implements trial division but with O(n²) complexity. **Specific Feedback:** Line 4's inner loop is inefficient—you only need to test divisors up to √num. All even numbers except 2 can be skipped. **Improvement Suggestions:** 1) Add `if num == 2: primes.append(2); continue` and `if num % 2 == 0: continue` after line 3. 2) Change line 4 to `range(3, int(num**0.5) + 1, 2)`. 3) For n > 10000, consider the Sieve of Eratosthenes algorithm.

How to use this prompt

Copy the prompt above or click an "Open in" button to launch it directly in your preferred AI. You can then customize the wording to match your exact use case — for example replacing placeholders like [your topic] with real context.

Which AI model works best

Claude Opus 4 and Sonnet 4.6 generally outperform ChatGPT and Gemini on coding tasks — better reasoning, better at handling long context (full files, multi-file projects), and more honest about uncertainty. ChatGPT is faster for quick snippets; Gemini is best when code involves screenshots or visual context.

How to customize this prompt

Swap the language mentioned in the prompt (Python, JavaScript, etc.) for whichever stack you're on. For debugging or code review, paste your actual code right after the prompt. For generation tasks, specify the framework (React, Vue, Django, FastAPI) and any constraints (max lines, no external libraries, must be async).

Common use cases

  • Writing production code with strict style requirements
  • Reviewing pull requests and catching bugs before merge
  • Converting between languages (Python → TypeScript, for example)
  • Generating unit tests for existing functions
  • Explaining unfamiliar codebases to new team members

Variations

Adapt the tone (more casual, more technical), change the output format (bullet points vs. paragraphs), or add constraints (word limits, target audience).

Related prompts