选项
首页首页 Skill Git 和版本控制 conventional-git

conventional-git

samber/cc-skills samber/cc-skills

适用于 GitHub 和 GitLab 项目的传统提交 v1.0.0 分支命名、工作树命名及提交信息标准。在创建分支、命名工作树、编写提交、生成提交信息、审查分支规范或设置变更日志自动化时请使用本规范。 当您的项目需要保持一致的 Git 历史、遵循 SemVer 规范的发布、可解析的变更日志生成或自动关闭问题时,请应用本规范。当用户询问如何命名工作树、创建 Git 工作树或组织

...展开全部
15
更新时间 2026-08-26

关于conventional-git

定义了适用于 GitHub 和 GitLab 项目的“常规提交(Conventional Commits)v1.0.0”标准,涵盖分支名称、Git 工作树名称以及提交信息,以便相关工具能够自动生成变更日志、强制执行 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 代理署名或“Co-authored-by”尾注。 该指南还详细说明了如何通过默认分支上的页脚关键词(close/fix/resolve 的变体)来关闭问题,包括跨仓库和多问题形式,并提醒用户:合并操作会将 PR 标题作为提交信息,因此标题必须遵循约定。

常见问题

分支名称应遵循什么格式?

/[issue-] ”,全部小写且仅使用连字符,例如 feat/42-user-authentication。如有问题编号,请将其作为前缀,且描述长度应控制在 50 个字符以内。

Git 工作树应放置在何处,又该如何命名?

应放置在 .claude/worktrees/ 目录下,命名方式为与分支名称对应,但将斜杠替换为连字符。分支名称中绝不能出现“worktree”一词,因为工作树是一种本地检出机制。

该技能会为 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 会自动检测并使用该技能

相关技能

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