SuperAPI AI Directory

commit-msg

Coding & development

View repository

Updated 10-15 21:11

About this skill

Commit Msg

Use this skill when the user explicitly asks to generate a commit message, organize a commit description, or mentions commit-msg.

Do not use for:

  • Automatically execute git add or git commit
  • Replacing a formal code review
  • Generating release notes or changelog

Core approach

  1. By default, look at staged changes first; when the user explicitly says all, all changes, or includes unstaged changes, then look at the entire workspace diff.
  2. First determine whether this batch of changes is suitable for one commit; if it is too mixed, remind the user to split it first.
  3. Classify it based on the intent of the changes as feat、fix、refactor、style、docs、test or chore。
  4. First provide a subject that can be used directly, then provide 2-5 body bullet points.
  5. Also list the main changed files to help the user judge whether the message is too broad.

Output requirements

  • Use Conventional Commit style:<type>: <subject>
  • subject Concise and focused, do not pile up file names
  • body Use Chinese flat bullets to describe the core changes
  • Do not add emoji, AI declarations, or Co-Authored-By
  • Do not execute the commit command for the user

Write-to-disk command (mandatory heredoc)

After outputting the message, you must additionally provide a directly copyable and executable heredoc command, so that git correctly preserves the structure of a single-line subject + blank line + multi-line body bullets:

git add <文件列表> && git commit -m "$(cat <<'EOF'
<type>: <subject>

- 变更点1
- 变更点2
- 变更点3
EOF
)"

<<'EOF' Use single-quote fencing to avoid $and backticks being expanded by the shell.

Forbidden counterexamples

  • ❌ git commit -m "feat: x\n- a\n- b" —— \n is a literal string, the shell will not parse it as a newline, and the entire paragraph will be stuffed into the subject line.
  • ❌ git commit -m "feat: x - a - b" —— the body is compressed into a single line, losing the markdown list structure, and GitHub Release / git log cannot render it correctly.
  • ❌ Joining multiple bullets into the subject with spaces —— the subject should maintain a single topic and be no longer than 80 characters.

Self-verification

After writing to disk, use git log -1 --pretty=format:'%s%n---%n%b' to check: the subject must be a single line, and the body must preserve each independent line of - bullet。

Expand as needed

  • Type selection:references/commit-types.md
  • Format constraints:references/message-format.md