AgentSkillsCN

git-commit-workflow

遵循仓库规范提交 Git 更改的技能。适用于需要依据 CONTRIBUTING 文件中的标准提交已暂存或未暂存的更改、通过 git status 和 git diff 分析更改内容、将相关文件归类分组,并按照规范或传统提交方式执行提交操作时使用。

SKILL.md
--- frontmatter
name: git-commit-workflow
description: Skill for committing git changes following repository guidelines. Use when needing to commit staged or unstaged changes by reading CONTRIBUTING files for standards, analyzing changes with git status and diff, grouping related files, and performing commits according to guidelines or conventional commits as fallback.

Git Commit Workflow

Overview

This skill provides a structured workflow for committing git changes that respects repository-specific guidelines and falls back to conventional commits when no guidelines exist. It ensures commits are logical, well-grouped, and follow established standards.

Workflow

Follow these steps to commit changes:

1. Read Repository Guidelines

  • Look for CONTRIBUTING, CONTRIBUTING.md, or similar files in the repository root
  • Extract commit message standards, guidelines, and any specific requirements
  • If no guidelines found, prepare to use conventional commits as fallback

2. Assess Current Changes

  • Run git status to see all modified, added, and untracked files
  • Note staged vs unstaged changes

3. Analyze Changes in Detail

  • Run git diff (and git diff --staged if needed) to understand what changes were made
  • Review the nature of changes: bug fixes, features, refactoring, documentation, etc.

4. Group Related Changes

  • Logically group files by related changes
  • See references/grouping_changes.md for guidance on grouping strategies
  • Avoid mixing unrelated changes in the same commit

5. Perform Commits

  • If CONTRIBUTING guidelines exist, follow their commit message format and grouping requirements
  • If no guidelines, use conventional commits standard: See references/conventional_commits.md
  • Stage appropriate files for each commit
  • Write descriptive commit messages
  • Run git commit with proper messages

Resources

references/

  • grouping_changes.md: Guidance on how to group related file changes into logical commits
  • conventional_commits.md: Reference for conventional commits specification