Git Commit Skill
This skill guides the creation of Git commit messages that follow the Conventional Commits format.
When to Use
Use this skill when:
- •Code changes are completed and ready to be committed
- •Need to create a commit message that adheres to project conventions
Commit Message Format
The commit message must follow this format:
code
<type>[optional scope]: <description> [optional body] [optional footer(s)]
Workflow overview
- •Check the staged files using
git diff --staged --name-only. Ask user to stage changes if there are no staged files. - •Determine the appropriate commit type and scope based on the staged files.
type must be selected from the following options:
- •
feat: New feature or change to existing functionality - •
fix: Bug fix - •
docs: Documentation-only changes (e.g., changes to*.mdfiles) - •
refactor: Refactoring (code changes that neither fix a bug nor add a feature) - •
perf: Performance improvements - •
test: Adding or modifying tests (e.g., changes to*.spec.*or*.spec.*.snapfiles) - •
build: Changes affecting the build system or external dependencies - •
ci: Changes to CI configuration files (e.g., changes within.github/actionsor.github/workflows) - •
chore: Other changes (e.g., changes to*.json,*.config.mjs,*.config.cjs,*.config.js,*.config.ts,.gitignore,.gitattributes,.prettierignore,.prettier) - •
revert: Reverting a previous commit
scope should be determined based on the directory structure of the staged files. For example:
- •If staged files are in
.claude/or.mcp.json, useclaude - •If staged files are in
.github/, usegithub - •If staged files are in
.vscode/, usevscode - •If staged files are in
apps/frontend/, usefrontend - •If staged files are in the root directory, do not set a scope
- •Craft a concise and descriptive commit message in English that adheres to the Conventional Commits format.
Example:
bash
git commit -m "$(cat <<'EOF' feat(utils): update xxx function - Add xxx logic in xxx function - Implement unit tests for xxx function Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com> EOF )"
Never use \n in the commit message. Use actual new lines.
Notes
- •Commit messages must be written in English. Important
- •If there are staged changes, determine the commit message based only on the staged changes.
- •The commit message must clearly indicate that it was created with Copilot.