git-commit-helper
Adherence to Conventional Commits and efficient Git history management using types, scopes, and advanced commit tools like fixup/amend. Triggers: git-commit, conventional-commits, breaking-change, fixup, git-amend, rebase.
When & Why to Use This Skill
This Claude skill streamlines Git workflows by enforcing Conventional Commits and optimizing history management. It enables developers to maintain professional, searchable commit logs while automating Semantic Versioning triggers for more efficient release cycles and cleaner project histories.
Use Cases
- Standardizing Team Collaboration: Enforce a consistent commit message format across the team to improve repository readability and searchability.
- Automated Release Management: Use standardized commit types like 'feat' and 'fix' to automatically trigger Semantic Versioning (SemVer) updates and changelog generation.
- Maintaining Clean Repository History: Utilize advanced Git features like 'fixup' and 'autosquash' to merge minor corrections into original commits and eliminate 'junk' commit logs.
- Documenting Breaking Changes: Clearly flag API-breaking changes using standardized indicators to ensure downstream users and automated tools are properly notified.
- Refining Recent Work: Quickly update the last commit with missed changes or message corrections using the 'amend' workflow without creating redundant commits.
| name | git-commit-helper |
|---|---|
| description | Adherence to Conventional Commits and efficient Git history management using types, scopes, and advanced commit tools like fixup/amend. Triggers: git-commit, conventional-commits, breaking-change, fixup, git-amend, rebase. |
Git Commit Helper
Overview
Conventional Commits provide a standardized format for commit messages, enabling automated versioning and clearer project history. This skill covers formatting, managing breaking changes, and using advanced Git features like fixup for a clean history.
When to Use
- Professional Collaboration: To make histories readable and searchable.
- Automated Releases: To trigger Semantic Versioning bumps (PATCH/MINOR/MAJOR).
- Clean History: To fix small mistakes in previous commits without creating "junk" commits.
Decision Tree
- Does the change add a new capability?
- YES: Type
feat(MINOR bump).
- YES: Type
- Does it fix a bug?
- YES: Type
fix(PATCH bump).
- YES: Type
- Does it break backward compatibility?
- YES: Append
!after type/scope OR addBREAKING CHANGE:footer (MAJOR bump).
- YES: Append
- Did you forget a small detail in the last commit?
- YES: Use
git commit --amendor--fixup.
- YES: Use
Workflows
1. Formatting a Feature Commit
- Start the message with
featand an optional scope in parentheses (e.g.,feat(auth):). - Provide a concise description of the new capability.
- If the change breaks compatibility, append
!to the type or add aBREAKING CHANGE:footer. - Run
git commit -m "..."using the formatted string.
2. Using Fixup for Clean History
- Identify the SHA of the commit needing a minor fix.
- Run
git commit --fixup <SHA>to stage the fix as afixup!commit. - Later, perform
git rebase -i --autosquashto automatically merge the fix into the original commit.
3. Amending the Last Commit
- Stage any missed changes using
git add. - Run
git commit --amend --no-editto update the last commit with new files while keeping the same message. - Alternatively, use
--amendwithout--no-editto refine the commit message structure.
Non-Obvious Insights
- Case Sensitivity: Conventional Commit units are not case-sensitive, EXCEPT for
BREAKING CHANGE, which MUST be uppercase. - Breaking Change Indicator: The
!indicator is a shorthand for marking API breaks without needing a full footer. - Trailers: Footers should follow the Git trailer convention (
word-token: value) to be recognized by automated tools.
Evidence
- "feat: a commit of the type feat introduces a new feature... (this correlates with MINOR in Semantic Versioning)." - Conventional Commits
- "The units... MUST NOT be treated as case sensitive... with the exception of BREAKING CHANGE which MUST be uppercase." - Conventional Commits
- "--fixup=reword: creates an 'amend!' commit which replaces the log message..." - Git Docs
Scripts
scripts/git-commit-helper_tool.py: Script to generate conventional commit messages via CLI.scripts/git-commit-helper_tool.js: Shell wrapper for executingfixupandamendcommands.
Dependencies
git(CLI tool)