agentleFS
PradnyeshpPradnyeshp/Claude-Skills/.claude/skills/squash/SKILL.md

squash

Skill2 starsChanged 4 months agoMITView on GitHub

Clean up a branch's commit history before merge — squash WIP/fixup commits into logical units and rewrite messages — safely, without losing work. Use when the user says "squash my commits", "clean up the history", "combine these commits", "tidy the branch before merging", "squash the fixups", or "rewrite the commit history".

  • Deletes or force-pushes
  • Commits and pushes

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Require a clean working tree: If there are uncommitted changes, stop and tell the user to commit or stash first — a rewrite with a dirty …

    line 23
  2. Very specific:

    Verify nothing was lost: after rewriting, confirm git diff <base>..HEAD is identical to before (same tree), and the test suite still passes.

    line 34
  3. Distinctive:

    Never rewrite history with a dirty tree or without a recoverable backup (reflog/backup branch).

    line 39
  4. Very specific:

    Use --force-with-lease, never a bare --force, when a push is needed — and only after the user confirms.

    line 41

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Branch state

!git status --short 2>/dev/null

!git log --oneline --no-merges "$(git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null)"..HEAD 2>/dev/null | head -30

!git branch --show-current 2>/dev/null

Instructions

Tidy the current branch's commits onto its base ($ARGUMENTS if given, else main/master) so the history that merges is clean and logical. History rewriting is destructive — be careful and confirm before rewriting.

Before touching history

  1. Require a clean working tree. If there are uncommitted changes, stop and tell the user to commit or stash first — a rewrite with a dirty tree risks losing work.
  2. Confirm the branch isn't shared, or that collaborators know. Rewriting commits others have pulled forces a --force-push that rewrites their view. If the branch is already pushed, note that a force-push (--force-with-lease) will be needed and confirm that's acceptable.
  3. Make a safety net: record the current tip (git rev-parse HEAD) or suggest a backup ref (git branch backup/<name>) so the pre-squash state is recoverable via reflog if anything goes wrong.
  4. Identify the base with git merge-base and review the commits above. Propose how to group them into logical units (e.g. squash all fixup/wip/address review commits into the feature commit they belong to) before doing anything.

Squashing

  1. Prefer the safest mechanism that fits:
    • Whole branch into one commit: git reset --soft <base> then a single git commit — simple and avoids interactive rebase.
    • Selective grouping: a non-interactive autosquash (git rebase --autosquash) when commits were made with --fixup, or scripted reword — interactive -i rebase isn't available in this environment, so drive it with explicit commands.
  2. Write clear messages for the resulting commits (Conventional Commits if the repo uses them — see the commit-message skill). One commit per logical change, each message explaining the why.
  3. Verify nothing was lost: after rewriting, confirm git diff <base>..HEAD is identical to before (same tree), and the test suite still passes. The content must be unchanged — only the history shape changes.
  4. Don't push automatically. Show the resulting git log --oneline and the exact git push --force-with-lease command, and let the user run it.

Rules

  1. Never rewrite history with a dirty tree or without a recoverable backup (reflog/backup branch). State the recovery path.
  2. The final tree must be byte-identical to before squashing — verify with a diff. Squashing changes history, never content.
  3. Use --force-with-lease, never a bare --force, when a push is needed — and only after the user confirms. Don't push on their behalf unless asked.
  4. Be cautious on shared branches: call out who is affected before any rewrite.
  5. End with the new history, confirmation the diff is unchanged and tests pass, and the push command the user can run.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.