merge-stack

📁 rarestg/rarestg-skills 📅 5 days ago
2
总安装量
2
周安装量
#65793
全站排名
安装命令
npx skills add https://github.com/rarestg/rarestg-skills --skill merge-stack

Agent 安装分布

opencode 2
gemini-cli 2
claude-code 2
github-copilot 2
codex 2
kimi-cli 2

Skill 文档

Merge Stacked PRs

Merge a linear chain of stacked PRs into main one at a time, re-targeting each subsequent PR to main before merging.

Workflow

1. Discover the stack

gh pr list --state open --json number,title,headRefName,baseRefName,additions,deletions \
  --jq '.[] | "#\(.number) \(.headRefName) → \(.baseRefName) (+\(.additions) -\(.deletions))"'

If a branch prefix argument is provided, filter to only PRs whose branch names match it. Confirm the PRs form a single linear chain ending at main. Show the user the full stack (bottom to top) and get confirmation before proceeding.

2. Merge bottom-up

Starting with the PR that targets main:

  1. Merge it: gh pr merge <number> --merge
  2. For each next PR in the chain: a. Re-target to main: gh pr edit <number> --base main b. Merge it: gh pr merge <number> --merge
  3. Repeat until all PRs are merged.

Use --merge (not --squash or --rebase) to preserve commit history, unless the user requests otherwise.

3. Verify

gh pr list --state open

Confirm zero open PRs remain (or only unrelated PRs remain) and report the result.

Notes

  • Always show the user the discovered stack and get confirmation before merging anything.
  • If a merge fails (e.g. conflicts), stop and report the issue rather than continuing.
  • If a merge fails because required CI checks haven’t passed (common after re-targeting to main), suggest gh pr merge <number> --merge --auto to auto-merge once checks pass.
  • The branch naming pattern is typically incremental (e.g. feature-1, feature-2), but detect the actual chain by following base branch references, not by name pattern.