You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(skills): harden github-complete-pr force-delete and full recipe
Rule §4 now distinguishes MERGED from CLOSED (unmerged) when allowing
force-delete, and calls out the data-loss tradeoff for closed branches
whose commits live nowhere else.
Full Recipe now enforces Rule §1 by capturing PR state and headRefName
from `gh pr view` and aborting when state is OPEN, refuses to delete
default/protected branches, and only force-deletes after state has been
validated (no more unconditional `|| git branch -D`). Deriving
FEATURE_BRANCH from the PR prevents a mistyped argument from targeting
the wrong branch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: skills/github-complete-pr/SKILL.md
+44-9Lines changed: 44 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,13 +58,20 @@ Use `--ff-only` to avoid accidental merge commits if the local default branch ha
58
58
git branch -d <feature-branch>
59
59
```
60
60
61
-
Use `-d` (safe delete) first. If Git refuses because the branch is not fully merged into the default branch (common when the PR was squash-merged), confirm the PR was actually merged via `gh pr view`, then force the delete:
61
+
Use `-d` (safe delete) first. Git will refuse when the branch is not fully merged into the default branch — this is common and expected when the PR was squash-merged or rebase-merged (the tip commit of the feature branch is not an ancestor of `main`).
62
+
63
+
Force-delete with `-D` is acceptable **only** when one of the following is true, confirmed via `gh pr view`:
64
+
65
+
-`state` is `MERGED` — the changes exist on the default branch under a new commit hash; the original commits are redundant.
66
+
-`state` is `CLOSED`**and** the branch was intentionally abandoned (the user confirms the work will not be reused).
62
67
63
68
```bash
64
69
git branch -D <feature-branch>
65
70
```
66
71
67
-
Never use `-D` without first confirming PR merge/close state.
72
+
**Data-loss warning.** For a `CLOSED` (unmerged) PR, `-D` permanently discards any commits on that branch that live nowhere else — there is no remote copy to recover from once the remote branch is also deleted in step 5. Confirm with the user before force-deleting a closed-unmerged branch.
73
+
74
+
Never use `-D` without first confirming PR state via `gh pr view`.
68
75
69
76
### 5. Delete the remote branch if it still exists
70
77
@@ -94,24 +101,52 @@ The feature branch must be absent from both.
94
101
95
102
## Full Recipe
96
103
104
+
The recipe below enforces Rule §1 (abort when `state` is `OPEN`) and Rule §4 (only force-delete after state validation), and derives `FEATURE_BRANCH` from the PR itself so a mistyped argument cannot cause the wrong branch to be deleted.
0 commit comments