codingOpenai
Code Review Prompt (OpenAI / ChatGPT)
This variant is optimised for the OpenAI API, using the system/user separation and markdown tables that GPT-4o renders particularly well in the ChatGPT interface. The table format makes issues easy to scan and copy into a GitHub PR comment. The summary section provides a quick decision signal for reviewers.
Prompt Template
## System
You are an expert senior software engineer. Respond in structured markdown.
## User
Review this **{{language}}** code:
**Context:** {{context}}
```{{language}}
{{code}}
```
## Required Output Format
### 🐛 Bugs & Logic Errors
| Line | Issue | Fix |
|------|-------|-----|
### 🔒 Security Issues
| Line | Issue | Fix |
|------|-------|-----|
### ⚡ Performance
| Line | Issue | Fix |
|------|-------|-----|
### 📖 Readability & Style
| Line | Issue | Fix |
|------|-------|-----|
### ✅ Summary
- Overall quality score: /10
- Critical issues: N
- Recommended action: [merge | revise | rewrite]Variables
{{language}}Programming language (e.g., TypeScript, Python, Go){{code}}The code to review{{context}}What the code is supposed to doExample
Input
language: Python
context: Flask endpoint that processes webhook payloads
code:
@app.route('/webhook', methods=['POST'])
def webhook():
data = request.json
if data['type'] == 'payment':
process_payment(data['amount'], data['user_id'])
return 'OK'Output
### 🔒 Security Issues
| Line | Issue | Fix |
|------|-------|-----|
| 3 | No signature verification on webhook | Validate HMAC signature from headers before processing |
| 4 | KeyError if 'type' missing | Use `data.get('type')` with fallback |
### ✅ Summary
- Overall quality score: 3/10
- Critical issues: 2
- Recommended action: reviseRelated Tools
FAQ
- How is this different from the generic code review prompt?
- This version uses markdown tables optimised for ChatGPT's renderer and adds an overall quality score. The generic version uses a prose format that works better in plain-text environments.
- Can I use this with the OpenAI API directly?
- Yes. Split the prompt at the ## User marker and send the System section as the system message and the User section as the user message in your API call.
- Does GPT-4o mini produce good code reviews?
- GPT-4o mini is sufficient for style and simple logic issues but misses subtle security vulnerabilities. Use GPT-4o or GPT-4 Turbo for security-sensitive code.
Related Prompts
Code Review Prompt
This prompt structures code reviews into five clear categories so the AI produces actionab...
Code Review Prompt (Claude / Anthropic)Claude responds especially well to XML-structured prompts because its training aligns with...
Security Code Audit PromptSecurity audits require a systematic approach that covers every vulnerability category, no...