agentleFS
IcodeNetIcodeNet/agent-skills/skills/squash-and-push/SKILL.md

squash-and-push

Skill0 starsChanged 4 months agoMITView on GitHub

Squash the current branch's full history since its base into one commit and force-push with lease. Manual command — run with /squash-and-push when the user asks to squash and push the current branch as a single commit.

  • Deletes or force-pushes
  • Commits and pushes

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 8 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Run git branch --show-current.

    line 12
  2. Very specific:

    Run git status --short and git rev-parse --abbrev-ref --symbolic-full-name @{u}.

    line 13
  3. Distinctive:

    If upstream is missing, stop and ask which base/upstream to use.

    line 14
  4. Distinctive:

    Run git fetch origin main (substitute the repo's actual default branch throughout).

    line 15
  5. Distinctive:

    If git status --short is not empty, stage with git add -A and commit using the repo's commit-message convention.

    line 18
  6. Distinctive:

    Always pass the commit message via HEREDOC.

    line 19
  7. Distinctive:

    Use the base branch as the root reference:

    line 22
  8. Very specific:

    If BRANCH_COMMITS and MAIN_DELTA differ, stop and report the blocker before squashing.

    line 27
  9. Very specific:

    If BRANCH_COMMITS is 0, report the blocker (nothing to squash) and stop.

    line 29
  10. Very specific:

    If BRANCH_COMMITS > 1, run git reset --soft HEAD~$BRANCH_COMMITS.

    line 33
  11. Distinctive:

    Create one final commit in the repo's message convention, via HEREDOC.

    line 34
  12. Very specific:

    Never calculate the squash span from @{u}..HEAD.

    line 46
  13. Very specific:

    Never run git reset --soft origin/main or any non-HEAD~N reset target for the squash.

    line 47
  14. Very specific:

    Never use plain --force; always --force-with-lease.

    line 48
  15. Distinctive:

    If conflicts or errors occur, stop and report the exact blocker before retrying.

    line 49

≈ “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 and Push

Squash all commits on the current branch (since it diverged from the base branch) into one commit, then push with --force-with-lease.

  1. Safety + scope checks
    • Run git branch --show-current; abort if on main/master.
    • Run git status --short and git rev-parse --abbrev-ref --symbolic-full-name @{u}.
    • If upstream is missing, stop and ask which base/upstream to use.
    • Run git fetch origin main (substitute the repo's actual default branch throughout).
  2. Commit working changes first (required when dirty)
    • If git status --short is not empty, stage with git add -A and commit using the repo's commit-message convention.
    • Always pass the commit message via HEREDOC.
  3. Determine the full squash span
    • Use the base branch as the root reference:
      • BASE=$(git merge-base origin/main HEAD)
      • BRANCH_COMMITS=$(git rev-list --count "$BASE..HEAD")
    • Sanity check to avoid misparsed ranges:
      • MAIN_DELTA=$(git rev-list --count origin/main..HEAD)
      • If BRANCH_COMMITS and MAIN_DELTA differ, stop and report the blocker before squashing.
    • The span is always the full branch history since base — including commits already pushed — never just @{u}..HEAD.
    • If BRANCH_COMMITS is 0, report the blocker (nothing to squash) and stop.
  4. Squash into one commit
    • git add -A.
    • If BRANCH_COMMITS > 1, run git reset --soft HEAD~$BRANCH_COMMITS.
    • Create one final commit in the repo's message convention, via HEREDOC.
  5. Push safely
    • git push --force-with-lease.
  6. Verify + report
    • git status --short (expect clean).
    • Recompute: git rev-list --count "$(git merge-base origin/main HEAD)..HEAD" (expect 1) and git rev-list --count origin/main..HEAD (expect 1).
    • Report branch name, new commit SHA, and confirmation of a single-commit branch.

Hard constraints

  • Never calculate the squash span from @{u}..HEAD.
  • Never run git reset --soft origin/main or any non-HEAD~N reset target for the squash.
  • Never use plain --force; always --force-with-lease.
  • If conflicts or errors occur, stop and report the exact blocker before retrying.

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.