← back to Cli Printing Press
fix(skills): publish skill checks for merged PRs before reusing branch
360db307cef09ac578074f1ed540a6f9d71e1753 · 2026-04-04 00:41:43 -0700 · Trevin Chow
The publish skill only checked --state open for existing PRs. If a
previous PR was merged, it reused the branch name, force-pushed onto
the merged branch, and silently updated a closed PR nobody watches.
Now checks --state merged after open returns empty. If a merged PR
exists on the same branch, auto-creates a timestamped branch name
(feat/<cli-name>-YYYYMMDD) instead of reusing the merged one.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Files touched
M skills/printing-press-publish/SKILL.md
Diff
commit 360db307cef09ac578074f1ed540a6f9d71e1753
Author: Trevin Chow <trevin@trevinchow.com>
Date: Sat Apr 4 00:41:43 2026 -0700
fix(skills): publish skill checks for merged PRs before reusing branch
The publish skill only checked --state open for existing PRs. If a
previous PR was merged, it reused the branch name, force-pushed onto
the merged branch, and silently updated a closed PR nobody watches.
Now checks --state merged after open returns empty. If a merged PR
exists on the same branch, auto-creates a timestamped branch name
(feat/<cli-name>-YYYYMMDD) instead of reusing the merged one.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---
skills/printing-press-publish/SKILL.md | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/skills/printing-press-publish/SKILL.md b/skills/printing-press-publish/SKILL.md
index d4a652cb..ad591d68 100644
--- a/skills/printing-press-publish/SKILL.md
+++ b/skills/printing-press-publish/SKILL.md
@@ -353,12 +353,21 @@ Parse the result:
- If the list is non-empty, store `EXISTING_PR_NUMBER` and `EXISTING_PR_URL` from the first entry
- If the list is empty or the command fails (network, auth), set `EXISTING_PR_NUMBER=""` — proceed as if no PR exists
+**If no open PR was found**, also check for a previously merged PR on the same branch:
+
+```bash
+MERGED_PR=$(gh pr list --repo mvanhorn/printing-press-library --head "$HEAD_REF" --state merged --author @me --json number --jq '.[0].number' 2>/dev/null)
+```
+
+If `MERGED_PR` is non-empty, the branch name was already used and merged. Set `BRANCH_MERGED=true` so Step 8 creates a new branch name (e.g., `feat/<cli-name>-YYYYMMDD`) instead of reusing the merged branch. Do NOT force-push onto a merged branch — `gh pr edit` would silently update a closed PR nobody is watching.
+
If an existing open PR was found, inform the user:
> "Found your open PR #N for `<cli-name>`. Will update it with the new version."
This determines the flow in Step 8:
- **Existing open PR:** Overwrite the branch automatically, force-push, update the PR description
-- **No open PR:** Standard flow — ask about branch conflicts if any, create a new PR
+- **No open PR, branch not merged:** Standard flow — ask about branch conflicts if any, create a new PR
+- **No open PR, branch was merged (`BRANCH_MERGED=true`):** Auto-create a timestamped branch `feat/<cli-name>-YYYYMMDD` and create a new PR
## Step 8: Branch, Commit, and PR
@@ -372,7 +381,15 @@ Always overwrite the branch — the intent is clearly to update:
git checkout -B feat/<cli-name>
```
-**If `EXISTING_PR_NUMBER` is empty** (no open PR):
+**If `EXISTING_PR_NUMBER` is empty and `BRANCH_MERGED` is true** (previous PR was merged):
+
+Auto-create a timestamped branch — do not reuse the merged branch name:
+
+```bash
+git checkout -b feat/<cli-name>-$(date +%Y%m%d)
+```
+
+**If `EXISTING_PR_NUMBER` is empty and `BRANCH_MERGED` is not set** (no open or merged PR):
Check for stale branches and competing PRs:
← 8763a05f fix(cli): sync path resolution for non-paginated list endpoi
·
back to Cli Printing Press
·
feat(cli): hide raw resource commands when promoted exist, a 4b12b325 →