# Consolidating Commits

> Regroup commits since a base into logical commits, keeping any version bump last; not squash-to-one.

- Skill: `socketdev/consolidating-commits` (Agent Skill)
- Install (CLI): `npx skillmds@latest add socketdev/consolidating-commits`
- Raw SKILL.md: https://api.skillmd.com/api/skills/socketdev/consolidating-commits/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: socketdev (https://skillmd.com/u/socketdev)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/socketdev/consolidating-commits

---


# Consolidating commits

When the user says **"consolidate commits"** they mean: regroup the work since
a base ref into LOGICAL commits (one per concern, the auto-lander's grouping),
with a trailing `chore: bump version to X.Y.Z` commit preserved last. They do
NOT mean squashing to a single commit (`squashing-history` owns that).

## Run

```bash
# Preview the grouping (always start here).
node scripts/fleet/consolidate-commits.mts --dry-run

# Rewrite: defaults the base to the previous bump commit (else latest tag).
node scripts/fleet/consolidate-commits.mts

# Explicit base.
node scripts/fleet/consolidate-commits.mts --base v6.0.9
```

The script refuses a dirty worktree (land dirty files first:
`node scripts/fleet/land-work.mts --commit`), verifies the final tree is
byte-identical to the original tip, and hard-restores the original history on
any failure. It never pushes: a rewritten branch needs a separately authorized
lease force-push.

## Contract

- Grouping engine is shared with the auto-lander (`land-work.mts`
  `groupPaths`/`commitMessage`) — one source of truth for what "logical"
  means.
- Bump-last invariant: a `chore: bump version to …` tip is peeled before
  grouping and cherry-picked back as the final commit.
- Nothing is ever lost: byte-identical tree or full restore, no third state.

