Back to Prompt Library
💻 Coding & DevIntermediate

Code Review Assistant

Runs pasted code through a structured senior-engineer review: security vulnerabilities and resource leaks first, then performance, then maintainability and style, with each finding explained rather than just flagged. The severity ordering matters — an unstructured "review this code" request tends to return style nitpicks while missing the SQL injection.

#code-review#best-practices#security#performance

The Prompt

Act as a senior software engineer conducting a thorough code review. Analyze the following [LANGUAGE] code:

```[LANGUAGE]
[PASTE CODE HERE]
```

Review for:

**Critical Issues:**
- Security vulnerabilities (injection, XSS, auth issues)
- Memory leaks or resource management problems
- Race conditions or concurrency bugs
- Error handling gaps

**Performance:**
- Time/space complexity concerns
- Unnecessary computations or allocations
- Database query optimization opportunities
- Caching possibilities

**Code Quality:**
- Violations of SOLID principles or DRY
- Naming clarity and consistency
- Function/method size and cohesion
- Testability concerns
- Documentation gaps

**Suggestions:**
Provide refactored code for each issue found, with explanations. Rate the overall code quality on a scale of 1-10.

Additional context: This is [CONTEXT - e.g., 'a production API endpoint', 'a frontend component', 'a data processing script'].

How to Customize It

Replace each bracketed placeholder with your own details before running the prompt. The more specific you are, the better the output — vague inputs produce generic results.

  • [LANGUAGE]Swap in your language.
  • [PASTE CODE HERE]Swap in your paste code here.
  • [CONTEXT - e.g., 'a production API endpoint', 'a frontend component', 'a data processing script']Swap in your context - e.g., 'a production api endpoint', 'a frontend component', 'a data processing script'.

When to Use It

  • Pre-review on your own pull requests before a human sees them — catching the obvious findings yourself keeps human review focused on design.
  • Auditing code you inherited or a dependency snippet you're about to vendor in.
  • Learning a new language by having idiomatic-usage issues in your code explained, not just corrected.

Tips for Better Results

  • 1Include the surrounding context (what calls this, what the inputs can be) — half of all real vulnerabilities depend on facts outside the pasted function.
  • 2Ask it to rank findings by severity and skip style comments if the code is prototype-stage; you can rerun with full strictness before merge.
  • 3Never paste code containing real secrets, tokens, or customer data — scrub first.

Want a Version Tailored to You?

Load this template into the AI Prompt Generator to customize it for your specific use case, or browse the full library for more.

Related Prompts