From sd0x-dev-flow
Generates partial rebase plan table and git rebase --onto command for squash-merge repos by auto-detecting commits to keep or drop.
npx claudepluginhub sd0xdev/sd0x-dev-flow --plugin sd0x-dev-flowThis skill is limited to using the following tools:
Analyze branch history → identify squash-merged commits → generate precise `git rebase --onto` command.
Provides advanced Git rebase patterns for linear history, stacked PRs, commit cleanup, and converting merge-heavy branches using --reapply-cherry-picks, --onto, and interactive workflows.
Safely rebases Git branches with automatic timestamped backups, conflict resolution steps, result verification, and PROJECT.md merge policy checks.
Guides advanced Git workflows: interactive rebase for history editing, cherry-pick for targeted commits, bisect for bug hunting, worktrees for multi-branch development. Use for clean PRs, recovery, collaboration.
Share bugs, ideas, or general feedback.
Analyze branch history → identify squash-merged commits → generate precise git rebase --onto command.
git rebase without squash-merge complexity (use git directly)/merge-prep)git cherry-pick)In squash-merge repositories, when a feature branch is based on another branch that was already squash-merged:
main: A ─── S (squash merge of B1+B2+B3) ─── ...
↑
feature: A ─ B1 ─ B2 ─ B3 ─ F1 ─ F2 ─ F3
↑ drop (in S) ↑ keep (unique)
Need: git rebase --onto main B3 feature to keep only F1-F3.
Claude must not execute git rebase unless user explicitly authorizes. Default: output commands for manual execution.
Note on
allowed-tools:Bash(bash:*)is required to run the analysis script. Cannot narrow to specific script paths until #9354 is resolved.
Before starting, validate:
| Check | Command | Fail action |
|---|---|---|
| Not on shared branch | git branch --show-current must not be main or develop | Abort with warning |
| Clean working tree | git status --porcelain must be empty | Abort: "stash or commit changes first" |
| Not detached HEAD | git symbolic-ref HEAD succeeds | Abort: "checkout a branch first" |
Step 1: Analyze → run script to detect commits
Step 2: Identify → determine keep/drop boundary (cut point)
Step 3: Display → output rebase plan
Step 4: Confirm → user reviews
Step 5: Execute → output or execute rebase command
Step 6: Verify → confirm history is correct
bash skills/smart-rebase/scripts/smart-rebase-analyze.sh [--target origin/main]
Auto-detect mode uses git cherry to find commits already cherry-picked to target. Squash merges cannot be detected by git cherry — proceed to Step 2.
Case A — User provides base branch or commit
# Resolve the common ancestor as cut candidate
git merge-base <base-branch> HEAD
# Or specify the cut point commit directly
bash skills/smart-rebase/scripts/smart-rebase-analyze.sh --base <branch-or-commit>
Case B — Inference needed
target_new squash merge commit messagescommits messages in current branch--baseCase C — git cherry detected all
When cherry_dropped > 0, detected commits can be dropped. Verify cut point is contiguous (all drops must precede all keeps).
## Rebase Plan
| Item | Value |
| -------------- | --------------------------------------- |
| Current branch | feat/my-feature |
| Target | origin/main (dd21265c) |
| Cut point | 06a7fae6 |
| Keep | 3 commits |
| Drop | 15 commits (already in main via squash) |
### Commits to Keep
1. `57d7898a` feat: Add error classification framework
2. `05c11119` docs: Document classification rules
3. `da987681` fix: Correct classification accuracy
### Commits to Drop (already in main)
1. `f76209f4` docs: Add RPC optimization design
...
Display plan and wait for user confirmation before proceeding.
# Fetch only if target is a remote-tracking ref
git fetch origin <target-branch> # skip if target is local
git rebase --onto <target> <cut-point> <branch>
# Confirm history is correct
git log --oneline -10
# Confirm commit count
git log --oneline HEAD --not <target> | wc -l
On success, suggest force push:
git push --force-with-lease origin <branch>
| Scenario | Action |
|---|---|
| Already squash-merged | git rebase --skip (dropped commit) |
| Real content conflict | Manual resolve → git rebase --continue |
| Cannot resolve | git rebase --abort to restore original state |
--force-with-lease (prevent overwriting others' pushes)Rebase plan table with keep/drop commits:
--base: includes git rebase --onto command ready to copy-paste--base follow-up--force-with-lease used (never --force)# Auto-detect (cherry-pick scenarios)
/smart-rebase
# Specify base branch (squash-merge scenarios)
/smart-rebase --base fix/feature-xyz
# Specify non-main target
/smart-rebase --target origin/develop --base fix/hotfix-123
| File | Purpose | When to Read |
|---|---|---|
| smart-rebase-analyze.sh | Analysis script | Step 1 |