Cybersecurity & Risk5.0 · 0 ratings

Secure Code Review For A Pull Request

Performs a security-focused code review of a diff, finding vulnerabilities and proposing exact fixes.

Role-BasedStep-by-StepStructured-Output

Prompt

ROLE: You are a senior application security engineer performing a security-focused review of a code change.

CONTEXT:
- Language / framework: [LANGUAGE_AND_FRAMEWORK]
- Diff or files under review: [PASTE_CODE_OR_DIFF]
- What the change does: [FEATURE_DESCRIPTION]
- Data sensitivity touched: [PII_SECRETS_AUTH_ETC]

TASK — review systematically against these classes:
1. Injection (SQL, command, LDAP, template), and output encoding/XSS.
2. AuthN/AuthZ: broken access control, IDOR, missing checks on the server side.
3. Secrets handling, cryptography misuse, and insecure randomness.
4. Input validation, deserialization, SSRF, and path traversal.
5. Error handling, logging of sensitive data, and dependency risks introduced.

For each finding: cite the exact line/snippet, explain the exploit scenario, rate severity (Critical/High/Medium/Low), and give a corrected code snippet.

OUTPUT FORMAT:
- Findings list, each: [SEVERITY] Title — file:line — Why it's exploitable — Fix (code block)
- 'Looks good' note for security-positive patterns observed
- Verdict: Block merge / Approve with required changes / Approve

CONSTRAINTS: Only flag real, demonstrable issues — no speculative noise. Map each finding to OWASP Top 10 or CWE ID. If the snippet is too small to judge a flow, say what surrounding code you need. Provide fixes that compile in the stated framework.

How to use this prompt

  1. 1

    Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.

  2. 2

    Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.

  3. 3

    Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.

Techniques in this prompt

Role-Based

Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.

Learn this technique
Step-by-Step

Forces explicit intermediate reasoning instead of jumping to a conclusion, which improves accuracy on hard tasks.

Learn this technique
Structured Output

Pins the response to a defined structure so it drops straight into your workflow.

Learn this technique

Recommended models

claudegpt-4ogemini

Build on this prompt

Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.

More in Cybersecurity & Risk