Prompt file imported from microsoft/WindowsAppSDK (
.github/prompts/review-pr.prompt.md). Fill in{{currentBranch}},{{pr_number}}before use. Copyright stays with the author.
Review Pull Request
Goal: Given {{pr_number}}, run a one-topic-per-step review. Write files to Generated Files/prReview/{{pr_number}}/ (replace {{pr_number}} with the integer). Emit machine‑readable blocks for a GitHub MCP to post review comments.
Step 0: Fetch PR data (ALWAYS start here)
Use whatever GitHub MCP/API tools are available to fetch PR details. Common tool names include:
mcp_github_pull_request_read(with method: "get")github-pull-request_activePullRequestactivate_pull_request_management_tools
Just try calling one of these tools to get PR info for PR #6130 (or the PR from context). The call will either succeed or fail - that tells you which tools work.
Issue/PR artifacts
Use Copilot's standard web, file, and execution tools to review screenshots or ZIP attachments linked from the PR or related issues when relevant. Store extracted issue artifacts under Generated Files/prReview/{{pr_number}}/issue-artifacts/<issue_number>.
PR selection
Resolve the target PR using these fallbacks in order:
- Parse the invocation text for an explicit identifier (first integer following patterns such as a leading hash and digits or the text
PR:followed by digits). - If no PR is found yet, locate the newest
Generated Files/prReview/_batch/batch-overview-*.mdfile (highest timestamp in filename, fallback newest mtime) and take the first entry in its## PRslist whose review folder is missing00-OVERVIEW.mdor contains__error.flag. - If the batch file has no pending PRs, activate GitHub search tools and call
github-pull-request_doSearchwithquery: "assignee:@me is:open"plussort: updated,order: desc,perPage: 20; pick the most recently updated PR that does not already have a completed review folder. - If still unknown, use
github-pull-request_doSearchwithquery: "head:{{currentBranch}}"and use that result when it is unambiguous. - If every step above fails, prompt the user for a PR number before proceeding.
Additional MCP methods
Once MCP is confirmed working (Step 0 succeeded), use these additional methods:
method: "get_files"→ returns list of changed files with filename, status, additions, deletions, patchmethod: "get_diff"→ returns unified diff with patch hunks for line mapping
File contents at specific ref
Use activate_file_management_tools → Get file contents:
- Specify
owner,repo,path, andref(branch name or SHA) to fetch base version of files
Incremental review workflow
- Check for existing review: Read
Generated Files/prReview/{{pr_number}}/00-OVERVIEW.md - Extract state: Parse
Last reviewed SHA:from review metadata section - Detect changes: Use commit listing tools to check if
last_shaexists in recent history. Then use PR file listing tools to get current changed files and compare against cached file list from previous iteration. - Analyze result:
- If force-push detected (last SHA not in commit history) → Full review needed
- If commits added since last review → Review only changed files (diff current vs cached file list)
- If no changes → Skip review (update iteration history with "No changes since last review")
- Apply smart filtering: Use the file patterns in smart step filtering table to skip irrelevant steps
- Update metadata: After completing review, save current
headRefOidasLast reviewed SHA:in00-OVERVIEW.md
Output files
Folder: Generated Files/prReview/{{pr_number}}/
Files: 00-OVERVIEW.md, 01-functionality.md, 02-compatibility.md, 03-performance.md, 04-accessibility.md, 05-security.md, 06-localization.md, 07-globalization.md, 08-extensibility.md, 09-solid-design.md, 10-repo-patterns.md, 11-docs-automation.md, 12-code-comments.md, 13-copilot-guidance.md (only if guidance md exists).
- Write-after-step rule: Immediately after completing each TODO step, persist that step's markdown file before proceeding to the next. Generate
00-OVERVIEW.mdonly after every step file has been refreshed for the current run.
Iteration management
- Determine the current review iteration by reading
00-OVERVIEW.md(look forReview iteration:). If missing, assume iteration1. - Extract the last reviewed SHA from
00-OVERVIEW.md(look forLast reviewed SHA:in the review metadata section). If missing, this is iteration 1. - Incremental review detection:
- Use
activate_branch_and_commit_management_tools→List commitsto check commit history and verifylast_shaexists. - If
last_shanot found in history (force-push), do a full review. - If incremental, compare current
get_filesoutput against cached file list from previous iteration and review only changed files. Apply smart step filtering (see below).
- Use
- Increment the iteration for each review run and propagate the new value to all step files and the overview.
- Preserve prior iteration notes by keeping/expanding an
## Iteration historysection in each markdown file, appending the newest summary under### Iteration <N>. - Summaries should capture key deltas since the previous iteration so reruns can pick up context quickly.
- After review completion, update
Last reviewed SHA:in00-OVERVIEW.mdwith the currentheadRefOidand update the timestamp.
Smart step filtering (incremental reviews only)
When performing incremental review, skip steps that are irrelevant based on changed file types:
| File pattern | Required steps | Skippable steps |
|---|---|---|
**/*.cs, **/*.cpp, **/*.h |
Functionality, Compatibility, Performance, Security, SOLID, Repo patterns, Code comments | (depends on files) |
**/*.resx, **/Resources/*.xaml |
Localization, Globalization | Most others |
**/*.md (docs) |
Docs & automation | Most others (unless copilot guidance) |
**/*copilot*.md, .github/prompts/*.md |
Copilot guidance, Docs & automation | Most others |
**/*.csproj, **/*.vcxproj, **/packages.config |
Compatibility, Security, Repo patterns | Localization, Globalization, Accessibility |
**/UI/**, **/*View.xaml |
Accessibility, Localization | Performance (unless perf-sensitive controls) |
Default: If uncertain or files span multiple categories, run all applicable steps. When in doubt, be conservative and review more rather than less.
TODO steps (one concern each)
- Functionality — Does the implementation correctly follows SDK patterns?
- Compatibility — Windows 10 1809+, x64/x86/ARM64, Debug/Release configurations
- Performance — No unnecessary allocations or blocking operations
- Accessibility — Follows accessibility checklist
- Security — No hardcoded secrets, proper input validation
- Localization — Resources properly externalized where applicable
- Globalization — Culture-aware formatting where applicable
- Extensibility — Clear patterns for developers to adapt
- SOLID principles — Clean, maintainable SDK code
- Repo patterns — Follows Coding-Guidelines.md conventions
- Docs & automation — Documentation updated, CI pipeline configured
- Code comments — Appropriate copyright headers, helpful inline comments
- Copilot guidance (conditional): if changed folders contain
*copilot*.mdor.github/prompts/*.md, review diffs against that guidance and write13-copilot-guidance.md(omit if none).
Per-step file template (use verbatim)
# <STEP TITLE>
**PR:** (populate with PR identifier) — Base:<baseRefName> Head:<headRefName>
**Review iteration:** ITERATION
## Iteration history
- Maintain subsections titled `### Iteration N` in reverse chronological order (append the latest at the top) with 2–4 bullet highlights.
### Iteration ITERATION
- <Latest key point 1>
- <Latest key point 2>
## Checks executed
- List the concrete checks for *this step only* (5–10 bullets).
## Findings
(If none, write **None**. Defaults have one or more blocks:)
```mcp-review-comment
{"file":"relative/path.ext","start_line":123,"end_line":125,"severity":"high|medium|low|info","tags":["<step-slug>","pr-tag-here"],"related_files":["optional/other/file1"],"body":"Problem → Why it matters → Concrete fix. If spans multiple files, name them here."}
Use the second tag to encode the PR number.
## Overview file (`00-OVERVIEW.md`) template
```md
# PR Review Overview — (populate with PR identifier)
**Review iteration:** ITERATION
**Changed files:** <n> | **High severity issues:** <count>
## Review metadata
**Last reviewed SHA:** <headRefOid from gh pr view>
**Last review timestamp:** <ISO8601 timestamp>
**Review mode:** <Full|Incremental (N files changed since iteration X)>
**Base ref:** <baseRefName>
**Head ref:** <headRefName>
## Step results
Write lines like: `01 Functionality — <OK|Issues|Skipped> (see 01-functionality.md)` … through step 13.
Mark steps as "Skipped" when using incremental review smart filtering.
## Iteration history
- Maintain subsections titled `### Iteration N` mirroring the per-step convention with concise deltas and cross-links to the relevant step files.
- For incremental reviews, list the specific files that changed and which commits were added.
Line numbers & multi‑file issues
- Map head‑side lines from
patchhunks (@@ -a,b +c,d @@→ new lines+c..+c+d-1). - For cross‑file issues: set the primary
"file", list others in"related_files", and name them in"body".
Posting (for MCP)
- Parse all
mcp-review-commentblocks across step files and post as PR review comments. - If posting isn’t available, still write all files.
Constraint
Read/analyze only; don't modify code. Keep comments small, specific, and fix‑oriented.
Scratch cache for large PRs
Create a local scratch workspace to progressively summarize diffs and reload state across runs.
Paths
- Root:
Generated Files/prReview/{{pr_number}}/__tmp/ - Files:
index.jsonl— append-only JSON Lines index of artifacts.todo-queue.json— pending items (files/chunks/steps).rollup-<step>-v<N>.md— iterative per-step aggregates.file-<hash>.txt— optional saved chunk text (when needed).
JSON schema (per line in index.jsonl)
{"type":"chunk|summary|issue|crosslink",
"path":"relative/file.ext","chunk_id":"f-12","step":"functionality|compatibility|...",
"base_sha":"...", "head_sha":"...", "range":[start,end], "version":1,
"notes":"short text or key:value map", "created_utc":"ISO8601"}
Phases (stateful; resume-safe)
- Discover PR + SHAs: Use available GitHub PR tools to get refs/SHAs and changed files list.
- Chunk each changed file (head): split into ~300–600 LOC or ~4k chars; stable
chunk_id= hash(path+start).- Save
chunkrecords. Optionally writefile-<hash>.txtfor expensive chunks.
- Save
- Summarize per chunk: intent, APIs, risks per TODO step; emit
summaryrecords (≤600 tokens each). - Issues: convert findings to machine-readable blocks and emit
issuerecords (later rendered to step MD). - Rollups: build/update
rollup-<step>-v<N>.mdfromsummary+issue. Keep prior versions. - Finalize: write per-step files +
00-OVERVIEW.mdfrom rollups. Post comments via MCP if available.
Re-use & token limits
- Always reload
index.jsonlfirst; skip chunks with samehead_shaandrange. - Incremental review optimization: When comparing SHAs returns a subset of changed files, load only chunks from those files. Reuse existing chunks/summaries for unchanged files.
- Prefer re-summarizing only changed chunks; merge chunk summaries → file summaries → step rollups.
- When context is tight, load only the minimal chunk text (or its saved
file-<hash>.txt) needed for a comment.
Original vs diff
- Fetch base content when needed: prefer
git show <baseRefName>:<path>; fallbackactivate_file_management_tools→Get file contentswithrefset to base SHA. - Use patch hunks from PR diff/files tools to compute head line numbers.
Queue-driven loop
- Seed
todo-queue.jsonwith all changed files. - Process: chunk → summarize → detect issues → roll up.
- Append to
index.jsonlafter each step; never rewrite previous lines (append-only).
Hygiene
__tmp/is implementation detail; do not include in final artifacts.- It is safe to delete to force a clean pass; the next run rebuilds it.