mcpField
C
commit-message

commit-message

github.com/jiatastic开发1058 次安装40 周前更新
代码仓库

关于 commit-message

commit-message 是用于分析 Git 变更并起草上下文相关 Conventional Commits 消息的命令行技能。它帮助开发者查看变更文件、按关联内容拆分提交,并描述代码改动的实际目的。

主要功能

  1. 01列出变更文件、状态和类别
  2. 02建议多次提交的文件分组
  3. 03按指定文件模式生成消息
  4. 04仅分析已暂存的变更
  5. 05遵循 Conventional Commits 类型与范围

适用场景

  1. 01提交前检查仓库中的全部变更
  2. 02将无关工作拆分为多次提交
  3. 03为选定文件起草提交消息
  4. 04将代码改动整理为目的明确的描述

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/jiatastic/open-python-skills --skill commit-message

安装后在 Claude Code 中输入/commit-message确认已加载。

附带文件data/commit_patterns.jsonscripts/analyze_changes.py

详细介绍

commit-message

分析 Git 更改,并按照 Conventional Commits 生成结合上下文的提交消息。

快速开始

# Analyze all changes
python3 .shared/commit-message/scripts/analyze_changes.py --analyze

# Get batch commit suggestions
python3 .shared/commit-message/scripts/analyze_changes.py --batch

# Generate message for specific files
python3 .shared/commit-message/scripts/analyze_changes.py --generate "src/api/*.py"

命令

命令描述
--analyze显示所有已更改文件的状态和类别
--batch建议如何将更改拆分为多个提交
--generate [pattern]为匹配的文件生成提交消息
--staged仅分析暂存的更改(默认:所有更改)

提交类型

类型描述示例
feat新功能feat(api): add user authentication
fix修复错误fix(db): resolve connection timeout
refactor重构代码refactor(utils): simplify helper functions
docs文档docs: update README
test测试test(api): add user endpoint tests
chore维护chore: update dependencies
style格式调整style: fix linting errors

批量提交工作流

当有多个不相关的更改时:

  1. 运行 --batch 查看建议的提交分组
  2. 暂存第一个提交的文件:git add <files>
  3. 使用建议的消息进行提交
  4. 对剩余分组重复上述步骤

分组策略

文件按以下方式分组:

  • 目录/模块:src/api/、tests/、docs/
  • 更改类型:新增、修改或删除
  • 语义关系:将相关文件放在一起

结合上下文的提交消息

注意:analyze_changes.py 脚本会对文件进行分组并提供基本建议。将其输出作为起点,然后阅读 git diff,了解实际更改,并参考以下示例生成结合上下文的消息。

生成提交消息时,分析实际代码更改以推断业务背景。不要只描述文件,而要说明这些更改实现了什么。

作用域指南

作用域应体现业务模块或功能,而不只是目录:

作用域类型示例使用场景
功能/模块companion、calendar、inbox更改特定产品功能时
平台ios、android、web平台特定的更改
集成outlook、gmail、slack第三方集成相关的更改
组件auth、api、db核心基础设施相关的更改
输入/输出示例

示例 1:新功能

Input (code changes):
  + src/companion/pages/AvailabilityDetailPage.tsx
  + src/companion/pages/AvailabilityActionsPage.tsx
  + src/companion/components/AvailabilityCard.tsx
  M src/companion/navigation/routes.ts

Output:
  feat(companion): add availability detail and actions pages for ios

  - New AvailabilityDetailPage showing time slot details
  - New AvailabilityActionsPage for booking/canceling
  - AvailabilityCard component for list display
  - Updated navigation routes

示例 2:修复错误

Input (code changes):
  M src/integrations/outlook/email_sender.py
  M src/integrations/outlook/auth.py

Output:
  fix(outlook): resolve email sending failures due to token expiration

  Refresh OAuth token before sending when close to expiry

示例 3:多平台更改

Input (code changes):
  M ios/Calendar/CalendarView.swift
  M android/calendar/CalendarFragment.kt
  M web/src/calendar/Calendar.tsx

Output:
  feat(calendar): add week view across all platforms

  Implement consistent week view UI for iOS, Android, and web

示例 4:杂项/维护

Input (code changes):
  M package.json
  M yarn.lock
  M requirements.txt

Output:
  chore(deps): update dependencies to latest versions
撰写优质描述
不佳(泛泛而谈)良好(结合上下文)
feat: add new filefeat(payments): add Stripe webhook handler
fix: fix bugfix(auth): prevent session timeout on mobile
chore: update codechore(ci): reduce build time with parallel jobs
refactor: refactor utilsrefactor(api): extract rate limiting to middleware
核心原则
  1. 阅读代码——了解更改实际实现的内容
  2. 确定功能——受到影响的是哪项面向用户的功能或系统能力?
  3. 具体明确——包含相关细节(平台、集成、组件)
  4. 使用主动语态——使用“add”“fix”“update”,而非“added”“fixed”“updated”
  5. 保持简洁——首行少于 72 个字符

评论

支持 Markdown