$npx -y skills add testdouble/han --skill update-pr-descriptionGenerate a PR description from the current branch's changes against a GitHub PR, using the gh CLI. Use when writing, drafting, or updating pull request descriptions, PR summaries, or PR bodies. Does not review code or post review comments — use code-review for local review or pos
| 1 | ## Pre-requisites |
| 2 | |
| 3 | - gh CLI: !`which gh 2>/dev/null || echo "not installed"` |
| 4 | |
| 5 | **If the gh CLI is not found:** |
| 6 | - Inform the user that it needs to be installed and configured before this skill can be used |
| 7 | - **Immediately stop** execution of this skill, as it cannot be executed |
| 8 | |
| 9 | ## Project Context |
| 10 | |
| 11 | - current branch: !`git branch --show-current 2>/dev/null || echo unknown` |
| 12 | - default branch: !`git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null || echo unknown` |
| 13 | - branch summary: !`git log origin/HEAD..HEAD --oneline 2>/dev/null || echo unknown` |
| 14 | - branch stats: !`git diff origin/HEAD...HEAD --stat 2>/dev/null || echo unknown` |
| 15 | - branch changes: !`git diff origin/HEAD...HEAD 2>/dev/null || echo unknown` |
| 16 | |
| 17 | ## Step 1: Validate Branch State |
| 18 | |
| 19 | Before generating a PR description, verify the branch has content to describe: |
| 20 | |
| 21 | 1. **If `default branch` is empty or `unknown`** — `origin/HEAD` is not set. Use `AskUserQuestion` to ask the user for the default branch name (e.g., `main`, `master`, `develop`). Use that branch as the base for all git commands in subsequent steps, and recompute `branch summary`, `branch stats`, and `branch changes` against it — their Project Context values may read `unknown` because they were derived from the unset `origin/HEAD`. |
| 22 | |
| 23 | 2. **If `branch summary` is empty** — there are no commits on this branch relative to the default branch. Inform the user and stop. |
| 24 | |
| 25 | 3. **If `branch stats` is empty** — there are no file changes despite having commits (e.g., empty commits or fully reverted changes). Inform the user and stop. |
| 26 | |
| 27 | ## Step 2: Discover the Repository PR Template |
| 28 | |
| 29 | Determine whether the repository defines its own GitHub pull-request template. If it does, the generated description must conform to that template's structure (Step 4). Do not assume any particular template shape — discover it, read it, and let its structure drive the output. |
| 30 | |
| 31 | Use the `Glob` tool to look in GitHub's supported template locations. GitHub matches the filename case-insensitively; check both common casings since the working filesystem may be case-sensitive. Search these paths (most templates are `.md`; `.txt` is also valid): |
| 32 | |
| 33 | - Root of the repo: `pull_request_template.md`, `PULL_REQUEST_TEMPLATE.md` (and the `.txt` variants). |
| 34 | - The `.github/` directory: `.github/pull_request_template.md`, `.github/PULL_REQUEST_TEMPLATE.md` (and `.txt`). |
| 35 | - The `docs/` directory: `docs/pull_request_template.md`, `docs/PULL_REQUEST_TEMPLATE.md` (and `.txt`). |
| 36 | - A multiple-template subdirectory: `.github/PULL_REQUEST_TEMPLATE/*.md`, `docs/PULL_REQUEST_TEMPLATE/*.md`, `PULL_REQUEST_TEMPLATE/*.md`. |
| 37 | |
| 38 | Then resolve to a single template (or none): |
| 39 | |
| 40 | 1. **No template file found** — the repository has no PR template. Record "no repository template" and continue. Step 4 uses the default structure. |
| 41 | 2. **Exactly one single-file template found** — `Read` it in full, including HTML comments. Record its path and full contents. |
| 42 | 3. **A `PULL_REQUEST_TEMPLATE/` directory with multiple templates** — GitHub selects one per PR and the skill cannot know which applies. Use `AskUserQuestion` to ask which template to conform to, listing the filenames plus a "None — use the default structure" option. `Read` the chosen file in full and record its path and contents. If the user picks "None," record "no repository template." |
| 43 | |
| 44 | Carry the recorded result (the template path and full contents, or "no repository template") into Step 4. Preserve the template's HTML comments verbatim in what you carry forward — they often state how the template is meant to be used. |
| 45 | |
| 46 | ## Step 3: Analyze Changes |
| 47 | |
| 48 | Review the branch diff, commits, and relevant source code to understand the PR. Identify the central mechanism — the primary purpose of the PR. If the PR is about feature flags, migrations, or behavioral changes, those ARE the point, not a side detail. Classify the change type (new feature, bug fix, refactoring, docs update, config change, etc.) and read related source files as needed to understand the full scope. |
| 49 | |
| 50 | Find the headline behavioral effect — what changes for a user or caller and why — and the central mechanism's key facts (a flag and its default, a migration's direction, the new vs. old behavior). Do not catalog every config value, phase, or mode; the diff carries the specifics. The goal is a short description, not an exhaustive one. |
| 51 | |
| 52 | While analyzing, count the **significant** changed files from `branch stats`, since that count gates the "What to look at first" section in Step 4. |