Example — Code Reviewer
Demonstration of prompts/dev/code-reviewer.txt with the variables filled in. Illustrative example of what such a prompt can produce. The response was generated by an AI in one pass — not guaranteed, and not professional advice. All names, numbers, and de
Works with
claude-code (compatible), claude (compatible), codex (compatible), chatgpt (compatible), gemini-cli (compatible), cursor (compatible), copilot (compatible), opencode (compatible), amp (compatible), roo (compatible), kiro (compatible), goose (compatible), junie (compatible), trae (compatible), cline (compatible), continue (compatible), antigravity (compatible), windsurf (compatible), augment (compatible), qwen-code (compatible), aider (compatible)
Content
Example — Code Reviewer
Demonstration of [prompts/dev/code-reviewer.txt](../prompts/dev/code-reviewer.txt) with the variables filled in. Illustrative example of what such a prompt can produce. The response was generated by an AI in one pass — not guaranteed, and not professional advice. All names, numbers, and details are fictional (Egypt-plausible where relevant).
Prompt (filled)
You are a senior engineer doing a constructive review of my code. Find real problems, rank them, and show fixes — as a colleague, not a gatekeeper.
MY DETAILS
- Language/framework: Python (FastAPI)
- What this code is supposed to do: endpoint that returns a user's saved addresses
- My main worry (performance, correctness, readability, security): security of user input
PASTE YOUR CODE BETWEEN THE MARKERS
--- CODE START ---
```python
@app.get("/addresses") def get_addresses(user_id: int): rows = db.execute(f"SELECT * FROM addresses WHERE user_id = {user_id}") return [dict(r) for r in rows]
> --- CODE END ---
>
> YOUR TASK — answer in this exact order:
> 1. VERDICT: one line — does this code do its stated job? If not, where does it break first?
> 2. FINDINGS: a table, Priority (P0 blocker / P1 should fix / P2 nice to have) | Issue | Why it matters | Suggested fix. Cover: correctness edge cases, error handling, performance, security (input validation, injection, secrets), and naming/readability.
> 3. SECURITY PASS: explicit check for the classics — unvalidated input, hardcoded credentials, unsafe queries — even if I didn't ask.
> 4. THE FIX DIFF: the improved version of the worst section only (not a full rewrite) with a one-line note per change.
> 5. THE COMPLIMENT: one thing this code genuinely does well — reviews that only criticize get ignored.
>
> RULES
> - Input-complete prompt: if the pasted material is unreadable or clearly incomplete, say exactly what is missing instead of proceeding on assumptions.
> - No style nitpicks above P2 (semicolon debates are not findings).
> - Fixes must keep my language/framework idioms — no rewriting into a different paradigm.
> - If my code is fine, say "this is fine" — don't invent problems to seem useful.
> Note: Before I paste anything, remind me to redact or mask personal and client data (names, phone numbers, account numbers, tokens) and replace them with placeholders.
>
> OUTPUT FORMAT
> - Five numbered sections: verdict (1 line), findings table (P0/P1/P2), explicit security pass, fix diff for the worst section only, one genuine compliment. Lead with VERDICT.
>
## Example AI response
**1. VERDICT**
The code returns addresses, but it is not safe to ship as-is: the SQL is injectable, and the endpoint trusts a client-supplied `user_id` with no authentication. Where it breaks first: anyone can read anyone's addresses.
**2. FINDINGS**
| Priority | Issue | Why it matters | Suggested fix |
|---|---|---|---|
| P0 | SQL built with an f-string (`{user_id}` inlined) | Classic injection vector; a `user_id` like `1 OR 1=1` dumps every row | Use a parameterized query: `db.execute("SELECT ... WHERE user_id = :uid", {"uid": user_id})` |
| P0 | No authentication/authorization — `user_id` comes from the query string | Any caller can read any user's addresses by changing the number | Take the user identity from the authenticated session/token, never from client input |
| P1 | `SELECT *` | Exposes new columns by accident later (e.g. soft-delete flags, notes) | Select explicit columns |
| P2 | No pagination or limit | A user with thousands of rows returns them all in one response | Add `LIMIT/OFFSET` or cursor pagination |
**3. SECURITY PASS**
Both classics found: unvalidated/interpolated input (P0 #1) and a missing authz check (P0 #2). No hardcoded credentials in this snippet — but the DB connection settings aren't shown; confirm they come from environment variables, never the source.
**4. THE FIX DIFF** (the auth/SQL core only)
@app.get("/addresses") def get_addresses(current_user: User = Depends(get_current_user)): rows = db.execute( "SELECT id, label, line1, city FROM addresses WHERE user_id = :uid", {"uid": current_user.id}, ) return [dict(r) for r in rows]
- `Depends(get_current_user)`: identity now comes from the verified token; the client can no longer name an arbitrary `user_id`.
- Parameterized query kills the injection vector.
- Explicit columns stop accidental data leaks.
**5. THE COMPLIMENT**
The endpoint is small, synchronous-simple, and returns plain dicts — easy to test and reason about. Fix the two P0s and this is a clean little handler.
---
*Generated for demonstration as part of Prompt Stash. Outputs vary by model and run.*
Source and license
- Source
- Prompt Stash
- Original
- Ziadtareks/prompt-stash/examples/dev-code-reviewer.md
- License
- MIT