cleanup-branch

Regroup a feature branch's commits into fewer logically grouped commits without changing the resulting tree.

Updated May 9, 2026
One-click install
npx skills add https://github.com/natelandau/cc-plugin --skill cleanup-branch-natelandau
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cleanup-branch
Source: https://github.com/natelandau/cc-plugin/tree/main/plugins/natelandau-toolkit/skills/cleanup-branch
Command: npx skills add https://github.com/natelandau/cc-plugin --skill cleanup-branch-natelandau

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Feature branches often accumulate messy, incremental commits that are hard to review. This Skill rewrites the branch's local history into a smaller set of logically grouped, reviewable commits while guaranteeing the files on disk stay byte-for-byte identical. ## Core Features & Use Cases - Safe history rewriting: Creates a backup branch before any rewrite, verifies the regrouped tree matches the original exactly, and rolls back from the backup if anything drifts. - Guardrails and early refusal: Refuses to run on the trunk, on a dirty working tree, or when there is one commit or fewer, and never pushes, fetches, rebases, or merges. - Use Case: Before opening a pull request, run /cleanup-branch to condense twelve work-in-progress commits into three conventional commits grouped by concern, then review the printed commit table and optionally delete the backup branch. ## Quick Start Invoke /cleanup-branch on your current feature branch to regroup its commits into a clean, reviewable history.

Frequently Asked Questions about cleanup-branch

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

FAQPage Schema
How do I clean up messy commits on a git feature branch?▼

Invoke /cleanup-branch on the feature branch to regroup its commits into fewer logically grouped conventional commits. It creates a backup branch first, rewrites history locally, and verifies the resulting tree is byte-for-byte identical to the original.

How to squash branch commits without changing the code?▼

This Skill regroups commits rather than squashing to one, preserving logical separation while keeping the final tree identical. It uses the merge-base with the trunk as the regroup base and verifies the tree after rewriting.

Does cleanup-branch push or modify the remote branch?▼

No, it is strictly local and never pushes, fetches, rebases, or merges. If the branch has an upstream, the user must run git push --force-with-lease themselves, since a hook blocks the agent from force pushing.

Why does cleanup-branch refuse to run on my branch?▼

It refuses when the current branch is the trunk, the working tree is dirty, or the branch has one commit or fewer above the merge-base. Commit or stash changes and switch to a feature branch before retrying.

What happens if the regrouped history fails verification?▼

The procedure restores the branch from the backup, leaving it unchanged. If the closing project gate is red due to pre-existing failures, the rewritten history is kept, the backup is retained, and the failures are reported without being fixed.