squash-merge-chain

Squash-merge the upstream PR and rebase downstream branches using gh, jq, git, and jj.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/bjaus/dotfiles --skill squash-merge-chain
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: squash-merge-chain
Source: https://github.com/bjaus/dotfiles/tree/main/plugin/skills/squash-merge-chain
Command: npx skills add https://github.com/bjaus/dotfiles --skill squash-merge-chain

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Managing stacked PR chains across branches can lead to diverging histories and manual, error-prone rebases. This Skill provides a disciplined workflow to squash-merge the most upstream PR and rebase downstream branches so the chain remains linear and clean.

Core Features & Use Cases

  • Detect and order the PR chain starting from the default branch.
  • Create local backups of downstream branches to enable recovery.
  • Squash-merge the upstream PR onto the default branch without deleting the merged branch.
  • Rebase all downstream branches in a linked chain to preserve history and dependency relationships.
  • Verify tree integrity against backups and provide explicit recovery steps if issues arise.
  • Retarget downstream PR bases after the squash merge to maintain correct base references.
  • Force-push rebased branches with safety checks and wait periods to reduce CI conflicts.

Quick Start

Use the smc CLI to squash-merge the most upstream PR in your stacked chain and rebase all downstream branches.

Frequently Asked Questions about squash-merge-chain

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I squash-merge an upstream PR and rebase downstream branches in a stacked chain?

To squash-merge a stacked PR chain, you squash-merge the most upstream PR onto the default branch without deleting it, then rebase all linked downstream branches to preserve history and dependency relationships. This workflow keeps the chain linear and clean.

What is the best way to clean up stacked GitHub PR chains after merging?

Cleaning stacked GitHub PR chains requires rebasing downstream branches to stay in sync after an upstream merge. This process retargets downstream PR bases, verifies tree integrity against backups, and force-pushes with safety checks to maintain correct references.

Do I need git and jj to rebase stacked PR branches?

Yes, rebasing stacked PR branches relies on git, jj, gh, and jq. These tools detect and order the PR chain from the default branch, perform local backup tagging, and execute the history rewrites required for downstream synchronization.

How do I recover downstream branches if a rebase fails during a squash merge?

To recover downstream branches after a failed rebase, you use local backup tags created before the history rewrite. The workflow provides explicit recovery steps and verifies tree integrity against these backups to ensure safe restoration.

Why do stacked PRs diverge and require retargeting after a squash merge?

Stacked PRs diverge because a squash merge rewrites upstream history, breaking downstream branch dependencies. Retargeting downstream PR bases after the squash merge ensures branches maintain correct base references and stay synchronized with the default branch.