Files
huangguo_landpage/.cursor/skills/commit-convention/SKILL.md
T
2026-09-15 15:46:36 +07:00

98 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: commit-convention
description: 为本仓库生成符合团队规范的 Git 提交信息,并在用户要求提交代码时执行完整提交流程。用于 git commit、提交代码、写 commit message、创建提交、push 前整理提交等场景;Agent 代提交时必须使用 [Ai] 标记并写清业务变更。
---
# Git 提交规范(Agent 代提交)
## 触发条件
满足任一条件,**必须先加载本 skill**,再执行 `git add` / `git commit`
- 用户明确要求:提交、commit、git commit、保存提交、push 前先 commit 等
- 用户规则中的「committing-changes-with-git」流程已启动
**未获用户明确授权时,不得执行 commit。**
---
## Agent 代提交:标记规则(强制)
由 Cursor Agent 发起的提交,**必须**在 subject 前加 `[Ai]`
```text
[Ai] <type>(<scope>): <subject>
<body 可选:业务背景、影响范围、关联 Bug>
```
- `type``feat` | `fix` | `refactor` | `style` | `perf` | `chore` | `docs` | `test` | `build` | `ci`
- `scope`:模块/页面,如 `benefits``mine``community``player`
- 可在正文末尾追加 trailer(可选):
```text
Co-Authored-By: Cursor <noreply@cursor.com>
```
用户本人手动提交、且明确说明「人工提交」时,建议使用 `[Human]`Agent **不要**替用户假标 `[Human]`
---
## Subject 质量(强制)
提交说明必须让人一眼看懂**改了什么业务**或**修了什么问题**。
### 必须做到
1. 先并行执行:`git status``git diff`(含 staged)、`git log -5 --oneline` 了解风格与变更范围
2. subject 用**完整语义**描述,优先中文;可中英混用 scope
3. 多文件、多模块时:一条 commit 只包同一业务目标;若混杂无关改动,先询问是否拆分
4. body 写:原因、用户可见变化、风险点(如有)
### 严禁(subject 不得仅为或等同于)
`test``修改``update``fix``xxx``111``wip``temp``提交``save`、纯标点、纯数字、单字
### 示例
```text
# ✅
[Ai] feat(benefits): 新增七日签到弹窗与连续签到奖励展示
[Ai] fix(player): 修复横屏切换后 HLS 首帧黑屏
[Ai] refactor(mine): 签到任务列表抽离 useSignTask composable
# ❌
[Ai] fix: 修改
[Ai] feat: test
修改播放器
111
```
---
## 提交流程(与 user rule 对齐)
1. `git status` + `git diff` + `git log`(可并行)
2. 根据 diff **撰写**符合本规范的 messageHEREDOC 传 `-m`
3.`git add` 与本次任务相关的文件
4. **不得**提交 `.env`、密钥、凭据类文件;若用户在 staged 中含此类文件,警告并排除
5. `git commit``git status` 确认成功
6. hook 失败时:**不要** `commit --amend`,修 message 后**新建 commit**
7. **除非用户明确要求,否则不 `git push`**
---
## 输出给用户
提交完成后简要说明:
- commit hash(若有)
- 本次纳入的文件范围
- message 摘要(一行)
---
## 与本地 Hook / CI 的关系
本 skill 约束 **Agent 行为**。若仓库后续接入 `husky` + `commitlint` 或 CI,以仓库脚本校验为准;Agent 仍须预先满足 `[Ai]` 与 subject 质量,避免 hook 拒绝。