Sentry 提交消息
为 Sentry 项目创建提交时,请遵循以下约定。
使用时机
- 用户请求提交代码、准备提交消息,或在 git 中保存更改。
- 需要 Sentry 风格的提交格式,包含约定式提交结构和 issue 引用。
- 任务要求在提交前强制执行分支安全检查,特别是避免直接在
main或master上提交。
前置条件
提交前,始终检查当前分支:
git branch --show-current
如果你在 main 或 master 分支上,必须先创建功能分支——除非用户明确要求提交到 main。不要询问用户是否创建分支;直接进行分支创建。create-branch 技能仍会提议一个分支名称供用户确认。
使用 create-branch 技能创建分支。create-branch 完成后,验证当前分支已变更再继续:
git branch --show-current
如果仍在 main 或 master 上(例如用户取消了分支创建),则停止——不要提交。
格式
<type>(<scope>): <subject>
<body>
<footer>
头部是必需的。scope 是可选的。所有行必须保持在 100 个字符以内。
提交类型
| 类型 | 用途 |
|---|---|
feat |
新功能 |
fix |
Bug 修复 |
ref |
重构(无行为变更) |
perf |
性能优化 |
docs |
仅文档 |
test |
测试新增或修正 |
build |
构建系统或依赖 |
ci |
CI 配置 |
chore |
维护任务 |
style |
代码格式化(无逻辑变更) |
meta |
仓库元数据 |
license |
许可证变更 |
标题行规则
- 使用祈使语气、现在时:"Add feature" 而非 "Added feature"
- 首字母大写
- 结尾不加句号
- 最多 70 个字符
正文指南
- 解释做什么和为什么,而非怎么做
- 使用祈使语气和现在时
- 包含变更动机
- 相关时对比之前的行为
页脚:Issue 引用
在页脚中使用以下模式引用 issue:
Fixes GH-1234
Fixes #1234
Fixes SENTRY-1234
Refs LINEAR-ABC-123
Fixes合并时关闭 issueRefs仅链接而不关闭
AI 生成的变更
当变更主要由编码智能体(如 Claude Code)生成时,在提交页脚中包含 Co-Authored-By 署名:
Co-Authored-By: Claude <noreply@anthropic.com>
这是提交中唯一应出现的 AI 参与标识。不要在标题、正文或提交消息的其他任何地方添加"Generated by AI"、"Written with Claude"或类似标记。
示例
简单修复
fix(api): Handle null response in user endpoint
The user API could return null for deleted accounts, causing a crash
in the dashboard. Add null check before accessing user properties.
Fixes SENTRY-5678
Co-Authored-By: Claude <noreply@anthropic.com>
带作用域的功能
feat(alerts): Add Slack thread replies for alert updates
When an alert is updated or resolved, post a reply to the original
Slack thread instead of creating a new message. This keeps related
notifications grouped together.
Refs GH-1234
重构
ref: Extract common validation logic to shared module
Move duplicate validation code from three endpoints into a shared
validator class. No behavior change.
破坏性变更
feat(api)!: Remove deprecated v1 endpoints
Remove all v1 API endpoints that were deprecated in version 23.1.
Clients should migrate to v2 endpoints.
BREAKING CHANGE: v1 endpoints no longer available
Fixes SENTRY-9999
回滚格式
revert: feat(api): Add new endpoint
This reverts commit abc123def456.
Reason: Caused performance regression in production.
原则
- 每个提交应该是单一、稳定的变更
- 提交应该可以独立审查
- 每次提交后仓库应处于可工作状态
参考资料
局限性
- 仅当任务明确符合上述范围时使用此技能。
- 不要将输出视为环境特定验证、测试或专家审查的替代品。
- 如果缺少必需的输入、权限、安全边界或成功标准,请停下来请求澄清。