SQ

Cleans up commit history by squashing multiple feature branch commits into a single commit.

Install

mkdir -p .claude/skills/squash-branch && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11710" && unzip -o skill.zip -d .claude/skills/squash-branch && rm skill.zip

Installs to .claude/skills/squash-branch

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Squash all commits on a feature branch into a single commit. Use when the user wants to clean up commit history, squash commits, or consolidate branch changes into one commit.
175 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Generate a patch from a feature branch against a base branch
  • Reset the feature branch to the base branch
  • Apply the generated patch as a single commit
  • Prompt for a commit message if not provided
  • Display the new clean commit history and diff statistics

How it works

The skill generates a diff patch from the feature branch, switches to the base branch, deletes and recreates the feature branch from the base, then applies the patch as a single commit.

Inputs & outputs

You give it
Feature branch name, base branch name, and optional commit message
You get back
New clean commit history on the feature branch with a single commit

When to use squash-branch

  • Clean up feature branch history
  • Consolidate commit logs
  • Prepare clean PRs

About this skill

Squash Branch Skill

Squash all commits on a feature branch into a single commit by generating a patch, recreating the branch from the base, and applying the patch.

Parameters

The user should provide:

  • feature_branch: The branch to squash (e.g., jose/vectors, feature/my-feature)
  • base_branch: The branch to squash against (e.g., mainline, main, master)
  • commit_message (optional): If not provided, prompt the user for a commit message

Instructions

  1. Verify current state: Ensure the working directory is clean and you're on the feature branch

    git status
    git branch --show-current
    
  2. Generate the patch: Create a diff between the base branch and feature branch

    git diff <base_branch>...<feature_branch> > /tmp/squash-branch.patch
    
  3. Switch to base branch and delete feature branch:

    git checkout <base_branch>
    git branch -D <feature_branch>
    
  4. Recreate feature branch from base and apply patch:

    git checkout -b <feature_branch>
    git apply /tmp/squash-branch.patch
    
  5. Prompt for commit message: If no commit message was provided, use AskUserQuestion to ask the user what commit message they want

  6. Stage and commit:

    git add -A
    git commit -m "<commit_message>
    
    Co-Authored-By: Claude <[email protected]>"
    
  7. Show final result: Display the new clean commit history

    git log --oneline <base_branch>..<feature_branch>
    git diff --stat <base_branch>...<feature_branch>
    

Example Usage

User: "Squash my feature/auth branch against main with message 'Add user authentication'"

User: "Clean up the commit history of jose/vectors against mainline"

User: "/squash-branch feature_branch=dev/new-feature base_branch=main"

Important Notes

  • This operation is destructive to the local branch history - make sure changes are not pushed and nothing other than the feature branch is modified
  • Always verify the patch was created successfully before deleting the branch
  • If the patch application fails, the original branch is already deleted - warn the user about this risk
  • The patch file is stored in /tmp and will be cleaned up by the system

When not to use it

  • When the working directory is not clean
  • When the local branch history should not be destructively modified
  • When changes other than the feature branch are modified

Limitations

  • This operation is destructive to the local branch history
  • The original branch is deleted if the patch application fails
  • The patch file is stored in `/tmp` and will be cleaned up by the system

How it compares

This skill consolidates all commits on a feature branch into a single commit by generating and applying a patch, providing a cleaner history than interactive rebase.

Compared to similar skills

squash-branch side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
squash-branch (this skill)05moReviewIntermediate
ast-grep-find37moReviewIntermediate
clean43moReviewIntermediate
code-transfer19moReviewBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

More by diegosouzapw

View all by diegosouzapw

helm-chart-scaffolding-v2

diegosouzapw

Helm Chart Scaffolding workflow skill. Use this skill when the user needs Comprehensive guidance for creating, organizing, and managing Helm charts for packaging and deploying Kubernetes applications and the operator should preserve the upstream workflow, copied support files, and provenance before

00

cc-skill-coding-standards-v2

diegosouzapw

Coding Standards & Best Practices workflow skill. Use this skill when the user needs Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development and the operator should preserve the upstream workflow, copied support files, and provenance before

00

worktree-setup

diegosouzapw

Automatically invoked after `git worktree add` to create data/shared symlink and data/local directory. Required before starting work in any new worktree.

00

parsehub-automation

diegosouzapw

Automate Parsehub tasks via Rube MCP (Composio). Always search tools first for current schemas.

00

signalwire-agents-sdk

diegosouzapw

Expert assistance for building SignalWire AI Agents in Python. Automatically activates when working with AgentBase, SWAIG functions, skills, SWML, voice configuration, DataMap, or any signalwire_agents code. Provides patterns, best practices, and complete working examples.

00

agent-sales-engineer

diegosouzapw

Expert sales engineer specializing in technical pre-sales, solution architecture, and proof of concepts. Masters technical demonstrations, competitive positioning, and translating complex technology into business value for prospects and customers.

00

Search skills

Search the agent skills registry