write-prlisted
Install: claude install-skill 0xdeafcafe/skills
# write-pr - compose, verify, and open a PR
## Phase 0 - Sanity checks
Before doing anything:
```bash
# Where are we, where's the base, what's the state?
git status --short
git rev-parse --abbrev-ref HEAD
git rev-list --count HEAD ^origin/<main> # commits ahead of main
git rev-list --count origin/<main> ^HEAD # commits behind main
gh pr view --json number,state 2>/dev/null # does a PR already exist?
```
Hard gates:
- **Branch is not the main branch.** Refuse to open a PR from `main` /
`master` / `trunk`. The user is in the wrong branch.
- **There are commits ahead of base.** A branch with no commits ahead
has nothing to PR.
- **A PR doesn't already exist for this branch.** If `gh pr view` finds
one, stop and tell the user - they probably want `/drive-pr` instead.
- **No uncommitted changes** (or, if any, ask whether to commit them
first, stash, or proceed regardless).
If the branch is **behind base** (`git rev-list --count origin/<main> ^HEAD > 0`),
flag it: the PR will be evaluated against an older base. Offer to
rebase / merge in `main`, but don't do it without permission - that's
history-modifying.
## Phase 1 - Find context for the description
The PR description should explain **what** the PR does, **why**, and
**how to test it**. Pull that material from:
### 1a. Commit messages
```bash
git log origin/<main>..HEAD --pretty='%h %s' --reverse
git log origin/<main>..HEAD --pretty='%B' --reverse # full messages
```
If commits are well-written, the body i