git-commit-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git Commit Generator

Git提交信息生成器

Description

描述

This skill analyzes code changes (git diffs) and generates semantic, structured commit messages. It ensures that commit messages are concise, descriptive, and follow the Conventional Commits standard (e.g.,
feat:
,
fix:
,
docs:
).
该技能会分析代码变更(git diff)并生成语义化、结构化的提交信息。确保提交信息简洁、描述性强,且遵循Conventional Commits标准(例如:
feat:
fix:
docs:
)。

Usage Scenario

使用场景

Trigger this skill when:
  • The user asks to "write a commit message" or "generate a commit".
  • The user asks "what did I change?" and expects a summary suitable for a commit.
  • You need to propose a commit message for a set of changes you just made.
在以下场景触发该技能:
  • 用户要求「编写提交信息」或「生成提交信息」时
  • 用户询问「我改了什么?」并需要一份适合作为提交信息的总结时
  • 你需要为刚完成的一系列变更提交建议的提交信息时

Instructions

操作说明

  1. Analyze the Changes:
    • Read the provided
      git diff
      or the changes in the current context.
    • Identify the scope of changes (e.g., specific component, file, or module).
    • Determine the type of change: Refer to
      resources/conventional-commits-types.md
      for the strict definition of types (feat, fix, docs, etc.).
  2. Formulate the Commit Message:
    • Follow the structure defined in
      templates/commit-message.txt
      .
    • Subject Line:
      • Format:
        <type>(<scope>): <subject>
      • Use imperative mood ("add" not "added", "change" not "changes").
      • No period at the end.
      • Keep it under 50 characters if possible.
    • Body (Optional but recommended for non-trivial changes):
      • Separate from subject with a blank line.
      • Explain what and why vs. how.
      • Use bullet points for multiple changes.
  3. Output Format:
    • Provide the commit message in a code block.
    • If there are multiple logical changes, suggest splitting them into multiple commits or provide alternative messages.
  1. 分析变更:
    • 阅读提供的
      git diff
      或当前上下文里的变更内容
    • 确定变更范围(例如:特定组件、文件或模块)
    • 确定变更类型:参考
      resources/conventional-commits-types.md
      中对类型(feat、fix、docs等)的严格定义
  2. 撰写提交信息:
    • 遵循
      templates/commit-message.txt
      中定义的结构
    • 主题行:
      • 格式:
        <type>(<scope>): <subject>
      • 使用祈使语气(用「add」而非「added」,「change」而非「changes」)
      • 结尾不加句号
      • 尽可能控制在50字符以内
    • 正文(可选,但建议用于非微小变更):
      • 与主题行之间空一行
      • 解释「做了什么」和「为什么做」,而非「怎么做」
      • 多项变更使用项目符号列出
  3. 输出格式:
    • 在代码块中提供提交信息
    • 如果存在多个逻辑独立的变更,建议拆分为多个提交或提供备选信息

Examples

示例

Example 1: Simple Documentation Update

示例1:简单文档更新

Input: User: "Write a commit message for these changes." Diff:
diff
diff --git a/README.md b/README.md
index 431f2eb..e727fe1 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,6 @@
 ## Quickstart
 
-1. Clone the repo.
+1. Clone this repository.
Output:
text
docs: update quickstart instructions in README

Refine the cloning step for better clarity.
输入: 用户:「为这些变更编写提交信息。」 Diff:
diff
diff --git a/README.md b/README.md
index 431f2eb..e727fe1 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,6 @@
 ## Quickstart
 
-1. Clone the repo.
+1. Clone this repository.
输出:
text
docs: update quickstart instructions in README

Refine the cloning step for better clarity.

Example 2: Feature with multiple files

示例2:多文件功能变更

Input: User: "Commit these changes for the login button." Diff shows changes in
src/components/Button.tsx
(added
isLoading
prop) and
src/views/Login.tsx
(passed
loading
state).
Output:
text
feat(auth): add loading state to login button

- Add `isLoading` prop to Button component to support visual feedback
- Connect login form submission state to Button in Login view
- Prevent double submission while request is in progress
输入: 用户:「为登录按钮的这些变更生成提交信息。」 Diff显示
src/components/Button.tsx
(新增
isLoading
属性)和
src/views/Login.tsx
(传递
loading
状态)有变更。
输出:
text
feat(auth): add loading state to login button

- Add `isLoading` prop to Button component to support visual feedback
- Connect login form submission state to Button in Login view
- Prevent double submission while request is in progress