Pre-PR Self-Review and Pull Request Description from a Git Diff

Has GitHub Copilot review your branch diff against the base branch, flag defects and missing tests, and draft a PR description with evidence. Use it to decide whether to open the PR or fix issues first.

You get: Verdict, findings table and PR description in Markdown with sections

More like this

The prompt

pre-pr-self-review-and-pull-request-description-from-a-git-diff.md
Role: You are a meticulous code reviewer and technical writer using GitHub Copilot Chat on my current branch. You review for correctness, security, test coverage, and clarity, and you write PR descriptions reviewers can act on.

Context: I am about to open a pull request. The decision I need to make is whether to open it now, fix blocking issues first, or split it. Use #changes or the diff against {base_branch}, and #codebase for surrounding context.

Task: Review my changes, produce a prioritized findings list, and draft a pull request description.

Inputs
- Base branch: {base_branch}
- Change summary in my own words: {change_summary}
- Linked issue or ticket: {linked_issue}
- Known risk areas: {risk_areas}
- Test evidence I already have (commands run, results): {test_evidence}
- Team review standards: {review_standards}
- PR template path, if any: {pr_template_path}
If the diff is not visible to you, say so and ask me to attach it or run git diff {base_branch}...HEAD. Do not guess at changes you cannot see.

Workflow
1. Diff inventory: list changed files grouped by purpose (feature, tests, config, docs, generated).
2. Intent check: compare the diff to {change_summary} and {linked_issue}. Note mismatches, scope creep, and unrelated edits.
3. Review pass: examine each change for logic errors, unhandled errors, race conditions, input validation, authorization gaps, secrets, breaking API or schema changes, performance regressions, and style violations per {review_standards}.
4. Test gap analysis: for each behavior change, state whether a test covers it. Propose specific missing test cases with names and assertions.
5. Classify findings as Blocker, Should fix, or Nit. Cite file and line range for each.
6. Draft the PR description. If {pr_template_path} exists, follow its headings exactly.

Constraints
- Only cite code that appears in the diff or the repo; no invented line numbers.
- Separate observed facts from assumptions.
- Do not claim tests passed unless {test_evidence} says so.
- Keep nits to at most 5.
- Do not rewrite code unless a fix is a few lines; otherwise describe the fix.

Output format
1. Verdict: Open now, Fix blockers first, or Consider splitting, with a two-sentence reason
2. Findings table: ID | Severity | File:lines | Issue | Suggested fix
3. Missing tests table: Behavior | Suggested test name | Key assertion
4. Missing information and assumptions (bulleted)
5. PR description in Markdown with sections: Summary, Motivation and linked issue, Changes, How to test, Risks and rollback, Screenshots or output (if relevant), Checklist
6. Next actions: ordered list, max 6 items

Acceptance criteria
- Every Blocker has a file reference and a concrete fix.
- The PR description's How to test section contains commands or steps a reviewer can run.
- Risks and rollback addresses each item in {risk_areas}.
- The verdict matches the highest severity in the findings.

Quality checks
- Did you read the full diff, not only the first files?
- Are findings specific and testable rather than generic advice?
- Does the description state only what the diff and {test_evidence} support?
- Are breaking changes, migrations, and config changes called out explicitly?
- Is anything left unresolved listed under Missing information?

Example output

AI-written example

1. Verdict: Fix blockers first.
The rate limiter keys on req.ip, which behind our load balancer is the proxy address, so every user would share one bucket. A Redis error also turns into a 500 on the reset endpoint.

2. Findings

IDSeverityFile:linesIssueSuggested fix
F1Blockersrc/middleware/rateLimit.ts:14-22Key uses req.ip. trust proxy is not set in src/app.ts, so all traffic shares one key.Set app.set('trust proxy', 1) in src/app.ts, or key on X-Forwarded-For from the trusted hop.
F2Blockersrc/middleware/rateLimit.ts:30-41An unhandled Redis rejection returns 500, so password reset is down whenever Redis is.Wrap the call in try/catch, log, and next() (fail open). Document the choice in the PR.
F3Should fixsrc/routes/auth.ts:57Limiter is applied after the user lookup, so response timing can reveal whether an email exists.Mount the limiter before the handler.
F4Nitsrc/middleware/rateLimit.ts:27console.log left in.Use logger.debug.

F2 fix:

try {
  const count = await redis.incr(key);
  if (count === 1) await redis.expire(key, WINDOW_SECONDS);
  if (count > MAX_ATTEMPTS) return res.status(429).json({ error: 'too_many_requests' });
} catch (err) {
  logger.warn({ err }, 'rate limiter unavailable, failing open');
}
return next();

3. Missing tests

BehaviorSuggested test nameKey assertion
Sixth request in window is blockedreturns 429 after 5 reset requests in 15 minStatus is 429 on request 6
Separate clients are counted separatelytracks limits per forwarded client IPDifferent X-Forwarded-For values both get 200
Redis outagefails open when redis throwsStatus is 200 and a warning is logged
Window expiryresets counter after windowRequest succeeds after fake timers advance 15 min

4. Missing information and assumptions

  • Fact: 41 auth tests passed per your evidence. Lint and type-check results were not provided.
  • Assumption: production runs behind exactly one proxy hop. Please confirm.
  • No test touches the limiter, so it is unverified.
  • Unknown whether MAX_ATTEMPTS=5 and the 15-minute window were agreed in #482.

5. PR description

## Summary
Adds per-client rate limiting to `POST /auth/password-reset`.

## Motivation and linked issue
Closes #482. The endpoint currently allows unlimited reset emails per address.

## Changes
- New `rateLimit` middleware backed by Redis (5 requests per 15 min)
Generated from this prompt by AI. Your results will vary.

Tips and common edits

Run in Copilot Chat after committing or staging your work, and attach the diff if #changes is unavailable. Verify each finding against the code before acting, since a reviewer model can misread context. Paste the description into your PR only after you confirm each claim.

Questions about this prompt

Conventional Commit and PR Description from a Diff and Ticket

Produces a Conventional Commits message and a reviewer-ready PR description covering what changed, why, how to test it, and the risks, based on your diff and ticket.

GitHub Copilot Pull Request Description Written From the Diff

Turns the changes in a branch into a clear pull request description: what changed and why, how to test it, risks and screenshots to add, in your repo's template if it has one.

Coding Agent Task Brief with Guardrails, Test Plan, and Rollback Steps

Creates a scoped brief for an AI coding agent that limits file changes, defines tests, and includes a rollback plan and review checklist.

Codex Pre-Merge Diff Review with Severity-Ranked Findings

Has Codex review a branch diff against a base ref in read-only mode. It checks correctness, tests, security, and maintainability, and returns evidence-backed findings with severity and a merge recommendation.

Pull Request Review with Merge Recommendation

Reviews a diff against your standards and returns a merge, merge-with-changes, or do-not-merge recommendation. Findings are ranked by severity, with evidence, suggested fixes, and open questions.

Edge-Case Test Suite for One Function in Your Existing Test Framework

Writes tests for a single function that cover normal inputs, boundaries, bad input and error paths, in the test framework your project already uses.

Implement a Scoped Feature in Copilot Agent Mode with Repo Discovery and Tests

Guides GitHub Copilot agent mode to inspect the repository, state assumptions, plan a minimal change, implement it, and add tests. It ends with a verification report you can use to decide whether to open a PR.

Rewrite a Vague Issue into a Copilot Coding Agent-Ready Issue

Turns a vague GitHub issue into a self-contained task with context, testable acceptance criteria, files to touch, and tests to add, so the Copilot coding agent can finish it.

Codex Pull Request Review With Comments Ranked by Severity

Has Codex review a pull request and return comments sorted into blocking, should-fix and nit, each with the file and line, the risk, and a suggested change.

Pre-Merge Code Review Checklist Skill (SKILL.md)

A save-ready SKILL.md that has your coding agent review a branch before merge: correctness, security, tests and migrations, with findings ranked by severity and no style nitpicks.