Skip to content

Instantly share code, notes, and snippets.

@matin
Created April 3, 2026 19:32
Show Gist options
  • Select an option

  • Save matin/20be54f0f20963a4d29fec4aaa6e9826 to your computer and use it in GitHub Desktop.

Select an option

Save matin/20be54f0f20963a4d29fec4aaa6e9826 to your computer and use it in GitHub Desktop.
Claude Code skill: merge Dependabot PRs (rebase + squash, worktree isolation)
name merge-dependabot
description Merge open Dependabot PRs one at a time, rebasing on main between each, after verifying safety

Merge all open Dependabot PRs sequentially, verifying each one before merging.

Run this entire workflow in a background agent with worktree isolation so it does not affect the current working directory or branch.

Steps

For each open Dependabot PR (oldest first):

  1. List PRsgh pr list --author "app/dependabot" --state open --json number,title,headRefName

  2. Verify safety — before merging each PR:

    • Run gh pr checks <number> to confirm CI is passing
    • Review the diff (gh pr diff <number>) for anything unexpected beyond a version bump
    • If checks are failing or the diff looks suspicious, skip the PR and report why
  3. Rebase and squash merge — for each PR that passes verification:

    • Fetch the branch: git fetch origin <branch>
    • Check out and rebase onto origin/main: git checkout <branch> && git rebase origin/main
    • Force push the rebased branch: git push --force-with-lease
    • Squash merge: gh pr merge <number> --squash --delete-branch
    • Update main: git checkout main && git pull origin main
  4. Report — after processing all PRs, summarize which were merged, skipped, or failed, and why.

Notes

  • Process PRs one at a time so each rebase includes the previous merge.
  • Always rebase onto origin/main, then squash merge.
  • Always return to main between PRs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment