Communitygithub.com

约定式提交与发布

用于提交、编写提交信息、打开将被压合并的PR,或配置自动版本控制/变更日志。关键词——约定式提交、release-please、语义化版本、feat/fix/chore、破坏性变更、变更日志。

约定式提交与发布 是什么?

该技能将约定式提交规范(Conventional Commits)和语义化版本控制(SemVer)严格整合到日常开发工作流中。它要求每条提交信息必须使用`<type>(<scope>): <description>`的格式,其中`feat`和`fix`类型直接驱动SemVer的次版本号(minor)和修订号(patch)自动递增,而`chore`、`docs`等类型则不会触发版本变动。核心规则包括:必须使用祈使语气、破坏性变更通过`!`或`BREAKING CHANGE:`脚注触发主版本号(major)递增、PR标题在压合(squash-merge)后成为最终提交信息因此必须合格。技能还禁止任何AI署名字段(如`Co-authored-by`或`Generated with [Claude…]`),并在CI中通过`amannn/action-semantic-pull-request`和专用的“No AI Attribution”任务进行强制执行。该技能主要适用于使用GitHub、依赖release-please等自动发布工具的团队,能够确保每次发布都能生成准确的变更日志和正确的版本号。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lguidolin/agent-skills/tree/main/skills/conventional-commits-and-releases

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

约定式提交与发布 是做什么的?

概述

提交消息是一种机器可读的接口,而非仅仅是一段文字。自动版本管理和变更日志生成都会解析它们;格式错误的消息会导致错误的公开发布版本或失败的发布。在小处遵循规范(一条格式正确的消息)将自动带来大处的正确性(准确的变更日志、正确的版本递增)。

格式

<类型>(<范围>): <描述>

类型作用 / 用途
feat新功能 — 次版本号(minor) 递增
fix错误修复 — 修订号(patch) 递增
docs仅文档变更
chore维护、依赖、配置
refactor保持行为的代码变更
test仅测试
ci / build流水线 / 构建系统变更
  • 祈使语气: “add X”,而不是“added X”或“adds X”。
  • 破坏性变更: feat!: 或 BREAKING CHANGE: 脚注 — 触发主版本号(major) 递增。
  • 范围(Scope) 可选,但鼓励使用:feat(auth):、fix(db):。

关键细节

  • 类型与版本的关联意味着错误地将 feat 写成 fix 会导致错误的版本发布。 请有目的地选择类型:“add” = 新功能,“update” = 对现有功能的增强,“fix” = 错误修复。
  • 压合合并: PR 标题会成为最终发布的提交。它本身必须是一个有效的约定式提交,否则发布将出错。
  • 人类作者语气。 不允许 AI/助手署名、Co-authored-by 尾注或“由...生成”的脚注。提交应表现为由人类编写。

常见辩解

借口现实
“这条消息其实无关紧要”它驱动变更日志和版本号。它在机械层面上至关重要。
“对于这个功能,用 chore 也差不多”chore 不会触发版本递增;用户将无法在你的发布中获得该功能。使用正确的类型。
“我稍后会修复 PR 标题”在压合合并中,标题在合并时就是最终的。请在合并前修复它。
“Co-authored-by 尾注没什么害处”项目规则禁止 AI 署名,没有例外。

红色警报 — 立即停止

  • 没有类型前缀的提交消息
  • 对增加或修复用户可见行为的内容使用了 chore/docs
  • 压合的 PR 标题不是有效的约定式提交
  • 任何 AI 署名或 Co-authored-by 行

强制执行:

  • PR 标题 — 在 CI 中验证,阻塞型(使用 amannn/action-semantic-pull-request)。 在压合合并时,标题就是最终发布的提交,因此这是最重要的关卡。
  • AI 署名 — 一个阻塞型的“无 AI 署名”任务会拒绝包含 Claude/Anthropic 的 Co-authored-by 尾注以及“Generated with [Claude…]”脚注,无论是分支提交还是 PR 主体(PR 主体会成为压合提交的主体)。人类作者的 Co-authored-by 尾注不受影响。
  • 分支提交体 — 有意不进行 lint 检查。压合合并会丢弃这些提交体,因此它们永远不会进入变更日志。如果你改用合并提交,请添加 commitlint。

已知缺口: 如果某个提交的作者是代理账户,GitHub 在压合时会自动生成一个 Co-authored-by 尾注——这是在 PR 检查运行之后。上述关卡无法捕获它。不要以代理身份提交。

完整理由:请参阅章程第三条,附于 engineering-constitution/references/engineering-constitution.md。

Individual skills in this repo

This repo contains 18 individual skills — each has its own dedicated page.

lguidolin/change-hygiene-and-code-craft

Use when writing or refactoring code, structuring a commit or PR, or deciding whether to abstract duplication. Symptoms — mixing reorg with logic changes, a PR doing several things at once, a file growing large, the second copy of similar code, or unsure whether to DRY something up.

lguidolin/cloud-delivery-aks

Use when deploying to Kubernetes or Azure Kubernetes Service (AKS), configuring cloud secrets, setting up progressive rollout/canary, per-PR ephemeral environments, or k8s health probes. Keywords — Kubernetes, AKS, Key Vault, Argo Rollouts, Flagger, canary, blue-green, liveness, readiness, PodDisruptionBudget, HPA, rollback, GHCR.

lguidolin/commit-history-rewrite

Use when an existing repository has messy commit history that needs to conform to conventional commits before adopting release-please, or when intermediate WIP/fixup/merge commits need to be cleaned up.

lguidolin/defense-in-depth-security

Use when handling untrusted input, secrets, authentication/authorization, or dependencies — or threat-modeling a new surface. Keywords — STRIDE, threat model, least privilege, secrets management, supply chain, dependency scanning, input validation, audit log, defense in depth.

lguidolin/designing-before-building

Use when starting a feature, fixing a non-trivial bug, or about to write implementation code — before any code exists. Symptoms you need this: "this is simple, I'll just code it", reaching for the editor before a design is approved, or an idea that hasn't been turned into a spec and plan.

lguidolin/engineering-constitution

Use when starting work in a project that follows the engineering constitution, orienting to its rules, or deciding which engineering practice applies to a task — spec writing, commits, testing, security, deploys, database, or UI work.

lguidolin/graphql-contract-testing

Use when writing a GraphQL query/mutation that the UI and a test will share, or building route/schema contract or smoke tests. Symptoms — copying a query into a test, a test asserting on query text, schema change that didn't break the UI build, or RLS/permission drift. Keywords — graphql-codegen, typed document, contract test, route smoke test.

lguidolin/init-repo-CI

Use when setting up a new repository with conventional commits, release-please, and CI automation, or when retrofitting an existing repository that lacks automated versioning and PR validation workflows.

lguidolin/interface-craft-and-accessibility

Use when building or styling UI — components, layouts, forms, design tokens — or making accessibility decisions. Keywords — a11y, WCAG, keyboard navigation, focus state, contrast, design system, minimalist UI, component reuse, ARIA, semantic HTML.

lguidolin/merge-gates-and-automation

Use when setting up or changing CI, pre-push hooks, or a task runner, or deciding what must pass before merge. Symptoms — tempted to put authoritative checks only in a local hook, skip CI, bypass with --no-verify, or unsure what gates a merge vs. runs locally.

lguidolin/observability-and-slos

Use when adding logging, metrics, tracing, health checks, SLOs, or alerting — or when building a service surface that needs to be operable and debuggable. Keywords — structured logs, OpenTelemetry, correlation id, RED metrics, liveness, readiness, SLI, SLO, error budget, alerting.

lguidolin/performance-and-scale

Use when working on hot paths, list endpoints, pagination, data-access in loops, or public interfaces/schemas. Symptoms — unbounded queries, N+1 access, no latency budget, optimizing without measuring, or changing an interface many consumers depend on. Keywords — pagination, N+1, Hyrum's Law, performance budget, bundle size.

lguidolin/postgres-postgraphile-rls-and-sql

Use when writing PostgreSQL, PostGraphile config, Row-Level Security policies, SQL schema files, or working on the Browser→App→PostGraphile→Postgres data path. Keywords — RLS, SECURITY DEFINER, search_path, pgSettings, grants, roles, GraphQL depth limit, query cost, statement_timeout, SQL file organization.

lguidolin/recording-decisions

Use when a design or architecture decision has been made and needs to be captured — writing a decision record or ADR, updating a decision index, noting a deferred idea, or superseding a past decision. Keywords — ADR, decision record, rationale, rejected alternatives, dependency index.

lguidolin/resilience-and-deploy-safety

Use when planning a deploy, designing a rollback, or responding to an incident or writing a postmortem. Keywords — deploy safety, rollback, immutable artifact, progressive delivery, canary, blast radius, incident response, blameless postmortem, error budget.

lguidolin/ship-it

Use when the user wants to ship work — push, PR, archive decision records, merge, and clean up. Handles the full lifecycle from committing final changes through post-merge cleanup including converting specs/plans to compact decision records.

lguidolin/tests-as-a-control

Use when writing or modifying tests, when a test breaks during a refactor, or when testing permission/role rules. Symptoms — tempted to edit a test to make it pass, testing only the happy path, a deny-test that started passing, flaky tests, or unsure what to assert.

lguidolin/zero-downtime-migrations

Use when changing a database schema where data must survive the change — adding/removing/renaming columns, constraints, indexes, or backfilling. Symptoms — a destructive migration bundled with a code deploy, a NOT NULL column with a backfill, a table-locking UPDATE, or a rename. Keywords — expand/contract, parallel change, backfill, NOT VALID, CREATE INDEX CONCURRENTLY, graphile-migrate.

相关技能