rewrite-pr-historylisted
Install: claude install-skill damson/hard-won-skills
# Rewrite PR history
The goal: never lose the user's work, never force-push a shared branch, and
show the plan before rewriting. Every step is recoverable if interrupted.
## Procedure
### 1. Read PR state
```bash
gh pr view <N> --json baseRefName,headRefName,mergeable,mergeStateStatus,reviewDecision,commits
```
Confirm:
- Head branch is **not** `main`, `master`, `develop`, or any protected branch.
- The branch is yours to rewrite — checked, not assumed: only you appear in
`git shortlog -sn origin/<base>..HEAD`, and only one open PR has this head
(`gh pr list --head <branch>`). Either check failing means the branch may be
shared — ask before rewriting; a rewrite under someone else's feet loses
their work.
- If `reviewDecision` shows pending or approved reviews, surface that — review
comments anchor to commits and go stale after a rewrite. Ask before continuing.
### 2. Sync working tree
```bash
git fetch origin --prune
git checkout <head-branch>
```
Verify clean working tree (`git status -s` returns empty). If dirty, stop and
ask the user — never auto-stash without consent.
### 3. Show the plan
Run `git log --oneline origin/<base>..HEAD` and `git diff origin/<base> --stat`.
State the intended action in plain words (e.g. "I'll drop commit X by rebasing
--onto origin/main starting after it"). **Wait for explicit user "go"** before
rewriting.
### 4. Rewrite
Use the smallest-blast-radius command for the job:
| Goal | Command |
|---|---|
| Resolve conflicts wi