|
| 1 | +--- |
| 2 | +name: pr-description |
| 3 | +description: Update the current PR description using `gh pr edit`. Analyzes the diff and commit history against the PR's base branch to write a reviewer-oriented summary. |
| 4 | +allowed-tools: Bash(git log *), Bash(git diff *), Bash(gh pr view *), Bash(gh pr edit *), AskUserQuestion |
| 5 | +--- |
| 6 | + |
| 7 | +# PR Description: Update the Current PR |
| 8 | + |
| 9 | +Generate and apply a PR description that helps reviewers understand the |
| 10 | +change as a whole. Commit messages explain incremental steps; the PR |
| 11 | +description explains the bigger picture — motivation, design decisions, |
| 12 | +and what reviewers should pay attention to. |
| 13 | + |
| 14 | +## Step 1: Gather context |
| 15 | + |
| 16 | +Run these in parallel: |
| 17 | + |
| 18 | +1. `gh pr view --json number,title,body,baseRefName` — get the current |
| 19 | + PR metadata **including the base branch** |
| 20 | +2. `git log --oneline <base>..HEAD` — list all commits on this branch |
| 21 | + (use the PR's `baseRefName`, NOT hardcoded `main`) |
| 22 | +3. `git diff <base>..HEAD --stat` — overview of what files changed |
| 23 | +4. `git diff <base>..HEAD` — full diff (read selectively if very large) |
| 24 | + |
| 25 | +If there is no open PR for this branch, tell the user and stop. |
| 26 | + |
| 27 | +**Important:** Always diff against the PR's actual base branch (from |
| 28 | +`baseRefName`), not `main`. A PR targeting `feature-x` should only |
| 29 | +describe changes relative to `feature-x`, not everything since `main`. |
| 30 | + |
| 31 | +## Step 2: Understand the change |
| 32 | + |
| 33 | +Read the full diff and commit history. Focus on: |
| 34 | + |
| 35 | +- **What changed**: which components, interfaces, types, or behaviors were added/removed/modified |
| 36 | +- **Why**: what motivated this change? Look for patterns across commits — a rename, a removal, a new abstraction, a simplification |
| 37 | +- **Design decisions**: what trade-offs were made? What was the alternative? |
| 38 | +- **Impact surface**: what do consumers of this code need to know? Are there breaking changes? |
| 39 | + |
| 40 | +Do NOT just concatenate commit messages. Synthesize them into a coherent narrative. |
| 41 | + |
| 42 | +## Step 3: Draft the description |
| 43 | + |
| 44 | +Write a PR description with this structure: |
| 45 | + |
| 46 | +``` |
| 47 | +<1-2 sentence summary of the change and its motivation> |
| 48 | +
|
| 49 | +### What changed |
| 50 | +
|
| 51 | +- **Component/area**: what happened and why (one bullet per logical change) |
| 52 | +- Keep bullets concrete — name the types, methods, and files involved |
| 53 | +- Group related changes under a single bullet rather than listing every file |
| 54 | +
|
| 55 | +### Breaking changes |
| 56 | +
|
| 57 | +- List any breaking changes to the public API (removed types, renamed methods, changed signatures) |
| 58 | +- Omit this section entirely if there are no breaking changes |
| 59 | +``` |
| 60 | + |
| 61 | +Guidelines: |
| 62 | +- Lead with motivation, not mechanics |
| 63 | +- Be specific: name the types, methods, and interfaces involved |
| 64 | +- Keep it scannable — reviewers skim first, read deeply second |
| 65 | +- Don't repeat information that's obvious from the diff |
| 66 | +- Don't include test plan sections, emoji, or boilerplate |
| 67 | + |
| 68 | +## Step 4: Present for review |
| 69 | + |
| 70 | +Show the drafted description to the user. Use **AskUserQuestion** to ask: |
| 71 | +"Update PR, adjust, or cancel?" with those three options. |
| 72 | + |
| 73 | +## Step 5: Apply |
| 74 | + |
| 75 | +Update the PR using `gh pr edit` with a heredoc: |
| 76 | + |
| 77 | +```bash |
| 78 | +gh pr edit --body "$(cat <<'EOF' |
| 79 | +<description here> |
| 80 | +EOF |
| 81 | +)" |
| 82 | +``` |
| 83 | + |
| 84 | +Confirm with the PR URL when done. |
0 commit comments