SuperAPI AI Directory

cc-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 commit descriptions, or mentions commit-msg.

Do not use for:

  • Automatically executing git add or git commit
  • replacing 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 including 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, first remind the user to split it.
  3. Classify according to the intent of the changes as feat、fix、refactor、style、docs、test or chore。
  4. First provide one ready-to-use subject, 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
  • Output language:type keep keywords in English (feat/fix/refactor/style/docs/test/chore),subject and body must use Simplified Chinese
  • body use flat bullets, explaining the core changes
  • Do not add emoji, AI statements, or Co-Authored-By
  • Do not execute the commit command on behalf of 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 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 $, 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 whole thing 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 correctly.
  • ❌ Concatenating multiple bullets into the subject with spaces — the subject should remain a single topic, with a maximum length of no more 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 line's independent - bullet。

Expand as needed

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