agentleFS
jcottamjcottam/agent-resources/skills/engineering/squash-branch/SKILL.md

squash-branch

Skill25 starsChanged 6 months agoMITView on GitHub

Review commits in a branch, date range, or recent history; group related work into a clean linear history; and verify that the final tree is unchanged. Use when the user asks to squash commits, clean Git history, combine WIP commits, organize today's commits, or prepare a readable commit stack.

  • Deletes or force-pushes
  • Commits and pushes

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. lbedner/aegis-stack★ 146same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository13 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    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:

    Create a backup branch.

    line 24
  2. Distinctive:

    Run the project's tests and build.

    line 27
  3. Distinctive:

    Use the range named by the user:

    line 32
  4. Distinctive:

    If there are uncommitted changes, commit them only when the user asks.

    line 42
  5. Distinctive:

    Read the log, messages, and file statistics:

    line 47
  6. Distinctive:

    Prefer a few clear commits, but do not force unrelated work into an arbitrary commit count.

    line 59
  7. Distinctive:

    Keep commits in their original order unless reordering is required to form a logical group.

    line 94
  8. Very specific:

    Do not use git checkout <sha> -- .

    line 98
  9. Distinctive:

    Run the repository's normal quality gates.

    line 111
  10. Distinctive:

    If the tree differs or a quality gate fails, do not push.

    line 114
  11. Very specific:

    Never use a plain --force push.

    line 125
  12. Distinctive:

    Use an imperative subject of 72 characters or fewer.

    line 130
  13. Distinctive:

    Do not list every changed file.

    line 132

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Squash Branch

Turn noisy Git history into a small, reviewable commit stack without changing the final code.

Workflow

  1. Define the commit range.
  2. Review each commit's purpose and files.
  3. Group related commits.
  4. Create a backup branch.
  5. Rebuild the commits.
  6. Compare the rebuilt tree with the backup.
  7. Run the project's tests and build.
  8. Push with --force-with-lease.

1. Define the range

Use the range named by the user:

  • Feature branch: <base>..HEAD
  • Since a commit or tag: <ref>..HEAD
  • Today's work: commits since local midnight
  • Recent work: the requested number of commits

Confirm the current branch, working tree, remote, and selected base before changing history.

If there are uncommitted changes, commit them only when the user asks. Otherwise, ask whether to commit or stash them.

2. Review the commits

Read the log, messages, and file statistics:

git log <range> --reverse --format="%H %s%n%b---"
git diff <base>...HEAD --stat
git show --stat <sha>

Group commits by purpose. Combine fixups, tests, documentation, and polish with the change they support. Keep unrelated features, infrastructure changes, and reverts separate.

Prefer a few clear commits, but do not force unrelated work into an arbitrary commit count.

3. Create a backup

git branch backup/<branch>-<date> HEAD

Record the original tip and base commit. The backup protects the exact tree while history is rebuilt.

4. Rebuild the history

Reset to the base only after the backup exists:

git reset --hard <base>

For contiguous groups, restore the tree at each group's tip:

git read-tree -u --reset <group-tip>
git commit -m "<clear subject>" -m "<why this group exists>"

For non-contiguous groups, apply the selected commits without committing, then create one new commit:

git cherry-pick -n <sha-1> <sha-2> <sha-3>
git commit -m "<clear subject>" -m "<why this group exists>"

Keep commits in their original order unless reordering is required to form a logical group. Stop and report conflicts rather than guessing how to resolve them.

Do not use git checkout <sha> -- . to restore a full tree. It can leave files that later commits deleted.

5. Verify

The rebuilt tree must exactly match the backup:

git diff --exit-code backup/<branch>-<date> HEAD
git log <base>..HEAD --oneline
git status --short

Run the repository's normal quality gates. Include tests and a production build when available.

If the tree differs or a quality gate fails, do not push.

6. Push safely

Rewriting main or master requires clear user approval. Warn that other checkouts may need to reset after the push.

git push --force-with-lease origin <branch>

Never use a plain --force push. Delete the backup only after verification and the push both succeed.

Commit messages

  • Use an imperative subject of 72 characters or fewer.
  • Explain why the group exists in one or two body sentences.
  • Do not list every changed file.

Final report

Report:

  • The old and new commit counts
  • The new commit list
  • Quality gates and their results
  • The pushed branch
  • Any reset command collaborators may need

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.