AgentSkillsCN

conventional-commit

以类型前缀搭配可选作用域,生成格式规范的常规提交信息

SKILL.md
--- frontmatter
name: conventional-commit
description: Create properly formatted conventional commits with type prefixes and optional scope

Conventional Commit Skill

Use this skill when creating git commits to ensure consistent, meaningful commit messages that follow the Conventional Commits specification.

Commit Message Format

code
<type>(<scope>): <subject>

<body>

<footer>

Required Elements

  • type: The category of change (see types below)
  • subject: Brief description in imperative mood ("add" not "added")

Optional Elements

  • scope: Component or area affected (e.g., auth, api, ui)
  • body: Detailed explanation if needed
  • footer: Breaking changes or issue references

Commit Types

TypeDescriptionExample
featNew featurefeat(auth): add OAuth2 login
fixBug fixfix(api): handle null response
docsDocumentation onlydocs: update README installation
styleFormatting, no code changestyle: fix indentation in utils
refactorCode change, no new feature/fixrefactor(db): simplify query builder
perfPerformance improvementperf: cache expensive calculation
testAdding/fixing teststest(auth): add login unit tests
buildBuild system or dependenciesbuild: upgrade typescript to 5.0
ciCI configurationci: add GitHub Actions workflow
choreMaintenance taskschore: update .gitignore
revertRevert previous commitrevert: revert feat(auth) commit

Rules

  1. Subject line: Max 70 characters, no period at end
  2. Imperative mood: "add feature" not "added feature" or "adds feature"
  3. Lowercase: Type and scope are lowercase
  4. Breaking changes: Add ! after type/scope and explain in footer
    code
    feat(api)!: change authentication flow
    
    BREAKING CHANGE: API now requires Bearer token instead of API key
    

Workflow

  1. Stage your changes: git add <files>
  2. Review what's staged: git diff --cached
  3. Determine the appropriate type based on the change
  4. Write commit message following the format
  5. Create the commit

Examples

Simple feature:

code
feat: add dark mode toggle

Bug fix with scope:

code
fix(auth): prevent session timeout on active users

Breaking change:

code
feat(api)!: migrate to v2 endpoints

BREAKING CHANGE: All v1 endpoints are now deprecated.
Migrate to /api/v2/* endpoints before next major release.

Closes #123

Multiple changes (prefer separate commits): If you have unrelated changes, create separate commits for each logical unit of work.

Todo List Integration

When working through implementation todos that modify code or files:

  1. Each completed implementation todo = one conventional commit
  2. After finishing an implementation task, stage and commit the changes
  3. Mark the todo as completed only AFTER the commit succeeds

This does NOT apply to:

  • Research or exploration todos
  • Planning or design todos
  • Reading/reviewing code without changes
  • Gathering information