Claude Security Review Prompt for Security Engineers
You get the real vulnerabilities in the code ranked by severity, each with how it could be exploited and a specific fix. This prompt is tuned for security engineers working in Claude: it carries your role context, and the steps below cover what changes in Claude. Remove secrets and customer data before pasting anything, and confirm every reported vulnerability is real before filing it, since false positives waste remediation time.
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 - System and exposure: [e.g. public REST API, handles payment data, behind a WAF] - Scope and authorization: [e.g. internal code review, authorized pentest of staging only] - Standards to map to: [e.g. OWASP Top 10, SOC 2 controls, internal policy] Context - Reference material: [paste it below, or attach the file]
How to use this prompt
- 1
Open Claude
Start a new chat in Claude and paste the prompt.
- 2
Give it context
Attach the documents, code or data the prompt refers to, or paste them below the prompt.
- 3
Review and iterate
Reply in the same chat to refine. Point to the exact part you want changed.
- 4
Save what you repeat
If you use this prompt often for one body of work, set it up in a Claude Project with the instructions and reference files saved.
Working in Claude
- •Claude handles long documents well, so paste the full source text rather than a summary when accuracy matters.
- •Longer pieces of writing or code may open in a side panel (an artifact) that you can edit and ask Claude to revise.
- •Clear structure helps: separate instructions from the material with headings or tags such as <document>.
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
- •State the exposure (who can reach the system and what data it holds) before asking for a review. Severity ratings mean little without it.
- •Fill in "Who can reach it" and "Data it handles" honestly. They decide whether a finding is High or Low.
- •Longer pieces of writing or code may open in a side panel (an artifact) that you can edit and ask Claude to revise.
- •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: Remove secrets and customer data before pasting anything, and confirm every reported vulnerability is real before filing it, since false positives waste remediation time.
Get the free prompt pack
Our best coding 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
Can AI replace a manual security review?
No. It is good at spotting common patterns like injection or missing auth checks, but it misses business logic flaws and context-specific risks. Use it as a first pass alongside tooling and human review.
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.
Should I use a Claude Project for this prompt?
If you run it often against the same reference material, yes. Save the prompt as the project's instructions and upload the files once.
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 coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.