Refresh PR Description
Bring an existing PR description back in sync with what the branch
currently does — non-destructively. The description's structure,
formatting, links, and hand-written customizations are preserved; only
content that the branch's evolution has made stale is updated.
This command is content-only. It never restructures the
description, never applies a template, and never discusses structure or
templates. If the user asks for a different structure or mentions a
template, reply in one line that restructuring is /pr:rewrite's job,
then continue with the content-only refresh (or stop, if restructuring
was the sole request).
User input: $ARGUMENTS
Context
Current branch:
!git branch --show-current
PR for current branch (if any):
!gh pr view --json number,title,url,baseRefName 2>/dev/null || echo "(no PR for current branch — expect a PR number/URL in the argument)"
Procedure
1. Resolve the PR and its target
- If
$ARGUMENTS contains a PR number or URL, use it; otherwise use
the current branch's PR. No PR found → report that and stop.
- Fetch the full PR:
gh pr view <number> --json number,title,body,url,baseRefName,headRefName,state
- The diff base is the PR's
baseRefName — this is what makes the
command stack-aware. A PR targeting a sibling branch in a stack is
diffed against that branch, never against trunk.
- Gather the net change:
git fetch origin <baseRefName>
git log origin/<baseRefName>..HEAD --oneline
git diff origin/<baseRefName>...HEAD --stat
git diff origin/<baseRefName>...HEAD
2. Back up the current description
Before any analysis, save the existing body verbatim:
mkdir -p .git/pr-backups/$(date -u +%Y%m%d-%H%M%SZ)-pr<number>
Write the fetched body to body.md and the title to title.txt inside
that directory, and tell the user the backup path. If the edit is later
regretted, the old description can be restored with
gh pr edit <number> --body-file <backup>/body.md.
3. Map the description against the current diff
Read the existing body section by section and classify every claim:
- Still accurate — describes something the net diff still does.
Leave it byte-for-byte untouched, including phrasing you'd have
written differently. Refresh fixes staleness, not style.
- Stale — describes behavior, files, flags, or approaches the
branch no longer contains, or understates/misstates what it now
does. Rewrite minimally, in the section's existing voice and format.
- Missing — a change in the net diff that the description doesn't
cover. Add it to the existing section where it belongs, matching
that section's format (bullet style, bold-label pattern, table
shape). Never create a new section for it.
- Unverifiable — hand-written content whose accuracy can't be
judged from the diff: reviewer commitments, deployment notes,
screenshots, benchmark numbers, external links, checked task-list
items. Preserve by default. If the diff suggests one of these is
now wrong (e.g., a screenshot of a UI the branch since changed), ask
the user before touching it — never silently drop or edit it.
Preserve throughout: section order and headings, link targets and link
text, images, badges, HTML comments, task-list check states, issue
keywords (Fixes #N), and @-mentions.
4. Ambiguity gate
When it is unclear whether a piece of existing content is stale or
load-bearing, ask via AskUserQuestion with the specific text quoted
and the options: keep as-is, update (showing the proposed replacement),
or remove. Batch related uncertainties into one question set rather
than asking serially. Never resolve ambiguity by guessing.
5. Present and apply
Rules
- Non-destructive: every run backs up the existing body before
editing; the smallest edit that restores accuracy wins.
- Content-only: never add, remove, rename, or reorder sections;
never discuss structure or templates.
- Stack-aware: the diff base is the PR's
baseRefName, never an
assumed trunk.
- Ask on ambiguity: unverifiable or uncertain content is kept
unless the user says otherwise.
- Whole-branch perspective: refreshed content describes the net
result against the base, not the branch's internal history.
- No brittle details: don't introduce test counts, SHAs, line
numbers, or file-changed counts while refreshing.
- Never force-push, push, or run destructive git commands; the only
write is
gh pr edit after approval.
1---2name: refresh3description: Refresh an existing PR description to match the branch's current net change, preserving structure and customizations4---567# Refresh PR Description89Bring an existing PR description back in sync with what the branch10**currently** does — non-destructively. The description's structure,11formatting, links, and hand-written customizations are preserved; only12content that the branch's evolution has made stale is updated.1314This command is **content-only**. It never restructures the15description, never applies a template, and never discusses structure or16templates. If the user asks for a different structure or mentions a17template, reply in one line that restructuring is `/pr:rewrite`'s job,18then continue with the content-only refresh (or stop, if restructuring19was the sole request).2021User input: $ARGUMENTS2223## Context2425Current branch:26`!git branch --show-current`2728PR for current branch (if any):29`!gh pr view --json number,title,url,baseRefName 2>/dev/null || echo "(no PR for current branch — expect a PR number/URL in the argument)"`3031---3233## Procedure3435### 1. Resolve the PR and its target3637- If `$ARGUMENTS` contains a PR number or URL, use it; otherwise use38 the current branch's PR. No PR found → report that and stop.39- Fetch the full PR:40 ```41 gh pr view <number> --json number,title,body,url,baseRefName,headRefName,state42 ```43- The diff base is the PR's **`baseRefName`** — this is what makes the44 command stack-aware. A PR targeting a sibling branch in a stack is45 diffed against that branch, never against trunk.46- Gather the net change:47 ```48 git fetch origin <baseRefName>49 ```50 ```51 git log origin/<baseRefName>..HEAD --oneline52 ```53 ```54 git diff origin/<baseRefName>...HEAD --stat55 ```56 ```57 git diff origin/<baseRefName>...HEAD58 ```5960### 2. Back up the current description6162Before any analysis, save the existing body verbatim:6364```65mkdir -p .git/pr-backups/$(date -u +%Y%m%d-%H%M%SZ)-pr<number>66```6768Write the fetched body to `body.md` and the title to `title.txt` inside69that directory, and tell the user the backup path. If the edit is later70regretted, the old description can be restored with71`gh pr edit <number> --body-file <backup>/body.md`.7273### 3. Map the description against the current diff7475Read the existing body section by section and classify every claim:7677- **Still accurate** — describes something the net diff still does.78 Leave it byte-for-byte untouched, including phrasing you'd have79 written differently. Refresh fixes staleness, not style.80- **Stale** — describes behavior, files, flags, or approaches the81 branch no longer contains, or understates/misstates what it now82 does. Rewrite minimally, in the section's existing voice and format.83- **Missing** — a change in the net diff that the description doesn't84 cover. Add it to the existing section where it belongs, matching85 that section's format (bullet style, bold-label pattern, table86 shape). Never create a new section for it.87- **Unverifiable** — hand-written content whose accuracy can't be88 judged from the diff: reviewer commitments, deployment notes,89 screenshots, benchmark numbers, external links, checked task-list90 items. **Preserve by default.** If the diff suggests one of these is91 now wrong (e.g., a screenshot of a UI the branch since changed), ask92 the user before touching it — never silently drop or edit it.9394Preserve throughout: section order and headings, link targets and link95text, images, badges, HTML comments, task-list check states, issue96keywords (`Fixes #N`), and @-mentions.9798### 4. Ambiguity gate99100When it is unclear whether a piece of existing content is stale or101load-bearing, ask via `AskUserQuestion` with the specific text quoted102and the options: keep as-is, update (showing the proposed replacement),103or remove. Batch related uncertainties into one question set rather104than asking serially. Never resolve ambiguity by guessing.105106### 5. Present and apply107108- Show the proposed edit as an old → new comparison, quoting only the109 sections that change; state explicitly which sections are untouched.110- Update the title only if it is factually stale; keep its style.111- Ask whether to apply. On approval:112 ```113 gh pr edit <number> --body-file <file>114 ```115 Write the new body to a file first (in the backup directory, as116 `body.new.md`) so formatting survives shell quoting.117- Confirm with the PR URL and repeat the backup path.118119---120121## Rules122123- **Non-destructive**: every run backs up the existing body before124 editing; the smallest edit that restores accuracy wins.125- **Content-only**: never add, remove, rename, or reorder sections;126 never discuss structure or templates.127- **Stack-aware**: the diff base is the PR's `baseRefName`, never an128 assumed trunk.129- **Ask on ambiguity**: unverifiable or uncertain content is kept130 unless the user says otherwise.131- **Whole-branch perspective**: refreshed content describes the net132 result against the base, not the branch's internal history.133- **No brittle details**: don't introduce test counts, SHAs, line134 numbers, or file-changed counts while refreshing.135- **Never** force-push, push, or run destructive git commands; the only136 write is `gh pr edit` after approval.