AgentSkillsCN

conventional-commit

通过分析仓库的 Git 日志,学习其提交规范、偏好使用的提交类型、作用域使用模式以及语言风格,从而生成具备上下文感知的常规提交信息。在创建 Git 提交、撰写提交信息,或当用户请求提交更改时,可使用此技能。系统会自动适配项目现有的提交风格与语言偏好。

SKILL.md
--- frontmatter
name: conventional-commit
description: Generate context-aware conventional commit messages by analyzing the repository's git log to learn its conventions, preferred commit types, scope usage patterns, and language. Use when creating git commits, writing commit messages, or when the user asks to commit changes. Automatically adapts to the project's existing commit style and language preferences.

Smart Commit

Generate conventional commit messages that adapt to the repository's existing patterns.

Workflow

1. Analyze Repository Patterns

Run the analysis script to detect the repository's commit conventions:

bash
python3 <skill-path>/scripts/analyze_git_log.py

Key outputs to note:

  • Language: Determines whether to write descriptions in English or Chinese
  • Type distribution: Which commit types the project prefers
  • Scope usage: Whether scopes are used and common scope names

2. Review Staged Changes

bash
git status
git diff --staged

3. Generate Commit Message

Apply these rules in order:

  1. Match language — Use the detected primary language for the description
  2. Match type conventions — Prefer types already used in the repository
  3. Match scope patterns — Include scope only if the repository commonly uses them; reuse existing scope names when applicable
  4. Choose correct type — Select based on the nature of the change (see references/conventional_commits.md for the full spec)
  5. Be concise — Description focuses on "why", body (if needed) explains "what"

4. Execute Commit

Format using HEREDOC to preserve formatting:

bash
git commit -m "$(cat <<'EOF'
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
EOF
)"

Resources