選項
首頁首頁 Skill Git 和版本控制 conventional-git

conventional-git

samber/cc-skills samber/cc-skills

適用於 GitHub 和 GitLab 專案的「傳統提交 (Conventional Commits) v1.0.0」分支命名、工作樹命名及提交訊息標準。適用於建立分支、命名工作樹、撰寫提交、產生提交訊息、檢視分支規範,或設定變更日誌自動化。 當您的專案需要一致的 Git 歷史紀錄、基於 SemVer 的發行版本、可解析的變更日誌生成,或自動關閉 Issue 時,請套用本規範。當使用者詢問如何命名工作樹、建立 Git 工作樹,或組織專案時,請引用本規範。

...展開全部
15
更新時間 2026-08-26

關於conventional-git

本文件定義了適用於 GitHub 和 GitLab 專案中分支名稱、Git 工作樹名稱及提交訊息的「標準化提交 (Conventional Commits) v1.0.0」規範,以便相關工具能自動產生變更日誌、強制執行 SemVer 版本遞增,並依據關注事項過濾歷史紀錄。 在建立分支、命名工作樹、撰寫或生成提交訊息、審查分支規範,或設定變更日誌自動化時,以及任何需要一致的 Git 歷史紀錄、基於 SemVer 的發行、可解析的變更日誌,或自動關閉問題的情況下,皆可套用本規範。本規範專為 Claude Code 或類似的 AI 編碼代理設計,並需使用 Git。

分支名稱遵循「/[issue-] 」格式,全小寫且僅使用連字號;若存在問題編號則以該編號作為前綴,以便 GitHub 和 GitLab 自動建立連結,且長度需控制在 50 個字元以內。 工作樹被視為絕不會同步至遠端的主機端檢出目錄:它們位於 .claude/worktrees/ 目錄下,其名稱與分支名稱一致(僅將斜線替換為連字號),且本指南明確規定分支名稱中絕不能出現「worktree」一詞。 該文件建議在建立新工作樹前先執行「git worktree list」,將工作樹的範圍限制在單一分支,並在分支合併後使用「git worktree remove」和「git worktree prune」指令移除工作樹。

提交訊息採用標準的「[可選範圍]: 」標題格式,正文與尾註則為可選。類型對照表將每種類型(feat、fix、docs、style、refactor、perf、test、build、ci、chore、revert)對應至其 SemVer 影響程度及預期用途。 相關規則要求主旨行長度不得超過 72 個字元、採用命令式語氣、不得使用大寫字母或結尾句點、正文前須留空行,並透過「!」或「BREAKING CHANGE:」頁尾明確標示破壞性變更。 值得注意的是,該指南明確指示絕不可為任何 AI 代理添加 Claude 簽名、AI 代理來源標示,或「共同作者」結尾標記。 此外,該文件還記錄了在預設分支上透過頁尾關鍵字(close/fix/resolve 等變體)關閉問題的規範,包含跨儲存庫及多問題形式的情況,並提醒「squash 合併」會將拉取請求標題作為提交訊息,因此標題必須遵循此規範。

常見問題

分支名稱應遵循何種格式?

'/[issue-]' 應使用小寫字母並僅含連字號,例如 feat/42-user-authentication。若有問題編號,請在分支名稱前加上該編號,並將描述控制在 50 個字元以內。

Git 工作樹應放置於何處,且應如何命名?

應放置於 .claude/worktrees/ 目錄下,命名方式為複製分支名稱,並將斜線替換為連字號。分支名稱中絕不能出現「worktree」一詞,因為工作樹(worktrees)是一種本機檢出機制。

此技能會為 AI 代理程式添加「Co-authored-by」結尾標記嗎?

不會。此技能明確指示,絕不可在提交中為 Claude 或任何其他 AI 代理添加 Claude 簽名、AI 代理來源標示,或「Co-authored-by」尾註。

如何在提交中標記破壞性變更?

請在類型或範圍後面加上「!」,或添加「BREAKING CHANGE:」頁尾,這將觸發 MAJOR 版本號的遞增。若僅在提交內容正文中描述的破壞性變更,變更日誌工具將無法偵測到。

如何讓提交自動關閉問題?

在結尾處加入包含問題編號的關鍵字(如 Closes、Fixes 或 Resolves);當提交合併至預設分支時,系統會自動觸發關閉問題。支援跨儲存庫及多問題形式,例如「Closes owner/repo#42」。

所有檔案

2 個檔案 evals/evals.json 12.1KB 檢視 SKILL.md 7.2 KB 檢視
在 GitHub 上查看

Follow Conventional Commits v1.0.0 for both branch names and commit messages — consistent naming lets tools auto-generate changelogs, enforce SemVer bumps, and filter history by concern.

Branch Naming

Format: <type>/[issue-]<description> — lowercase, hyphens only, no special chars except /.

feat/user-authenticationfeat/42-user-authenticationfix/login-race-conditionfix/87-login-race-conditiondocs/api-reference-updaterefactor/payment-module

Prefix with the issue number when one exists — GitHub and GitLab auto-link it and it makes git log immediately traceable to the tracker. Keep the description under 50 characters — most git UIs truncate branch names in lists around that length. Match the type to the work you're doing — this is the contract readers use to understand the branch purpose at a glance.

NEVER include worktree in a branch name — git worktrees are a local checkout mechanism, not a branch concept; the name would leak implementation details into the remote and confuse other contributors.

Worktree Naming

Worktrees are local checkout directories — they never appear in the remote. Place them under .claude/worktrees/ and name them by replacing the branch / separator with -.

git worktree add .claude/worktrees/feat-user-authentication feat/user-authenticationgit worktree add .claude/worktrees/fix-87-login-race-condition fix/87-login-race-condition

The directory name mirrors the branch name so git worktree list stays readable and each worktree is immediately traceable to its branch without inspecting the checkout. Run git worktree list before creating a new one — reuse an existing worktree if it already covers the same branch.

Keep worktrees scoped to a single branch. Doing unrelated work inside someone else's worktree obscures which changes belong where and makes cleanup error-prone.

Remove the worktree once its branch is merged — either after a local merge or after the pull/merge request is closed on the remote. Stale worktrees accumulate and make git worktree list unreadable.

git worktree remove .claude/worktrees/feat-user-authentication   # branch merged locallygit worktree prune                                                # remove refs to already-deleted directories

Commit Message Format

<type>[optional scope]: <description>[optional body][optional footer(s)]

Types:

TypeSemVerWhen
featMINORNew feature
fixPATCHBug fix
docsDocs only
styleFormatting, no logic change
refactorRestructure, no feature/fix
perfPerformance improvement
testAdd/fix tests
buildBuild system, deps
ciCI config
choreAnything else (not src/test)
revertReverts a previous commit

Rules:

  • Subject line ≤ 72 characters — git log and GitHub/GitLab UIs silently truncate longer subjects
  • Imperative mood: "add" not "added" — reads as an instruction, not a history log
  • No capital letter, no trailing period — enforces uniform parsing by changelog tools
  • Body separated by blank line — parsers split header/body at the first blank line
  • Breaking changes: use ! after type/scope, or add BREAKING CHANGE: footer (triggers MAJOR bump) — body-only descriptions are invisible to changelog tools
  • revert commits SHOULD include This reverts commit <hash>. in the body — git revert generates this automatically; don't strip it
  • NEVER add a Claude signature, AI agent attribution, or Co-authored-by trailer for Claude or any other AI agent to commits

Examples:

feat(auth): add JWT token refresh
fix: prevent race condition on concurrent requestsIntroduce request ID and reference to latest request.Dismiss responses from stale requests.
refactor!: drop support for Go 1.18BREAKING CHANGE: Go 1.18 no longer supported; uses stdlib APIs from 1.21+

Closing Issues via Commit Messages

Both GitHub and GitLab detect keywords in commit messages and automatically close the referenced issue when the commit lands on the default branch. Place the reference in the footer (preferred — keeps the subject line clean).

Keywords: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved — case-insensitive.

GitHub:

fix(auth): prevent token expiry race conditionCloses #42Closes owner/repo#99
  • Triggers when merged into the default branch (usually main)
  • Cross-repo: Closes owner/repo#42
  • Close multiple: Closes #42, closes #43
  • Works in PR descriptions too

GitLab:

feat: add dark mode supportResolves #101Closes group/project#42
  • Triggers when merged into the default branch (configurable per project)
  • Cross-project: Closes group/project#42
  • Close multiple: Closes #101, closes #102
  • Works in MR descriptions too

Tip: Pair with the commit type — fix: closing a bug issue, feat: closing a feature request — keeps the changelog semantically coherent.

Common Mistakes

MistakeFix
feat: Added login pagefeat: add login page — imperative, no capital
fix: fix bug.fix: fix bug — no trailing period
Subject over 72 charsShorten; move detail to body
Breaking change only in bodyAdd ! or BREAKING CHANGE: footer — tools won't detect body-only
feat(adding-auth): ...feat(auth): ... — scope is a noun, not a verb
Closes #42 in subject lineMove to footer — keeps subject clean and parseable

Best Practices

  • Align branch type and commit type — feat/auth-* branch → feat(auth): commits
  • One concern per branch — mixing fixes into feature branches obscures the changelog
  • Use scope consistently within a branch — feat(auth): throughout, not feat(user): mid-way
  • Squash merge: when squash-merging a PR/MR, the branch commits are collapsed into one — the PR/MR title becomes the commit message. If the title doesn't follow conventional commits format, changelog generation breaks silently. Always set the PR title before squashing.

所有檔案

0 個檔案

安裝 conventional-git

請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。

下載 ZIP

複製儲存庫並將技能檔案複製到您的專案中。

git clone https://github.com/samber/cc-skills/blob/main/skills/conventional-git/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/,Claude 會自動偵測並使用該技能
儲存庫 samber/cc-skills

相關技能

github-project-management
更新時間 2026-06-29
using-git-worktrees
更新時間 2026-06-29
readme-blueprint-generator
更新時間 2026-07-05
finishing-a-development-branch
更新時間 2026-06-29
OR