Developer Security Review Prompts Templates
You get the real vulnerabilities in the code ranked by severity, each with how it could be exploited and a specific fix. For developers there's an extra layer: developers mostly need help reading unfamiliar code, writing and debugging functions, and drafting tests and docs inside an existing codebase with its own conventions. The prompt below adds your role context so the answer fits how you work.
Do a security review of the code below. ## Context Language and framework: [e.g. Python, Flask] What this code does: [e.g. public endpoint that looks up a user by name] Who can reach it: [e.g. anyone on the internet, logged-in users only, internal only] Data it handles: [e.g. emails, payment info, none sensitive] ## Code [paste the code] ## Instructions - Check for injection, broken access control, exposed secrets, unsafe deserialization, missing input validation and sensitive data leaks. - For each finding, explain how an attacker would exploit it in one or two sentences. - Show the fixed code for each finding. - Do not list generic advice that does not apply to this code. - Say clearly if you cannot judge something without seeing more code (e.g. auth middleware). ## Output format Findings grouped as High, Medium, Low. Each with: issue, line, exploit, fix. About my work - Language, framework and versions: [e.g. TypeScript 5, Next.js 15, Node 20] - Relevant files or functions: [e.g. lib/billing.ts, the createInvoice function] - Conventions to follow: [e.g. no classes, Zod for validation, Vitest for tests]
How to use this prompt
- 1
Copy the prompt
Use the copy button, or type its Retext trigger in any app to paste it.
- 2
Open your AI assistant
Start a new chat in ChatGPT, Claude, Gemini or whichever assistant you use, so earlier messages don't steer the answer.
- 3
Fill in the brackets
Replace every [bracketed] part with your real details. Specific inputs are what make the answer specific.
- 4
Check and refine
Read the result against the goal above, then reply with one change at a time.
Worked example
What you give it
Framework: Python, Flask, sqlite3
What it does: returns a user's id and email by name.
Who can reach it: anyone on the internet.
@app.route("/user")
def get_user():
name = request.args.get("name")
row = db.execute("SELECT id, email FROM users WHERE name = '" + name + "'").fetchone()
return {"id": row[0], "email": row[1]}What a good answer looks like (shortened)
High: SQL injection (the db.execute line)
Exploit: a request with name set to ' OR '1'='1 returns the first user, and crafted UNION payloads can read other tables.
Fix: use a parameterized query.
row = db.execute("SELECT id, email FROM users WHERE name = ?", (name,)).fetchone()
Medium: email exposed with no authentication
Exploit: anyone can collect user emails by guessing names.
Fix: require login and return email only to the account owner or an admin.
Low: unhandled missing user
If no row matches, row[0] raises and returns a 500 that may leak a stack trace in debug mode.
Fix: if row is None: return {"error": "not found"}, 404Tips for better results
- •Paste the actual error output and the exact versions you run. Most wrong answers come from the AI assuming a different version of a library or framework.
- •Fill in "Who can reach it" and "Data it handles" honestly. They decide whether a finding is High or Low.
- •Paste the auth middleware or permission checks if they live elsewhere. Otherwise the AI will rightly flag access control as unknown.
- •Avoid this: Leaving out who can reach the code, so the AI cannot tell an internal admin script from a public endpoint.
Check before you use it: Check that every function, method and package the AI uses actually exists in your installed versions, and run the tests before you commit.
Get the free prompt pack
Our best AI prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.
Variations
Threat model first
Add this line to Instructions: Before reviewing, list the three most likely attackers and what each would want from this code.
Dependency check
Add this section: ## Dependencies [paste package.json or requirements.txt] and flag packages that are commonly misconfigured or need pinning.
Checklist output
Change Output format to: A table with columns: check, pass or fail, line, fix.
Save it as a Retext snippet
Retext is a free text expander for Mac. Save this prompt once, then type ;secreview in any app (ChatGPT, Claude, your editor, a browser tab) and the full prompt is pasted in.
- Click Add to Retext. The prompt installs as a snippet with the trigger ;secreview.
- Change the trigger in Retext if you prefer a different one.
- Type the trigger wherever you want the prompt, then fill in the brackets.
Frequently asked questions
How do developers keep AI-generated code consistent with their codebase?
Include one or two existing files as examples of your style and state your conventions in the prompt. Ask for changes as small diffs to existing code rather than whole new files.
Is an AI security review enough before launch?
No. It is a useful first pass that catches common mistakes like injection and missing auth checks. Sensitive systems still need a dependency scan, a review by someone with security experience, and testing.
Is it safe to paste code into an AI for a security review?
Remove secrets, keys and customer data first, and follow your company's policy on sharing source code. The review works just as well with placeholder values.
How do I reuse this prompt without copying it every time?
Click Add to Retext to save it as a snippet. Then type ;secreview in any Mac app, including your AI tool, and the full prompt is pasted in.
Related Templates
Get the free prompt pack
Our best AI prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.