SuperAPI AI Directory

commit-convention

Coding & development

View repository

Updated 10-15 08:13

About this skill

Commit Convention

This Skill does not directly perform git commit or git add operations, but instead provides the current Agent with commit messagedecision guidanceandformat standards。

Core Strategy

1. Style Learning (Priority)

Before generating a commit message, you must first observe the project's existing commit habits:

  • Run git log -n 5 --oneline。
  • Match history: If the project habitually uses specific prefixes (such as [FEAT]、Update: , etc.) or language habits, prioritize imitating them and staying consistent.
  • Language consistency: If the history is entirely in Chinese, use Chinese descriptions; if it is entirely in English, use English.

2. Specification Fallback

If the project's commit records are empty, show no clear pattern, or the project explicitly requires standardized commits, follow the Conventional Commits specification:

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

<body>

Type Definitions

  • feat: new feature
  • fix: bug fix
  • docs: documentation changes
  • style: changes that do not affect the meaning of the code (whitespace, formatting, missing semicolons, etc.)
  • refactor: refactoring (code changes that neither fix a bug nor add a feature)
  • perf: performance improvement
  • test: adding missing tests or correcting existing tests
  • build: changes that affect the build system or external dependencies
  • ci: changes to CI configuration files and scripts
  • chore: other changes that do not modify src or test files
  • revert: revert a previous commit

Subject Format

  • Use the imperative mood (e.g. "add" instead of "added").
  • Do not end with a period.
  • Lowercase the first letter (unless it is a proper noun).
  • Keep the length within 50 characters.

Operational Instructions (For Agent Reference Only)

When the Agent needs to generate a commit message, it should think according to the following logic:

  1. Observe: Use git log -n 5 --oneline to observe the project style.
  2. Judge:
    • An established pattern is found? → Imitate that pattern.
    • A Conventional Commits pattern is found? → Follow this specification.
    • Initial commit/no pattern? → Adopt Conventional Commits.
  3. Write:
    • A concise Subject.
    • Provide a Body when necessary (explain Why rather than How).
    • Reference the Issue (e.g. Closes #123)。

Precautions

  • Strictly prohibit over-engineering: Do not generate overly complex commit messages unless the changes are genuinely complex.
  • Atomicity: It is recommended that one commit does only one thing. If too many changes are found, it is recommended to prompt the user to split the commit.
  • Do not execute commands: This Skill only provides "message suggestions"; execution operations are decided by the main Agent.