Best Llama Prompt for Code Review
This optimized Llama prompt for code review helps you get professional-quality results in seconds. Perfect for coding professionals who want to leverage AI effectively.
๐The Optimized Prompt
You are a senior engineer conducting a thorough code review. **Task:** Review the provided code comprehensively. **Check for:** 1. **Bugs** - Logic errors, edge cases, null checks 2. **Security** - Vulnerabilities, injection risks, auth issues 3. **Performance** - Inefficiencies, memory leaks, N+1 queries 4. **Readability** - Naming, structure, comments, DRY 5. **Best practices** - Design patterns, SOLID, error handling **Format your response as:** - ๐ด Critical issues (must fix) - ๐ก Suggestions (should consider) - ๐ข What's done well - Refactored code (if needed) **Code to review:** ``` [PASTE YOUR CODE] ```
๐ฌExample Output
Here's an example of what Llama might generate using this prompt:
## Code Review Results
### ๐ด Critical Issues
**1. SQL Injection Vulnerability (Line 23)**
```javascript
// VULNERABLE
const query = `SELECT * FROM users WHERE id = ${userId}`;
// SECURE
const query = 'SELECT * FROM users WHERE id = $1';
const result = await db.query(query, [userId]);
```
**2. Missing Error Handling (Line 45)**
The async function doesn't have try/catch, causing unhandled promise rejections.
### ๐ก Suggestions
**1. Consider using constants for magic numbers**
```javascript
const MAX_RETRIES = 3; // Instead of hardcoded 3
```
**2. Function is too long (80+ lines)**
Consider breaking into smaller, testable functions.
### ๐ข What's Done Well
- Clear variable naming
- Good use of async/await
- Comprehensive input validation๐Prompt Performance
Scores are estimated based on prompt characteristics (not live model calls).
๐Why ChatGPT wins for this prompt
- โขVersatile across many use cases
- โขConsistent, reliable outputs
- โขStrong instruction following
๐กWhy This Prompt Works
- โColor-coded severity makes issues easy to prioritize
- โCovers security, performance, and maintainability
- โProvides concrete fixes, not just criticism
- โBalances critique with positive feedback
- โStructured format ensures thorough review
โFrequently Asked Questions
What makes this the best Llama prompt for code review?
This prompt is specifically optimized for Llama and code review tasks. It includes role assignment, clear structure, and specific output requirements that Llama responds to best, resulting in more accurate and useful outputs.
Can I customize this code review prompt?
Absolutely! Replace the placeholder text in brackets [LIKE THIS] with your specific details. The more context you provide, the better your results will be.
Does this prompt work with other AI models besides Llama?
Yes, while this prompt is optimized for Llama, it will work well with other AI models like ChatGPT, Claude, Gemini, and Llama. You may see slight variations in output style.
How do I get the best results from this prompt?
Fill in all placeholder sections with specific details, be clear about your desired outcome, and don't hesitate to ask for revisions if the first output isn't perfect. Iteration is key to great AI results.
