mcpField
E
engram-commit-hygiene

engram-commit-hygiene

github.com/gentleman-programming开发7.7k80 次安装今天更新
代码仓库

关于 engram-commit-hygiene

为提交、分支命名和暂存区整理提供 Git 操作规范的开发技能,适合需要遵守仓库提交规则的开发者。重点涵盖 Conventional Commits、分支格式与提交前检查。

主要功能

  1. 01规范 Conventional Commits 提交信息
  2. 02规定分支命名格式
  3. 03强调每次提交聚焦单一改动
  4. 04提供提交前检查清单

适用场景

  1. 01创建符合规则的提交
  2. 02为新分支选择合规名称
  3. 03整理暂存改动并核查提交范围
  4. 04检查 PR 历史中的提交规范

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/gentleman-programming/engram --skill engram-commit-hygiene

安装后在 Claude Code 中输入/engram-commit-hygiene确认已加载。

详细介绍

使用场景

在以下情况下使用此技能:

  • 创建提交
  • 创建或命名分支
  • 在 PR 中查看提交历史
  • 清理暂存的更改

关键规则

  1. 提交消息必须遵循 Conventional Commits——由 GitHub 规则集强制执行;格式无效时,推送会被拒绝
  2. 分支名称必须遵循 type/description 格式——由 GitHub 规则集强制执行;格式无效时,推送会被拒绝
  3. 每个提交只包含一个逻辑更改
  4. 消息应说明原因,而不只是说明做了什么
  5. 绝不要包含 Co-Authored-By 脚注
  6. 绝不要提交 Transient Artifact Policy 禁止的路径

提交消息格式(由 GitHub 规则集强制执行)

正则表达式: ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z0-9\._-]+\))?!?: .+

<type>(<optional-scope>): <description>
<type>(<optional-scope>)!: <description>   ← breaking change
允许的类型
类型用途
feat新功能
fix修复错误
docs仅修改文档
refactor重构代码(不改变行为)
chore维护、依赖项
style格式、空白字符
perf性能改进
test添加或修复测试
build构建系统更改
ciCI/CD 流水线更改
revert撤销先前的提交
规则
  • 类型必须为小写,且是所列值之一
  • 范围可选,必须为小写,可使用 a-z、0-9、.、_、-
  • : 前的 ! 表示破坏性更改
  • 描述必须以 : (冒号 + 空格)开头
  • 描述应使用祈使语气(使用“add”,而不是“added”或“adds”)
有效示例
feat(cli): add --json flag to session list command
fix(store): prevent duplicate observation insert on retry
docs(contributing): update workflow documentation
refactor(internal): extract search query sanitizer
chore(deps): bump github.com/charmbracelet/bubbletea to v0.26
style(tui): fix alignment in session detail view
perf(store): optimize FTS5 query for large datasets
test(sync): add coverage for conflict resolution
ci(workflows): split e2e into separate job
fix!: change session ID format
无效示例(推送会被拒绝)
Fix bug                          ← no type prefix
feat: Add login                  ← description should be lowercase
FEAT(cli): add flag              ← type must be lowercase
feat (cli): add flag             ← no space before scope
feat(CLI): add flag              ← scope must be lowercase
update docs                      ← no conventional commit format

分支命名格式(由 GitHub 规则集强制执行)

正则表达式: ^(feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)\/[a-z0-9._-]+$

<type>/<description>
允许的类型

feat、fix、chore、docs、style、refactor、perf、test、build、ci、revert

规则
  • 类型必须是所列值之一
  • 描述必须为小写
  • 描述中只能使用 a-z、0-9、.、_、-
  • 不得使用大写字母、空格或特殊字符
有效示例
feat/json-export-command
fix/duplicate-observation-insert
docs/api-reference-update
refactor/extract-query-sanitizer
chore/bump-bubbletea-v0.26
ci/split-e2e-job
无效示例(推送会被拒绝)
feature/add-login                ← "feature" not allowed, use "feat"
fix/Add-Login                    ← uppercase not allowed
my-branch                        ← no type prefix
fix_something                    ← missing "/" separator

提交前检查清单

  • 提交消息符合 conventional commits 格式
  • 分支名称符合 type/description 格式
  • 差异内容与提交范围一致(不包含无关更改)
  • 不包含机密信息、凭据或 .env 文件
  • 每个更改路径都符合 Transient Artifact Policy
  • 不包含 Co-Authored-By 脚注
  • 与更改相关的测试均已通过

评论

支持 Markdown