Skip to content

Commit 5c273f6

Browse files
DCjanuscodex
andcommitted
feat(skills): extract git commit guidance into standalone skill
Co-authored-by: OpenAI Codex <codex@openai.com> (cherry picked from commit 1df012b)
1 parent 5d192be commit 5c273f6

File tree

2 files changed

+99
-19
lines changed

2 files changed

+99
-19
lines changed

AGENTS.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@
2727
### 2.2 破坏性更新(Breaking Change)
2828
- 如果改动会导致既有用法失效或行为变化,必须在回复中显著标识为 breaking change,并清晰说明影响范围(哪些用法/接口/行为变了)与迁移建议(用户该怎么改)。
2929

30-
### 2.3 Git 提交/推送
31-
- 未收到用户当次明确 `commit` 指令时,不得执行 `git commit`(即便工作区已准备好)。
32-
- 未收到用户当次明确 `push` 指令时,不得执行 `git push`(即便工作区已准备好)。
33-
- 如工作需要提交且用户未明确要求 `commit`,可以询问用户是否需要 `commit`;但不得沿用任何历史授权。
34-
- 禁止主动询问是否需要 `push`(例如“要不要顺便推送”);只有用户当次明确要求 `push` 才能执行 `git push`
35-
- 有疑义先向用户确认,等待明确指令后再执行(`push` 相关限制见上条)。
36-
- 提交信息使用简洁、精确、描述性强的英文,遵循 [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/);可行时尽量包含 scope。
37-
- 创建分支时尽量遵循 [Conventional Branch](https://conventional-branch.github.io/)
38-
39-
### 2.4 依赖管理
30+
### 2.3 依赖管理
4031
- 优先使用官方命令获取最新版依赖。
4132
- 禁止手动修改项目描述文件或锁文件。
4233
- 一次性临时 Python 统一使用 `uv run (--with <外部依赖包>)* python ...``*` 表示 0~N 次),不要直接调用系统 `python`/`python3`
@@ -52,23 +43,21 @@
5243
- Markdown 链接优先使用 `[描述](URL)` 形式,避免裸露 `<URL>`;在 Markdown 中引用相对路径文件时,优先使用链接形式(链接文本仅保留文件名、路径放在链接目标里)。除非有歧义或明确要求,否则不要用 inline code 引用路径。
5344
- 输出文件路径只写纯路径/文件名,不附加 `:行号``#L行号`;仅当用户明确要求或任务必须精确定位(如代码评审/报错排查/同名文件消歧)时附加行号;新生成且需直接打开的文件一律不加行号。
5445

55-
### 3.3 Git 约定
56-
- 提交追加 `Co-authored-by: OpenAI Codex <codex@openai.com>` trailer。
57-
- 日常操作优先使用 `git switch`(分支/HEAD 切换)与 `git restore`(文件恢复),尽量避免使用语义混杂的 `git checkout`
58-
- 常见替代:切分支用 `git switch <branch>`;新建并切换用 `git switch -c <new-branch>`;丢弃工作区改动用 `git restore <path>`;取消暂存用 `git restore --staged <path>`
59-
60-
### 3.4 依赖版本策略
46+
### 3.3 依赖版本策略
6147
- 使用最新可用版本;非必要不手动固定版本号。
6248

63-
### 3.5 Codex 安装偏好
49+
### 3.4 Codex 安装偏好
6450
- Codex CLI 安装命令:`npm i -g @openai/codex@alpha`
6551

6652
## 4. 操作流程
6753

68-
### 4.1 查看 GitHub issue / PR
54+
### 4.1 Git 提交相关操作
55+
- 涉及 `git commit``git push`、分支命名、提交信息或提交前整理时,优先使用 [git-commit](skills/git-commit/)
56+
57+
### 4.2 查看 GitHub issue / PR
6958
- 涉及 GitHub issue/PR 的查看、更新或创建:优先使用 [github-pr-issue](skills/github-pr-issue/)
7059

71-
### 4.2 添加/更新依赖
60+
### 4.3 添加/更新依赖
7261
- 使用对应生态官方命令:
7362
- Rust:`cargo add <crate>`
7463
- Python:`uv add <package>`

skills/git-commit/SKILL.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
name: git-commit
3+
description: 处理 git 提交/推送/分支命名与提交信息规范;当用户要求 commit、push、起分支或整理 commit message 时使用。
4+
---
5+
6+
用于处理 git 提交相关操作与约定,重点是授权边界、提交信息、分支命名和常用非交互命令。
7+
8+
## Quick start
9+
10+
```bash
11+
cd /path/to/repo
12+
git status --short
13+
git add <paths>
14+
git commit -m "feat(scope): short summary"
15+
```
16+
17+
## 使用约定
18+
19+
- 未收到用户当次明确 `commit` 指令时,不执行 `git commit`
20+
- 未收到用户当次明确 `push` 指令时,不执行 `git push`
21+
- 可以在确有需要时询问是否需要 `commit`;不得主动询问是否需要 `push`
22+
- 如存在授权歧义,先向用户确认,再执行相关 git 写操作。
23+
- 提交信息使用简洁、精确、描述性强的英文,遵循 [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/);可行时尽量包含 scope。
24+
- 创建分支时尽量遵循 [Conventional Branch](https://conventional-branch.github.io/)
25+
- 提交时追加 `Co-authored-by: OpenAI Codex <codex@openai.com>` trailer。
26+
- 日常切换/恢复操作优先使用 `git switch``git restore`,尽量避免 `git checkout`
27+
- 进行提交前,先确认工作区中哪些改动属于当前任务,避免把无关改动混入同一个提交。
28+
29+
## 常用场景
30+
31+
- 创建提交:
32+
33+
```bash
34+
git status --short
35+
git add <paths>
36+
git commit -m "fix(scope): concise summary"
37+
```
38+
39+
- 创建带 trailer 的提交:
40+
41+
```bash
42+
git commit -m "feat(scope): concise summary" -m "Co-authored-by: OpenAI Codex <codex@openai.com>"
43+
```
44+
45+
- 补充说明较多的提交:
46+
47+
```bash
48+
git commit -m "refactor(scope): concise summary" -m "Explain the key intent or constraint." -m "Co-authored-by: OpenAI Codex <codex@openai.com>"
49+
```
50+
51+
- 新建并切换分支:
52+
53+
```bash
54+
git switch -c feat/scope-short-summary
55+
```
56+
57+
- 切换已有分支:
58+
59+
```bash
60+
git switch <branch>
61+
```
62+
63+
- 丢弃工作区单文件改动:
64+
65+
```bash
66+
git restore <path>
67+
```
68+
69+
- 取消暂存:
70+
71+
```bash
72+
git restore --staged <path>
73+
```
74+
75+
## 提交信息约定
76+
77+
- 推荐格式:`type(scope): short summary`
78+
- 常见 `type``feat``fix``refactor``docs``test``chore`
79+
- `summary` 保持简短,聚焦结果,不写空泛描述
80+
- 若无合适 scope,可省略 scope,但优先保留
81+
82+
## 冷门参数怎么查
83+
84+
- `git commit --help`
85+
- `git switch --help`
86+
- `git restore --help`
87+
- `git push --help`
88+
89+
## 资源
90+
91+
- [SKILL.md](SKILL.md)

0 commit comments

Comments
 (0)