Prompt

Code Review Assistant

code reviewbest practicesquality

Code Review Assistant: AI-Powered Code Quality Analysis

Code reviews are essential for maintaining code quality, catching bugs early, and ensuring security—but they're also time-consuming. Whether you're working solo without a team to review your code, or you want a quick pre-review check before submitting a pull request, AI can help identify issues you might miss.

Full Prompt
Perform a comprehensive code review covering security, performance, code quality, and adherence to best practices, then deliver prioritized, actionable improvement recommendations with clear explanations.

REVIEW METHODOLOGY:

1. Security Analysis
   - Identify injection vulnerabilities (SQL, XSS, command injection, path traversal)
   - Check for hardcoded secrets, credentials, or API keys
   - Evaluate input validation and sanitization completeness
   - Assess authentication and authorization logic for flaws
   - Flag unsafe deserialization, insecure cryptographic usage, or exposed sensitive data
   - Check for dependency vulnerabilities or outdated library patterns

2. Performance Evaluation
   - Identify unnecessary computations, redundant loops, or O(n^2+) operations that could be optimized
   - Check for memory leaks, unbounded growth, or excessive allocations
   - Evaluate database query efficiency (N+1 queries, missing indexes, full table scans)
   - Assess caching opportunities and unnecessary I/O operations
   - Flag blocking calls in async contexts or missing concurrency controls

3. Code Quality and Style
   - Evaluate naming conventions (variables, functions, classes) for clarity and consistency
   - Assess function/method length and single-responsibility adherence
   - Check for code duplication that should be abstracted
   - Review error handling completeness and consistency
   - Evaluate comment quality: missing where needed, excessive where code should be self-documenting
   - Verify consistent formatting and idiomatic patterns for the language

4. Best Practices and Architecture
   - Assess SOLID principles adherence where applicable
   - Check for proper separation of concerns
   - Evaluate testability of the code structure
   - Identify missing type hints, null checks, or defensive programming gaps
   - Flag anti-patterns specific to the programming language or framework

OUTPUT CONSTRAINTS:
- Categorize every finding as CRITICAL, WARNING, or SUGGESTION
- For each finding: state the problem, explain WHY it matters, and provide a concrete code fix
- Provide a summary scorecard at the end (Security / Performance / Quality / Best Practices each rated Low/Medium/High concern)
- If the code is solid in a category, say so briefly rather than inventing issues
- Prioritize findings by impact: security risks first, then correctness bugs, then performance, then style

FORMAT:
## Review Summary
[1-2 sentence overall assessment]

## Findings

### CRITICAL
[numbered list with code snippets]

### WARNING
[numbered list with code snippets]

### SUGGESTION
[numbered list with code snippets]

## Scorecard
| Category | Rating | Notes |
|----------|--------|-------|

## Refactored Code (if applicable)
[Full corrected version if changes are substantial]

---

MY INFO:

Programming Language: (required)

Code to Review: (required)

Additional Context (what this code does, where it runs): (optional)

Specific Concerns (anything you already suspect): (optional)

This Code Review Assistant prompt turns ChatGPT into your personal code reviewer, analyzing your code for security vulnerabilities, performance issues, style problems, and best practices violations. It's like having a senior developer review your code 24/7.

What is the Code Review Assistant Prompt?

The Code Review Assistant is an AI prompt that performs comprehensive code analysis across multiple dimensions: security, performance, code style, and industry best practices. You simply paste your code and specify the programming language, and ChatGPT provides detailed feedback with specific improvement suggestions.

Who it's for:

  • Solo developers who need a second pair of eyes
  • Junior developers learning best practices
  • Teams wanting to catch issues before formal code review
  • Open-source contributors preparing pull requests
  • Anyone learning a new programming language

Key benefits:Security-first: Identifies common vulnerabilities (SQL injection, XSS, auth issues) ✓ Performance optimization: Spots inefficient algorithms and memory leaks ✓ Style consistency: Enforces language-specific conventions and best practices ✓ Learning tool: Explains why changes are needed, not just what to change ✓ Multi-language: Works with Python, JavaScript, Java, Go, Rust, C++, and more

How to Use This Prompt

Step 1: Prepare your code

Copy the code segment you want reviewed. This works best with:

  • Individual functions (10-50 lines)
  • Class definitions
  • API endpoint handlers
  • Database queries
  • Algorithm implementations

For very large files (500+ lines), consider breaking them into logical sections.

Step 2: Fill in the prompt

Specify:

  • Programming Language: Python, JavaScript, TypeScript, Java, Go, Rust, C#, PHP, etc.
  • Code to Review: Paste your complete code block

Example input:

Programming Language: JavaScript

Code to Review:
function getUserData(userId) {
  const query = "SELECT * FROM users WHERE id = " + userId;
  const result = db.execute(query);
  return result[0];
}

Step 3: Analyze the feedback

ChatGPT will review your code across four dimensions:

  1. Security Vulnerabilities: SQL injection, XSS, insecure dependencies, etc.
  2. Performance Issues: O(n²) where O(n) is possible, unnecessary loops, memory inefficiency
  3. Code Style: Naming conventions, formatting, structure
  4. Best Practices: Error handling, validation, type safety, maintainability

Each issue comes with:

  • Severity level (Critical/High/Medium/Low)
  • Clear explanation of the problem
  • Specific improvement suggestion
  • Example of corrected code

Step 4: Implement improvements

Apply the suggested changes to your code. For learning, try implementing fixes yourself before looking at the AI's code examples.

Best Practices & Tips

Be specific about context: Add "This is a REST API endpoint" or "This function processes user payments" to get context-aware reviews

Specify your tech stack: Mention frameworks like "React component" or "Django view" for framework-specific advice

Ask for prioritization: Add "prioritize security issues" or "focus on performance" if you have specific concerns

Include error cases: Paste code that handles edge cases so the AI can review error handling logic

Request style guides: Ask to "review against Airbnb JavaScript style guide" or "follow PEP 8 for Python"

Compare alternatives: Ask "suggest alternative approaches" to learn different design patterns

Iterative reviews: After fixing issues, run the prompt again to verify your changes

Real-World Use Cases

Use Case 1: Security Audit Before Deployment

Scenario: A developer has written an authentication system and wants to ensure there are no security holes before deploying to production.

Solution: Run the Code Review Assistant on all auth-related functions, specifically asking it to "focus on security vulnerabilities and authentication best practices." The AI identifies issues like weak password validation, missing rate limiting, and insecure session storage.

Use Case 2: Learning Best Practices in a New Language

Scenario: A Python developer is learning Go and wants to ensure their code follows Go idioms and conventions.

Solution: After writing Go code, use the prompt to review against Go best practices. The AI explains Go-specific patterns like error handling, goroutine usage, and interface design.

Use Case 3: Performance Optimization

Scenario: An application has slow response times, and the developer suspects inefficient database queries or algorithms.

Solution: Submit the suspected code sections with "focus on performance and efficiency." The AI identifies N+1 query problems, unnecessary loops, and suggests caching strategies.

Use Case 4: Pre-Pull Request Check

Scenario: A developer wants to catch obvious issues before submitting a PR to avoid back-and-forth with reviewers.

Solution: Run the Code Review Assistant on all changed files as a pre-commit check. Fix identified issues before creating the PR, leading to faster approval times.

Frequently Asked Questions

Q: What programming languages does this work with? A: ChatGPT can review code in virtually any language: Python, JavaScript, TypeScript, Java, C#, C++, Go, Rust, PHP, Ruby, Swift, Kotlin, and more. Just specify the language in the prompt.

Q: Can it detect all security vulnerabilities? A: While it catches common vulnerabilities (SQL injection, XSS, CSRF, insecure deserialization), it's not a replacement for dedicated security tools like static analysis scanners or penetration testing. Use it as a first line of defense.

Q: How much code can I review at once? A: For best results, review 10-100 lines at a time. ChatGPT can handle larger files, but focused reviews on specific functions or classes provide more detailed feedback.

Q: Will it understand framework-specific code? A: Yes! Mention the framework ("React component", "Django view", "Express.js route") and ChatGPT will provide framework-aware suggestions.

Q: Can I use this for code interview prep? A: Absolutely! Practice solving coding challenges, then use this prompt to review your solution for optimization opportunities and best practices you might have missed.

Q: Does it provide refactored code examples? A: Yes, the prompt asks for "improvements with explanations," which typically includes both written suggestions and code examples showing the corrected version.

Q: Can it review SQL queries? A: Yes! Specify "Programming Language: SQL" and paste your query. The AI will check for injection vulnerabilities, performance issues (missing indexes), and query optimization opportunities.

Q: How is this different from automated linters? A: Linters catch syntax and style issues. This AI review also analyzes logic, architecture, security implications, and suggests alternative approaches—things static analysis tools can't do.

Related Prompts You Might Like

  • Bug Debugging Helper: Diagnose and fix runtime errors and unexpected behavior
  • Unit Test Generator: Create comprehensive test cases for your code
  • Refactoring Assistant: Improve code structure while maintaining functionality
  • API Documentation Generator: Auto-generate clear API documentation from code
  • Git Commit Message Writer: Write descriptive commit messages following conventions

Start Reviewing Your Code with AI Today

Every developer benefits from code review, but not everyone has access to senior developers or team reviewers. This free ChatGPT prompt gives you instant, detailed feedback on security, performance, style, and best practices—helping you write better code faster.

Whether you're preparing for a code interview, learning a new language, or just want to catch bugs before deployment, this Code Review Assistant prompt is an essential tool in your development workflow.

Copy the prompt, paste your code, and get expert-level feedback in seconds.