generating-smart-commits

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git Commit Smart

Git Commit Smart

This skill provides automated assistance for git commit smart tasks.
本技能为Git智能提交任务提供自动化辅助。

Prerequisites

前提条件

Before using this skill, ensure:
  • Git repository is initialized in {baseDir}
  • Changes are staged using
    git add
  • User has permission to create commits
  • Git user name and email are configured
使用本技能前,请确保:
  • {baseDir}目录下已初始化Git仓库
  • 已通过
    git add
    命令暂存变更
  • 用户拥有创建提交的权限
  • 已配置Git用户名和邮箱

Instructions

操作步骤

  1. Analyze Staged Changes: Examine git diff output to understand modifications
  2. Determine Commit Type: Classify changes as feat, fix, docs, style, refactor, test, or chore
  3. Identify Scope: Extract affected module or component from file paths
  4. Detect Breaking Changes: Look for API changes, removed features, or incompatible modifications
  5. Format Message: Construct message following pattern:
    type(scope): description
  6. Present for Review: Show generated message and ask for confirmation before committing
  1. 分析已暂存变更:查看git diff输出以了解修改内容
  2. 确定提交类型:将变更分类为feat、fix、docs、style、refactor、test或chore
  3. 识别作用范围:从文件路径中提取受影响的模块或组件
  4. 检测破坏性变更:查找API变更、已移除功能或不兼容的修改
  5. 格式化提交信息:按照
    type(scope): description
    的格式构建提交信息
  6. 提交前确认:展示生成的提交信息,在提交前请求用户确认

Output

输出格式

Generates conventional commit messages in this format:
type(scope): brief description

- Detailed explanation of changes
- Why the change was necessary
- Impact on existing functionality

BREAKING CHANGE: description if applicable
Examples:
  • feat(auth): implement JWT authentication middleware
  • fix(api): resolve null pointer exception in user endpoint
  • docs(readme): update installation instructions
生成符合规范的提交信息,格式如下:
type(scope): 简要描述

- 变更的详细说明
- 变更的必要性
- 对现有功能的影响

BREAKING CHANGE: 若有则填写相关描述
示例:
  • feat(auth): implement JWT authentication middleware
  • fix(api): resolve null pointer exception in user endpoint
  • docs(readme): update installation instructions

Error Handling

错误处理

Common issues and solutions:
No Staged Changes
  • Error: "No changes staged for commit"
  • Solution: Stage files using
    git add <files>
    before generating commit message
Git Not Initialized
  • Error: "Not a git repository"
  • Solution: Initialize git with
    git init
    or navigate to repository root
Uncommitted Changes
  • Warning: "Unstaged changes detected"
  • Solution: Stage relevant changes or use
    git stash
    for unrelated modifications
Invalid Commit Format
  • Error: "Generated message doesn't follow conventional format"
  • Solution: Review and manually adjust type, scope, or description
常见问题及解决方案:
无已暂存变更
  • 错误提示:"No changes staged for commit"
  • 解决方案:在生成提交信息前,使用
    git add <files>
    命令暂存文件
Git未初始化
  • 错误提示:"Not a git repository"
  • 解决方案:使用
    git init
    初始化Git,或导航至仓库根目录
存在未暂存变更
  • 警告提示:"Unstaged changes detected"
  • 解决方案:暂存相关变更,或使用
    git stash
    暂存无关修改
提交格式无效
  • 错误提示:"Generated message doesn't follow conventional format"
  • 解决方案:检查并手动调整提交类型、作用范围或描述内容

Resources

参考资源

  • Conventional Commits specification: https://www.conventionalcommits.org/
  • Git commit best practices documentation
  • Repository commit history for style consistency
  • Project-specific commit guidelines in {baseDir}/000-docs/007-DR-GUID-contributing.md
  • Conventional Commits 规范:https://www.conventionalcommits.org/
  • Git提交最佳实践文档
  • 仓库提交历史(用于保持风格一致性)
  • 项目特定提交指南:{baseDir}/000-docs/007-DR-GUID-contributing.md

Overview

概述

This skill provides automated assistance for the described functionality.
本技能为上述功能提供自动化辅助。

Examples

示例

Example usage patterns will be demonstrated in context.
将结合上下文展示示例使用模式。