💻 Programmierung & Entwicklung

Code Review Assistant

📁 Programmierung & Entwicklung 👤 Beigetragen von @sinansonmez 🗓️ Aktualisiert
Der 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"

Beispiel-Ausgaben

So antworten ChatGPT, Claude und Gemini typischerweise auf diesen 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.

So nutzt du diesen Prompt

Kopiere den Prompt oben oder klicke einen "Öffnen in"-Button um ihn direkt in deiner bevorzugten KI zu starten. Du kannst den Text dann an deinen Anwendungsfall anpassen — z.B. Platzhalter wie [dein Thema] durch echten Kontext ersetzen.

Welches KI-Modell funktioniert am besten

Claude Opus 4 und Sonnet 4.6 performen bei Coding-Aufgaben meist besser als ChatGPT und Gemini — stärkeres Reasoning, besser mit langem Kontext (ganze Dateien, Multi-File-Projekte), und ehrlicher über Unsicherheit. ChatGPT ist schneller für Quick-Snippets; Gemini ist am besten wenn Code mit Screenshots oder visuellem Kontext zu tun hat.

Diesen Prompt anpassen

Tausche die im Prompt erwähnte Sprache (Python, JavaScript, etc.) gegen deinen Stack. Für Debugging oder Code-Review fügst du deinen echten Code direkt nach dem Prompt ein. Bei Generierungs-Aufgaben spezifiziere das Framework (React, Vue, Django, FastAPI) und Einschränkungen (max. Zeilen, keine externen Libraries, muss async sein).

Typische Anwendungsfälle

  • Production-Code mit strikten Style-Vorgaben schreiben
  • Pull Requests reviewen und Bugs vor dem Merge finden
  • Zwischen Sprachen konvertieren (Python → TypeScript z.B.)
  • Unit-Tests für bestehende Funktionen generieren
  • Unbekannte Codebases für neue Team-Mitglieder erklären

Variationen

Passe den Tonfall an (lockerer, technischer), ändere das Ausgabeformat (Aufzählungen vs. Absätze) oder füge Einschränkungen hinzu (Wortlimits, Zielgruppe).

Verwandte Prompts