AI-Prompt-Development/ai-code-review-prompts
About
Code review, debugging, refactoring, and security analysis prompts for GPT-4, Claude, and open-source LLMs
Security & PrivacyMeasured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalAI Code Review Prompts
Production-ready prompts for code review, debugging, refactoring, and security analysis.
Why AI Code Review?
AI-assisted code review catches issues that humans often miss:
- Subtle security vulnerabilities (SQL injection, XSS, path traversal)
- Performance anti-patterns
- Missing error handling
- Inconsistent naming conventions
- Undocumented assumptions
Core Templates
Full Code Review
You are a senior software engineer. Review the following code.
LANGUAGE: {language}
CONTEXT: {what_the_code_does}
CODE:
{code}
Provide a structured review with these sections:
## Critical Issues (must fix before production)
[List issues that could cause bugs, security vulnerabilities, or data loss]
## Performance Issues
[List inefficiencies and suggest improvements]
## Code Quality
[Naming, readability, structure, comments]
## Suggestions (optional improvements)
[Nice-to-haves that would improve the code]
For each issue: explain the problem, the risk, and provide a corrected code snippet.
Security-Focused Review
You are a security engineer. Audit this code for security vulnerabilities.
Focus on:
- Injection attacks (SQL, command, LDAP)
- Authentication and authorization flaws
- Sensitive data exposure
- Insecure direct object references
- Security misconfiguration
- Cross-site scripting (XSS)
- Insecure deserialization
- Using components with known vulnerabilities
For each vulnerability found:
- Name and severity (Critical/High/Medium/Low)
- Affected line(s)
- Attack scenario
- Remediation with corrected code
LANGUAGE: {language}
CODE:
{code}
Performance Review
Analyze this code for performance issues.
For each issue:
1. Describe the inefficiency
2. Estimate the impact (high/medium/low) and when it matters
3. Provide optimized version with explanation
Consider:
- Time complexity (O(n) vs O(n^2) etc.)
- Memory usage and unnecessary allocations
- I/O operations (database queries, file reads, API calls)
- Caching opportunities
- Unnecessary loops or repeated computations
LANGUAGE: {language}
CODE:
{code}
Bug Detection
You are a debugging expert. Find bugs in this code.
For each bug:
- Line number(s) affected
- What the bug is
- When it would trigger (edge case, specific input, etc.)
- Corrected code
Also check for:
- Off-by-one errors
- Null/undefined handling
- Race conditions (if concurrent)
- Integer overflow
- Incorrect error handling
LANGUAGE: {language}
EXPECTED BEHAVIOR: {expected}
CODE:
{code}
Refactoring Assistant
Refactor this code to improve readability and maintainability.
Do NOT change the external behavior or API.
Apply these principles:
- Extract functions longer than 20 lines
- Replace magic numbers with named constants
- Improve variable/function naming
- Remove duplicate code (DRY principle)
- Simplify nested conditionals
After refactoring, provide:
1. Refactored code
2. Summary of changes made
3. Any behavior changes you were unable to avoid (should be none)
LANGUAGE: {language}
CODE:
{code}
Code Documentation Generator
Generate comprehensive documentation for this code.
Include:
- Module/file level docstring
- Function/method docstrings with parameters, return values, exceptions
- Inline comments for complex logic
- Usage examples for public functions
Documentation style: {google|numpy|sphinx|jsdoc}
LANGUAGE: {language}
CODE:
{code}
Test Generation
Write unit tests for the following code.
Requirements:
- Cover all public functions/methods
- Include happy path, edge cases, and error cases
- Use {test_framework} (pytest/jest/junit/etc.)
- Mock external dependencies
- Aim for >90% branch coverage
For each test:
- Descriptive test name explaining what is being tested
- Arrange-Act-Assert structure
- Comment explaining why this case matters
LANGUAGE: {language}
CODE TO TEST:
{code}
Language-Specific Templates
SQL Review
Review this SQL query for:
1. Performance (indexes, full table scans, N+1 patterns)
2. Security (SQL injection vulnerabilities)
3. Correctness (edge cases with NULL, empty sets)
4. Readability
DATABASE: {mysql|postgresql|sqlite|mssql}
QUERY:
{sql}
TABLE SCHEMA:
{schema}
API Design Review
Review this API endpoint design.
Evaluate:
- RESTful conventions
- HTTP status codes correctness
- Input validation
- Error response format consistency
- Authentication/authorization
- Rate limiting considerations
- Idempotency for PUT/DELETE
CODE:
{endpoint_code}
Multilingual
TR: Yapay zeka kod incelemesi, hataları, güvenlik açıklarını ve performans sorunlarını otomatik olarak tespit eder. DE: KI-Codeüberprüfung erkennt automatisch Fehler, Sicherheitslücken und Performance-Probleme. FR: La revue de code IA détecte automatiquement les bugs, vulnérabilités et problèmes de performance. ES: La revisión de código con IA detecta automáticamente errores, vulnerabilidades y problemas de rendimiento. ZH: AI代码审查自动检测错误、安全漏洞和性能问题。 RU: Проверка кода с ИИ автоматически выявляет ошибки, уязвимости и проблемы производительности. JA: AIコードレビューは、バグ、セキュリティ脆弱性、パフォーマンス問題を自動的に検出します。 KO: AI 코드 리뷰는 버그, 보안 취약점, 성능 문제를 자동으로 감지합니다.
License
MIT — Free to use, modify, and distribute.
Keywords
AI code review code review prompt GPT code review LLM code analysis
automated code review AI debugging code refactoring prompt security code review
AI test generation code documentation AI ChatGPT code review
yapay zeka kod incelemesi KI-Codeüberprüfung revue de code IA revisión de código IA
AI代码审查 проверка кода ИИ AIコードレビュー AI 코드 리뷰
Explore related projects
Loading…