
关于
提交代码变更时必须使用此技能。遵循 Sentry 约定创建提交,使用规范的 Conventional Commit 格式和 Issue 引用。
name: commit description: 提交代码变更时始终使用本技能——绝不直接提交。遵循 Sentry 约定创建提交,使用正确的约定式提交格式和 issue 引用。在任何提交、git commit、保存变更或提交消息任务时触发。 risk: critical source: community
Sentry 提交消息
为 Sentry 项目创建提交时遵循这些约定。
何时使用
- 用户要求提交代码、准备提交消息或在 git 中保存变更。
- 需要带约定式提交结构和 issue 引用的 Sentry 风格提交格式。
- 任务要求在提交前强制分支安全,特别是避免直接在
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 参与指示。不要在主题、正文或提交消息的其他任何地方添加"由 AI 生成"、"使用 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>
带 scope 的功能
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.
原则
- 每次提交应是单一、稳定的变更
- 提交应可独立审查
- 每次提交后仓库应处于可工作状态
参考
限制
- 仅在任务明确匹配上述范围时使用本技能。
- 不要将输出视为环境特定验证、测试或专家审查的替代品。
- 如果缺少所需输入、权限、安全边界或成功标准,请停下来要求澄清。
兼容工具
Claude CodeCursor
标签
前端开发