Git Commit Helper
davila7/claude-code-templates
透過分析 Git diff 來產生具描述性的提交訊息。當使用者需要協助撰寫提交訊息或審閱已暫存的變更時,可使用此功能。
...展開全部關於Git Commit Helper
Git Commit Helper 技能旨在透過分析 Git diff,協助開發人員產生清晰且具說明性的提交訊息。此技能針對提交訊息模糊或結構不佳的常見問題提供解決方案,此類問題可能導致混淆,並阻礙軟體開發專案中的協作。透過根據待提交的暫存變更提供建議,此技能可確保提交訊息內容充實,並遵循提交訊息格式的最佳實務。
此技能採用結構化的方式生成提交訊息,遵循傳統提交格式。它將變更分類為特定類型,例如功能、錯誤修正和文件更新,並提供撰寫有效提交訊息的指引。使用者可透過各種 Git 指令分析已暫存的變更,並獲得量身訂製的提交訊息建議,最終提升其版本控制實務的清晰度與品質。
目標使用者包括軟體開發人員、從事協作專案的團隊,以及任何參與程式碼庫維護的人員。Git Commit Helper 對於希望提升提交訊息品質、簡化工作流程,並確保其版本控制歷史記錄對當前及未來的協作者而言既具意義又易於理解的人士,特別有用。
常見問題
如何使用Git Commit Helper ?
您可以使用 'git diff --staged' 分析已暫存的變更,然後根據這些變更生成提交訊息。
這項工具是否適用於所有 Git 環境?
是的,Git Commit Helper 可在任何支援 Git 指令的環境中使用。
使用此技能是否有任何限制?
為了獲得最佳效果,此技能需仰賴正確使用 Git 指令以及遵循標準的提交格式。
我可以自訂提交訊息的格式嗎?
雖然此技能遵循標準格式,但您可以根據需要調整生成的訊息。
如果我有多個變更需要提交,該怎麼辦?
您可以參考「多檔案提交」指南,有效組織您的提交訊息。
Git Commit Helper
Quick start
Analyze staged changes and generate commit message:
# View staged changesgit diff --staged# Generate commit message based on changes# (Claude will analyze the diff and suggest a message)
Commit message format
Follow conventional commits format:
<type>(<scope>): <description>[optional body][optional footer]Types
- feat: New feature
- fix: Bug fix
- docs: Documentation changes
- style: Code style changes (formatting, missing semicolons)
- refactor: Code refactoring
- test: Adding or updating tests
- chore: Maintenance tasks
Examples
Feature commit:
feat(auth): add JWT authenticationImplement JWT-based authentication system with:- Login endpoint with token generation- Token validation middleware- Refresh token supportBug fix:
fix(api): handle null values in user profilePrevent crashes when user profile fields are null.Add null checks before accessing nested properties.Refactor:
refactor(database): simplify query builderExtract common query patterns into reusable functions.Reduce code duplication in database layer.Analyzing changes
Review what's being committed:
# Show files changedgit status# Show detailed changesgit diff --staged# Show statisticsgit diff --staged --stat# Show changes for specific filegit diff --staged path/to/file
Commit message guidelines
DO:
- Use imperative mood ("add feature" not "added feature")
- Keep first line under 50 characters
- Capitalize first letter
- No period at end of summary
- Explain WHY not just WHAT in body
DON'T:
- Use vague messages like "update" or "fix stuff"
- Include technical implementation details in summary
- Write paragraphs in summary line
- Use past tense
Multi-file commits
When committing multiple related changes:
refactor(core): restructure authentication module- Move auth logic from controllers to service layer- Extract validation into separate validators- Update tests to use new structure- Add integration tests for auth flowBreaking change: Auth service now requires config objectScope examples
Frontend:
feat(ui): add loading spinner to dashboardfix(form): validate email format
Backend:
feat(api): add user profile endpointfix(db): resolve connection pool leak
Infrastructure:
chore(ci): update Node version to 20feat(docker): add multi-stage build
Breaking changes
Indicate breaking changes clearly:
feat(api)!: restructure API response formatBREAKING CHANGE: All API responses now follow JSON:API specPrevious format:{ "data": {...}, "status": "ok" }New format:{ "data": {...}, "meta": {...} }Migration guide: Update client code to handle new response structureTemplate workflow
- Review changes:
git diff --staged - Identify type: Is it feat, fix, refactor, etc.?
- Determine scope: What part of the codebase?
- Write summary: Brief, imperative description
- Add body: Explain why and what impact
- Note breaking changes: If applicable
Interactive commit helper
Use git add -p for selective staging:
# Stage changes interactivelygit add -p# Review what's stagedgit diff --staged# Commit with messagegit commit -m "type(scope): description"
Amending commits
Fix the last commit message:
# Amend commit message onlygit commit --amend# Amend and add more changesgit add forgotten-file.jsgit commit --amend --no-edit
Best practices
- Atomic commits - One logical change per commit
- Test before commit - Ensure code works
- Reference issues - Include issue numbers if applicable
- Keep it focused - Don't mix unrelated changes
- Write for humans - Future you will read this
Commit message checklist
- Type is appropriate (feat/fix/docs/etc.)
- Scope is specific and clear
- Summary is under 50 characters
- Summary uses imperative mood
- Body explains WHY not just WHAT
- Breaking changes are clearly marked
- Related issue numbers are included
安裝 Git Commit Helper
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/git-commit-helper/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
