GitHub Copilot Prompts for Security Engineers
Security engineers need help reviewing code and configs for vulnerabilities, drafting threat models, writing detection rules, and summarizing incidents for different audiences. These GitHub Copilot prompts start from that: fill in your situation once and reuse it. The worked example below is a security review task, one of the most common for security engineers.
I'm a security engineer and need help with [task, e.g. security audits]. What I have: - [the material involved: code, draft, notes or data] What a good result looks like: - [the outcome and its format] Ask me one clarifying question if something important is missing, then give the result. 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 - Files involved: [list the files, or reference them in the chat] - How I build and test: [e.g. npm test]
How to use this prompt
- 1
Open GitHub Copilot
Open Copilot Chat in your editor and paste the prompt.
- 2
Give it context
Select the relevant code first, or reference files in the chat, so Copilot answers about your code rather than in general.
- 3
Review and iterate
Ask follow-ups in the same thread, and copy or insert the suggestion only after you have read it.
- 4
Save what you repeat
Keep repository-wide guidance in a .github/copilot-instructions.md file so it applies to every chat in that repo.
Working in GitHub Copilot
- •Inline suggestions only see the file you are in. Use Copilot Chat for anything that spans several files.
- •Copilot Chat has built-in slash commands such as /explain, /fix and /tests. The prompt here gives more control when you need a specific format.
- •Short, concrete requests work best: name the function, the input and the expected result.
Example task: Security Review
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.
- •Select the relevant code first, or reference files in the chat, so Copilot answers about your code rather than in general.
- •Check this before you use the output: remove secrets and customer data before pasting anything, and confirm every reported vulnerability is real before filing it, since false positives waste remediation time.
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
Task
Security Review: Replace the first line with: Do a security review of the code below.
Threat model first
Add this line to Instructions: Before reviewing, list the three most likely attackers and what each would want from this code.
Second task
Change the task line to: [Vulnerability assessments].
Save it as a Retext snippet
Retext is a free text expander for Mac. Save this prompt once, then type ;security-copilot 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 ;security-copilot.
- 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.
Does this prompt work with inline suggestions or only chat?
Use it in Copilot Chat. Inline suggestions complete code as you type and don't take long instructions like this.
How do I give Copilot project conventions once?
Add them to .github/copilot-instructions.md in the repository. Copilot Chat includes that file with your requests in that repo.
How do I reuse this prompt without copying it every time?
Click Add to Retext to save it as a snippet. Then type ;security-copilot 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.