选项
首页首页 Skill 代码审查 Git Commit Helper

通过分析 Git diff 生成描述性提交信息。当用户请求帮助撰写提交信息或审查已暂存的更改时,可使用此功能。

...展开全部
50
更新时间 2026-06-29

关于Git Commit Helper

Git Commit Helper 技能旨在通过分析 Git 差异,帮助开发者生成清晰且描述性强的提交信息。它解决了提交信息模糊或结构不佳这一常见问题,此类问题可能导致混淆并阻碍软件开发项目的协作。该技能基于待提交的变更提供建议,确保提交信息内容充实,并遵循提交信息格式的最佳实践。

该技能采用结构化的提交信息生成方法,遵循常规提交格式。它将变更分类为功能、修复和文档更新等具体类型,并提供撰写有效提交信息的指南。用户可以使用各种 Git 命令分析已暂存的变更,并获得量身定制的提交信息建议,从而最终提高版本控制实践的清晰度和质量。

目标用户包括软件开发人员、从事协作项目的团队以及任何参与代码库维护的人员。Git Commit Helper 对于希望提高提交信息质量、优化工作流程,并确保其版本控制历史记录对当前和未来的协作者而言既具有意义又易于理解的人士尤为有用。

常见问题

如何使用Git Commit Helper ?

您可以使用 'git diff --staged' 分析暂存的更改,然后根据这些更改生成提交信息。

这项技能是否兼容所有 Git 环境?

是的,Git Commit Helper 可在任何支持 Git 命令的环境中使用。

使用此技能是否有任何限制?

为了获得最佳效果,该技能依赖于对 Git 命令的正确使用以及遵循常规的提交格式。

我可以自定义提交信息格式吗?

虽然该技能遵循标准格式,但您可以根据需要调整生成的提交信息。

如果我有多个更改需要提交,该怎么办?

您可以参考多文件提交指南,有效组织提交信息。

在 GitHub 上查看

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 support

Bug 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 object

Scope examples

Frontend:

  • feat(ui): add loading spinner to dashboard
  • fix(form): validate email format

Backend:

  • feat(api): add user profile endpoint
  • fix(db): resolve connection pool leak

Infrastructure:

  • chore(ci): update Node version to 20
  • feat(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 structure

Template workflow

  1. Review changes: git diff --staged
  2. Identify type: Is it feat, fix, refactor, etc.?
  3. Determine scope: What part of the codebase?
  4. Write summary: Brief, imperative description
  5. Add body: Explain why and what impact
  6. 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

  1. Atomic commits - One logical change per commit
  2. Test before commit - Ensure code works
  3. Reference issues - Include issue numbers if applicable
  4. Keep it focused - Don't mix unrelated changes
  5. 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

所有文件

1 个文件

安装 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

复制 复制
快速设置: 将技能文件夹复制到 .claude/skills/ 目录下,Claude 会自动检测并使用该技能

相关技能

code-simplify
更新时间 2026-07-02
requesting-code-review
更新时间 2026-06-29
commit-standards
更新时间 2026-06-29
fetch-pr-review-comments
更新时间 2026-06-29
OR