with one click
commits-squash
// Use when squashing commits on the current branch into fewer logical commits. Triggers: squash, clean up commits, combine commits, tidy history before push or PR.
// Use when squashing commits on the current branch into fewer logical commits. Triggers: squash, clean up commits, combine commits, tidy history before push or PR.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | commits-squash |
| description | Use when squashing commits on the current branch into fewer logical commits. Triggers: squash, clean up commits, combine commits, tidy history before push or PR. |
Squash commits on the current branch into fewer, logically grouped commits. Each resulting commit must be independently revertable — reverting any single commit leaves the codebase in a working state.
Every resulting commit must satisfy: git revert <sha> produces a working codebase. This means:
Group by code dependency, not just by topic or file proximity. Read the actual diffs to trace what depends on what.
These commands run automatically when the skill loads — output replaces each line below:
gh pr view --json baseRefName -q '.baseRefName' 2>/dev/null || truegit rev-parse --verify origin/main 2>/dev/null && echo origin/main || truegit rev-parse --verify origin/master 2>/dev/null && echo origin/master || truegit statusgit log "origin/$(gh pr view --json baseRefName -q '.baseRefName' 2>/dev/null || (git rev-parse --verify origin/main >/dev/null 2>&1 && echo main || echo master))..HEAD" --oneline 2>/dev/null || truePick <base> from the pre-run output:
gh pr view returned onemain if it existsmastergit status output: if uncommitted changes exist, follow the commit skill first, then continue..git/rebase-merge or .git/rebase-apply. If found, STOP and report.git log origin/<base>..HEAD --format='%H %s' --reverse then git show <sha> for eachAnalyze commits and decide which ones belong together based on code dependencies:
If all commits are already logically clean and independently revertable, report "nothing to squash — commits already clean" and stop.
Use the soft-reset pattern since interactive rebase is unavailable. Process groups from oldest to newest:
# Reset all commits
git reset --soft origin/<base>
# Unstage everything
git reset HEAD .
# For each logical group, stage its files and commit:
git add <files-for-group-1>
git commit -m "type(scope): summary for group 1"
git add <files-for-group-2>
git commit -m "type(scope): summary for group 2"
# ... etc
If all commits collapse into a single group, the simpler pattern works:
git reset --soft origin/<base>
git commit -m "type(scope): summary"
commit skill format: <type>(<scope>): <summary>Co-Authored-By trailers from original commitsgit diff --stat origin/<base>..HEAD — must match Phase 1 output exactly. If not, STOP — something was lost.For each new commit, verify it's revertable by reading the diff and confirming:
If a commit fails this check, go back and regroup.
git log origin/<base>..HEAD --oneline — show new commit historycommit skill), then squash.push skill handles force-push safely.