PR
Create, update, and review GitHub PRs using gh. Each command is a separate workflow — pick the one that matches the user's intent.
Requested command and target: $ARGUMENTS — if that is blank or still shows the literal placeholder, infer the command from the user's wording using the table below.
Choosing a command
| User says… |
Command |
| "Open a PR", "make a PR", "ship this to review" |
create |
| "Update the PR description", "refresh the PR body", "add the latest commits to the PR" |
update |
| "Review PR #123", "look at this PR", "can you review " |
review |
If the request names no command and the branch has no PR yet, create is the safe default. If a PR already exists, ask before assuming update over review.
When NOT to use
- Merging / closing / reopening a PR — use
gh pr merge / gh pr close directly.
- Drive-by commenting on an existing PR — use
gh pr comment.
- Posting review output to GitHub.
review writes to the terminal for the user to decide what to do with. Only post to GitHub if the user explicitly asks.
Commands
| Command |
Purpose |
create |
Create a PR with a structured body from commits on the branch. |
create -v |
Show the draft, ask y/n before running gh pr create. |
create --draft |
Create as draft (work-in-progress). |
update |
Regenerate the PR body of the current branch's PR to reflect new commits. |
update -v |
Diff old vs new body, confirm before writing. |
review <pr> |
Fetch a PR by number or URL and output a structured review to the terminal. |
Workflow: create
- Safety: current branch must not be
main/master. Abort otherwise — you don't open PRs from the trunk.
- Push: if no upstream,
git push -u origin HEAD. Otherwise verify local ≤ remote.
- Gather:
- Base branch:
gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'
- Commits:
git log origin/<base>..HEAD --oneline
- Diff:
git diff origin/<base>...HEAD
- Generate:
- Title: derive from the primary commit or branch name, reusing conventional-commit
type(scope): description when present. If the branch was committed with a conventional-commit workflow like /commit, the title comes for free from the leading commit's subject.
- Body: fill the template in
references/templates.md. What/Why/How/Changes always. Conditional sections by the table below.
- Confirm (if
-v): print draft title + body, ask yes/no.
- Execute:
gh pr create --title "Title" --body "$(cat <<'EOF'
Body
EOF
)"
Add --draft if --draft was passed.
- Return: the PR URL from
gh's output.
Conditional sections
Include a conditional section only when the trigger below is met. Empty placeholder sections are worse than no section — they train reviewers to skim.
| Section |
Include when the diff includes… |
## Testing |
test files (*.test.*, *.spec.*, __tests__/) OR the change needs manual verification (UI, side effects) |
## Deployment |
DB migrations, config, env vars, feature flags, CI workflow changes, infra |
## Screenshots |
UI files: *.tsx, *.jsx, *.vue, *.svelte, *.css, design assets |
Workflow: update
- Locate PR:
gh pr view --json number,title,body,headRefName. Abort if no PR exists for the current branch.
- Gather (same as create): base branch, commits, full diff.
- Parse body: split the existing body into sections by
## header.
- Regenerate:
- What / How / Changes: regenerate from the commits + diff. These are descriptive — they should always reflect the current state of the branch.
- Why: preserve verbatim. Motivation is set when the PR is opened, comes from a ticket/conversation the branch has no visibility into, and reviewers may have refined it in-place. Regenerating from commits would destroy that context.
- Conditional sections (Testing / Deployment / Screenshots): preserve as-is. Don't auto-add new ones — they often contain reviewer-specific checkboxes and deployment notes that aren't derivable from the diff.
- Confirm (if
-v): show a side-by-side diff of What/How/Changes. Ask yes/no.
- Execute:
gh pr edit <number> --body "$(cat <<'EOF'
New body
EOF
)"
Workflow: review
- Fetch: accept a number or URL. Extract the number if given a URL.
gh pr view <pr> --json title,body,files,commits,additions,deletions
gh pr diff <pr>
- Analyze: for each dimension, form an opinion backed by the diff.
- Scope — one logical change, or several that should be split?
- Code quality — readability, naming, duplication, error handling.
- Testing — covered? missing cases? tests actually exercise the new code?
- Security — injection, auth, secrets, input validation, unsafe deserialization.
- Performance — hot-path allocations, N+1 queries, blocking I/O.
- Commit hygiene — conventional commits? Atomic?
- Size signal: <200 lines → small, 200–500 → medium, 500+ → suggest splitting.
- Output to the terminal using the Review Output Template. Tag each suggestion as
[blocker] (must fix before merge), [should-fix] (address or justify), or [nit] (stylistic preference).
- Do not post the review as a PR comment automatically. The user decides whether to share it.
Handoff from a commit workflow
create assumes the branch's commits follow the conventional-commit format, as produced by a commit workflow like /commit. When that's the case:
- PR title = primary commit's
type(scope): description.
## What bullet list mirrors the commit subjects.
## How groups commits by scope.
If the branch has messy or non-conventional commits, offer to amend or reword them (for example with /commit --amend) before opening the PR rather than papering over it in the body.
1---2name: pr3description: Create, update, or review GitHub pull requests via `gh` CLI. Use when opening a PR from the current branch, refreshing an existing PR's body after new commits, or doing a structured review of somebody's PR by number or URL. Commands: create [-v] [--draft], update [-v], review <number|url>.4---56# PR78Create, update, and review GitHub PRs using `gh`. Each command is a separate workflow — pick the one that matches the user's intent.910Requested command and target: `$ARGUMENTS` — if that is blank or still shows the literal placeholder, infer the command from the user's wording using the table below.1112## Choosing a command1314| User says… | Command |15| --- | --- |16| "Open a PR", "make a PR", "ship this to review" | `create` |17| "Update the PR description", "refresh the PR body", "add the latest commits to the PR" | `update` |18| "Review PR #123", "look at this PR", "can you review <url>" | `review` |1920If the request names no command and the branch has no PR yet, `create` is the safe default. If a PR already exists, ask before assuming `update` over `review`.2122## When NOT to use2324- Merging / closing / reopening a PR — use `gh pr merge` / `gh pr close` directly.25- Drive-by commenting on an existing PR — use `gh pr comment`.26- Posting review output to GitHub. `review` writes to the terminal for the user to decide what to do with. Only post to GitHub if the user explicitly asks.2728## Commands2930| Command | Purpose |31| --- | --- |32| `create` | Create a PR with a structured body from commits on the branch. |33| `create -v` | Show the draft, ask y/n before running `gh pr create`. |34| `create --draft` | Create as draft (work-in-progress). |35| `update` | Regenerate the PR body of the current branch's PR to reflect new commits. |36| `update -v` | Diff old vs new body, confirm before writing. |37| `review <pr>` | Fetch a PR by number or URL and output a structured review to the terminal. |3839## Workflow: create40411. **Safety**: current branch must not be `main`/`master`. Abort otherwise — you don't open PRs from the trunk.422. **Push**: if no upstream, `git push -u origin HEAD`. Otherwise verify local ≤ remote.433. **Gather**:44 - Base branch: `gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'`45 - Commits: `git log origin/<base>..HEAD --oneline`46 - Diff: `git diff origin/<base>...HEAD`474. **Generate**:48 - **Title**: derive from the primary commit or branch name, reusing conventional-commit `type(scope): description` when present. If the branch was committed with a conventional-commit workflow like `/commit`, the title comes for free from the leading commit's subject.49 - **Body**: fill the template in [`references/templates.md`](references/templates.md). What/Why/How/Changes always. Conditional sections by the table below.505. **Confirm** (if `-v`): print draft title + body, ask `yes/no`.516. **Execute**:52 ```bash53 gh pr create --title "Title" --body "$(cat <<'EOF'54 Body55 EOF56 )"57 ```58 Add `--draft` if `--draft` was passed.597. **Return**: the PR URL from `gh`'s output.6061### Conditional sections6263Include a conditional section only when the trigger below is met. Empty placeholder sections are worse than no section — they train reviewers to skim.6465| Section | Include when the diff includes… |66| --- | --- |67| `## Testing` | test files (`*.test.*`, `*.spec.*`, `__tests__/`) OR the change needs manual verification (UI, side effects) |68| `## Deployment` | DB migrations, config, env vars, feature flags, CI workflow changes, infra |69| `## Screenshots` | UI files: `*.tsx`, `*.jsx`, `*.vue`, `*.svelte`, `*.css`, design assets |7071## Workflow: update72731. **Locate PR**: `gh pr view --json number,title,body,headRefName`. Abort if no PR exists for the current branch.742. **Gather** (same as create): base branch, commits, full diff.753. **Parse body**: split the existing body into sections by `## ` header.764. **Regenerate**:77 - **What / How / Changes**: regenerate from the commits + diff. These are descriptive — they should always reflect the current state of the branch.78 - **Why**: preserve verbatim. Motivation is set when the PR is opened, comes from a ticket/conversation the branch has no visibility into, and reviewers may have refined it in-place. Regenerating from commits would destroy that context.79 - **Conditional sections** (Testing / Deployment / Screenshots): preserve as-is. Don't auto-add new ones — they often contain reviewer-specific checkboxes and deployment notes that aren't derivable from the diff.805. **Confirm** (if `-v`): show a side-by-side diff of What/How/Changes. Ask yes/no.816. **Execute**:82 ```bash83 gh pr edit <number> --body "$(cat <<'EOF'84 New body85 EOF86 )"87 ```8889## Workflow: review90911. **Fetch**: accept a number or URL. Extract the number if given a URL.92 ```bash93 gh pr view <pr> --json title,body,files,commits,additions,deletions94 gh pr diff <pr>95 ```962. **Analyze**: for each dimension, form an opinion backed by the diff.97 - **Scope** — one logical change, or several that should be split?98 - **Code quality** — readability, naming, duplication, error handling.99 - **Testing** — covered? missing cases? tests actually exercise the new code?100 - **Security** — injection, auth, secrets, input validation, unsafe deserialization.101 - **Performance** — hot-path allocations, N+1 queries, blocking I/O.102 - **Commit hygiene** — conventional commits? Atomic?1033. **Size signal**: <200 lines → small, 200–500 → medium, 500+ → suggest splitting.1044. **Output** to the terminal using the [Review Output Template](references/templates.md#review-output-template). Tag each suggestion as `[blocker]` (must fix before merge), `[should-fix]` (address or justify), or `[nit]` (stylistic preference).1055. **Do not** post the review as a PR comment automatically. The user decides whether to share it.106107## Handoff from a commit workflow108109`create` assumes the branch's commits follow the conventional-commit format, as produced by a commit workflow like `/commit`. When that's the case:110111- PR title = primary commit's `type(scope): description`.112- `## What` bullet list mirrors the commit subjects.113- `## How` groups commits by scope.114115If the branch has messy or non-conventional commits, offer to amend or reword them (for example with `/commit --amend`) before opening the PR rather than papering over it in the body.