merge-pr
Skill1 starsChanged 2 months agoMITView on GitHub
Merge a PR safely — retargets any dependent PRs to main BEFORE deleting the base branch, so GitHub never auto-closes them
6 other projects use a version of this.
Adopted by
Most recently taken up by
- kdy1/kdy1-scriptstheir own version, first seen Oct 4, 2026
- kaiohenricunha/dotbabeltheir own version, first seen Sep 24, 2026
- r3bl-org/r3bl-open-coretheir own version, first seen Sep 21, 2026
- phmatray/tagouttheir own version, first seen Sep 14, 2026
- tbhb/vale-ai-tellstheir own version, first seen Aug 18, 2026
- anderson-c-santos/claude-skills-networktheir own version, first seen Jun 28, 2026
Used with
Projects with it also use create-pr.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SentrySkillcreate-pr
Create pull requests following Sentry conventions. Use when opening PRs, writing PR descriptions, or preparing changes for review. Follows Sentry's code review guidelines.
Also in 3 projects that use this
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- r3bl-org/r3bl-open-core★ 485same name
- tbhb/vale-ai-tells★ 115same name
- kdy1/kdy1-scripts★ 9same name
- phmatray/tagout★ 4same name
- anderson-c-santos/claude-skills-network★ 1same name
- kaiohenricunha/dotbabel★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-permissionSkill
- downstream-syncSkill
- neon-postgresSkill
- new-featureSkill
- personalizeSkill
- pre-pushSkill
- process-feedbackSkill
- release-notesSkill
- testSkill
- trivialSkill
- upstream-syncSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
When the user invokes /merge-pr <number>, merge that PR while protecting any open PRs whose base branch is about to disappear.
- Very specific: line 37
If state is CLOSED or MERGED, stop.
- Distinctive: line 45
If the list is empty, skip to Step 4 — no retargeting needed.
- Distinctive: line 57
After all retargets, verify with a single re-query:
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Merge a PR Safely (auto-retargets downstream PRs)
When the user invokes /merge-pr <number>, merge that PR while protecting any open PRs whose base branch is about to disappear. Applies the same way regardless of which app or package the PR touches — this is a GitHub-mechanics skill.
The trap this avoids
gh pr merge N --delete-branch deletes the head branch after the merge commit lands on main. If any other open PR has that branch as its baseRefName, GitHub auto-closes those PRs — their base no longer exists. The recovery is a 5-step dance: push the deleted branch back, gh pr reopen, retarget to main, wait for mergeability, then merge.
This skill retargets dependents to main before the base branch is deleted, so nothing auto-closes.
When to use
- Any PR you're about to merge with
--delete-branch(which should be ~every PR). - Stacked PRs: invoke
/merge-prfor each one bottom-up; each call retargets the next layer.
When NOT to use
- The PR doesn't use
--delete-branch(the trap doesn't apply if the head branch persists). - The PR has no dependents AND you don't care if the branch stays — plain
gh pr mergeis fine.
Procedure
Step 1 — Look up the PR's head branch
gh pr view <N> --json headRefName,baseRefName,state,mergeableConfirm: state is OPEN, mergeable is MERGEABLE (or UNKNOWN — GitHub may still be computing). Note headRefName for Step 2.
If state is CLOSED or MERGED, stop. This skill prevents the trap; it does not recover from already-closed PRs.
Step 2 — Find dependent PRs
gh pr list --base "<headRefName from Step 1>" --state open --json number,title,baseRefNameIf the list is empty, skip to Step 4 — no retargeting needed.
Step 3 — Retarget each dependent to main
For each dependent PR number M:
gh api repos/{owner}/{repo}/pulls/M -X PATCH -f base=main --silent{owner} and {repo} are auto-substituted by gh from the current repository — no hardcoding.
After all retargets, verify with a single re-query:
gh pr list --base "<headRefName from Step 1>" --state open --json numberResult should be [].
Step 4 — Merge
gh pr merge <N> --merge --delete-branchDefaults: --merge (matches the repo convention) and --delete-branch (the trap is now prevented). Swap --merge for --squash or --rebase only if the user explicitly asks.
Step 5 — Verify
gh pr view <N> --json state,mergedAtExpect state: MERGED. For each retargeted PR M, confirm it's still OPEN and now targets main:
gh pr view M --json state,baseRefNameCI consideration
Retargeting changes a PR's base but does not push new commits, so CI configured on pull_request events may not re-trigger automatically. If CI must run before merge, push a --allow-empty commit on the head branch after the retarget, or escalate to the user.
Why this exists
Multiple downstream forks independently hit the auto-close trap while merging PR stacks (one stack of 8 PRs cost ~5 minutes of branch-restore + reopen + retarget per PR). The Workflow Rules point at this skill so it's discoverable from the rules layer.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

