skills/git-squash-commits/SKILL.md
Squash multiple git commits into a single commit with an auto-generated comprehensive commit message based on the changes made.
npx skillsauth add acking-you/myclaude-skills git-squash-commitsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill helps you squash a range of git commits into a single commit with an automatically generated commit message that summarizes all the changes. It analyzes the commit history and file changes to create a comprehensive, well-structured commit message.
IMPORTANT: Before invoking this skill, you MUST manually reset your branch to the parent of the earliest commit you want to squash. The skill will verify this and prompt you if needed.
Example:
# If you want to squash commits from abc123 to xyz789
# First find the parent of abc123
git log --oneline abc123~5..abc123
# Then reset to the parent (e.g., parent_commit)
git reset --hard parent_commit
When invoking this skill, provide:
The skill will:
ai_docs/git-squash-commits/ directory containing:
The generated commit message follows this structure:
<Type>: <Brief summary of the main changes>
Major changes:
- <Category 1>: <Description>
- <Category 2>: <Description>
- ...
<Specific area> improvements:
- <Detailed change 1>
- <Detailed change 2>
- ...
Other changes:
- <Miscellaneous improvements>
- ...
This squash consolidates N commits focusing on <focus areas>.
Statistics: X files changed, Y insertions(+), Z deletions(-)
User request:
Help me squash commits from f2da9a6 to d2755e90
Skill execution flow:
Please first reset to the parent of f2da9a6:
git reset --hard <parent_commit_id>
Then invoke this skill again.
git merge --squash d2755e90# Get current HEAD
git rev-parse HEAD
# Get parent of start commit
git rev-parse <start_commit>^
# Compare - they should match
# List commits to squash (from start to end, inclusive)
git log --oneline <start_commit>..<end_commit>
# Include the end commit itself
git log --oneline <end_commit> -1
# Get commit messages for analysis
git log --format="%s" <start_commit>~1..<end_commit>
# Get file statistics
git diff --stat <start_commit>~1..<end_commit>
# Get detailed changes for major files
git diff <start_commit>~1..<end_commit> -- <important_files>
Analyze the commits and changes to create a message that:
After generating the commit message but before executing the squash, prompt the user to verify the changes build correctly:
Please run your project's build/compilation command to verify the changes:
- For Node.js: npm run build or yarn build
- For Python: python -m pytest or your test suite
- For Go: go build ./...
- For Rust: cargo build
- For Java/Maven: mvn compile
- For other projects: use your project-specific build command
Please run the build and let me know:
1. If the build succeeds, I will proceed with creating the squash commit
2. If the build fails, share the error output and I will help resolve it
Wait for user response:
# Squash merge all commits
git merge --squash <end_commit>
# Commit with generated message
git commit -m "$(cat <<'EOF'
<generated_message_here>
EOF
)"
# Check new commit is created
git log --oneline -3
# Verify old commits are NOT in current branch
git log --oneline HEAD~20..HEAD | grep -E "(<start_commit_short>|<end_commit_short>)"
# Should return empty
# Create ai_docs directory structure if not exists
mkdir -p ai_docs/git-squash-commits
# Generate summary filename with timestamp and commit hash
SUMMARY_FILE="ai_docs/git-squash-commits/$(date +%Y%m%d_%H%M%S)_$(git rev-parse --short HEAD).md"
# Write summary containing:
# - Squash operation metadata (date, commit range, new commit hash)
# - Generated commit message
# - Statistics (files changed, insertions, deletions)
# - List of original commits that were squashed
cat > "$SUMMARY_FILE" <<EOF
# Git Squash Summary
**Date**: $(date +"%Y-%m-%d %H:%M:%S")
**Branch**: $(git branch --show-current)
**New Commit**: $(git rev-parse HEAD)
## Commit Range Squashed
- Start: <start_commit>
- End: <end_commit>
## Generated Commit Message
\`\`\`
<paste the generated commit message here>
\`\`\`
## Statistics
<paste git diff --stat output>
## Original Commits
<paste git log --oneline output of squashed commits>
EOF
echo "Summary saved to: $SUMMARY_FILE"
ai_docs/git-squash-commits/ directory
YYYYMMDD_HHMMSS_<short_hash>.md (timestamp + new commit hash)ai_docs/ directory should be added to .gitignore if you prefer not to commit these recordsIf the user hasn't reset to the correct parent commit:
git rev-parse <start_commit>^git rev-parse HEADgit reset --hard <correct_parent>development
Write precise technical implementation docs (developer or user) with clear structure, accurate flows, render-safe Mermaid diagrams, and audience-appropriate detail; avoid boilerplate; include a meaningful Code Index for developer docs.
documentation
Generate technical design documents with proper structure, diagrams, and implementation details. Default language is English unless user requests Chinese.
development
Write code-driven technical blog posts with data-flow narrative, rich Mermaid visuals, and citation-backed claims. Covers source code deep dives, architecture analysis, and doc-driven comparisons.
development
Structured web research with multi-source validation. Output reports with complete citation links. Focus on key results, verify information quality.