AI for PR Summaries & Code Review

Practical prompt frameworks and templates to generate PR summaries, highlight risk points, suggest tests, and create regression checklists using LLMs.

AI for PR Summaries & Code Review

Purpose

This guide provides concise prompt frameworks and example templates you can use with DeepSeek, Qwen, or other LLMs to generate actionable PR summaries, identify risks, propose tests, and produce regression checklists.

General Principles

Prompt Frameworks

  1. PR Summary + High-level Impact

Template:

“You are a senior code reviewer. Summarize this pull request in 3–5 bullet points: include the intent, key changes (files/functions), expected behavior changes, and an overall impact statement. Output as a short bullet list labeled ‘Summary’.”

Example follow-up: include file list and 3–4 short code snippets or diffs.

  1. Risk Identification (Top N)

Template:

“Act as a security-aware senior engineer. Given the PR context, list the Top 5 potential risks introduced by these changes. For each risk, provide: (a) one-sentence description, (b) severity (Low/Medium/High), and (c) a one-line mitigation or check to perform. Output as a numbered list.”

  1. Test Suggestions & Acceptance Criteria

Template:

“You are a QA engineer. For the PR below, propose up to 8 test cases (unit/integration/edge). For each test case give: (1) Test name, (2) Short description, (3) Steps to reproduce, and (4) Expected result. Output as JSON array or a numbered list.”

  1. Regression Checklist

Template:

“Produce a concise regression checklist for this PR. Include items that cover functionality, performance, security, and backward compatibility. For each item, provide an acceptance check (pass/fail criteria). Keep the checklist to 10 items max.”

  1. Code Review Comments (Focused Suggestions)

Template:

“Act as a senior reviewer focusing on readability, performance, and maintainability. For each changed file, provide up to 3 inline suggestions (format: file:line-range — suggestion — rationale). Keep suggestions brief and actionable.”

Practical Prompt Example (combined flow)

“You are a senior reviewer and QA lead. Given the PR title, description, changed file list, and these code snippets: 1) produce a 4-bullet PR Summary; 2) list Top 5 Risks with severity and mitigation; 3) propose 6 test cases with steps and expected results; 4) output a 6-item regression checklist. Return each section under the headers: SUMMARY, RISKS, TESTS, REGRESSION_CHECKLIST.”

Tips for Effective Use

Prompt Templates (copyable)

You are a senior code reviewer. Summarize this PR in 3–5 bullets: intent, key changes, behavior change, and impact.
PR Title: <title>
PR Description: <description>
Changed files: <fileA>, <fileB>, ...
Code snippets: <snippet 1> ...
Act as a security-aware senior engineer. List the Top 5 risks from this PR. For each: description, severity (Low/Medium/High), and one-line mitigation.
Context: <paste short context or link>
You are a QA engineer. Return up to 8 test cases as a JSON array with fields: name, description, steps (array), expected.
Context: <paste description and key snippets>

When to Use Which Model

Conclusion

These frameworks are designed to be adaptable for any LLM platform. Start with concise, structured requests and iterate prompts based on the observed outputs. Always pair automated suggestions with human review for production changes.