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
- Use context: include the PR title, description, changed files list, and key code snippets (or links to diffs).
- Be specific about the role: ask the model to act as a senior reviewer or QA engineer.
- Ask for structured outputs: bullet lists, risk severity levels, and short suggested tests.
- Keep prompts deterministic: set max items (e.g., “Top 5 risks”) and explicit formats.
Prompt Frameworks
- 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.
- 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.”
- 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.”
- 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.”
- 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
- Chunk large diffs: feed important files or snippets rather than entire large diffs.
- Use retrieval: link to code search or specific functions to ground suggestions.
- Tune verbosity: ask for short items when you need quick triage, or detailed steps for QA handoff.
- Validate: always have a human reviewer validate security and production-impacting suggestions.
Prompt Templates (copyable)
- PR Summary:
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> ...
- Top 5 Risks:
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>
- Test Cases (JSON):
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
- Fast triage / high volume: use models optimised for low-cost, high-throughput inference.
- Deep reasoning / safety checks: prefer models that demonstrate stable chain-of-thought and explainability.
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.