@zhouhao4221/devflow-skills 0.3.4 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/package.json +1 -1
- package/plugins/diag/templates/services.yaml.template +31 -0
- package/plugins/req/skills/branch/SKILL.md +48 -377
- package/plugins/req/skills/dev/SKILL.md +1 -1
- package/plugins/req/skills/dev-guide/SKILL.md +74 -399
- package/plugins/req/skills/do/SKILL.md +1 -1
- package/plugins/req/skills/done/SKILL.md +2 -2
- package/plugins/req/skills/edit/SKILL.md +1 -1
- package/plugins/req/skills/fix/SKILL.md +1 -1
- package/plugins/req/skills/init/SKILL.md +66 -430
- package/plugins/req/skills/issue/SKILL.md +1 -1
- package/plugins/req/skills/migrate/SKILL.md +1 -1
- package/plugins/req/skills/natural-language-dispatcher/SKILL.md +78 -438
- package/plugins/req/skills/new/SKILL.md +1 -1
- package/plugins/req/skills/pr/SKILL.md +1 -1
- package/plugins/req/skills/prd/SKILL.md +1 -1
- package/plugins/req/skills/prd-edit/SKILL.md +1 -1
- package/plugins/req/skills/release/SKILL.md +1 -1
- package/plugins/req/skills/review/SKILL.md +1 -1
- package/plugins/req/skills/review-pr/SKILL.md +74 -601
- package/plugins/req/skills/test/SKILL.md +41 -355
- package/plugins/req/skills/test_new/SKILL.md +36 -356
- package/plugins/req/skills/test_regression/SKILL.md +1 -1
- package/plugins/req/skills/update-template/SKILL.md +1 -1
- package/plugins/req/skills/use/SKILL.md +1 -1
- package/plugins/req/templates/claude-md-snippets/frontend-react.md +48 -0
- package/plugins/req/templates/claude-md-snippets/generic.md +43 -0
- package/plugins/req/templates/claude-md-snippets/go-backend.md +47 -0
- package/plugins/req/templates/claude-md-snippets/java-backend.md +46 -0
- package/plugins/req/templates/docker-compose.test.yml +84 -0
- package/plugins/req/templates/index-template.md +60 -0
- package/plugins/req/templates/module-template.md +79 -0
- package/plugins/req/templates/prd-template.md +338 -0
- package/plugins/req/templates/quick-template.md +71 -0
- package/plugins/req/templates/release-prompt-template.md +51 -0
- package/plugins/req/templates/requirement-template.md +256 -0
- package/plugins/req/templates/scripts/test-env.sh +226 -0
- package/plugins/req/templates/tests/e2e/playwright.config.ts +86 -0
- package/plugins/uat/templates/flow-template.md +116 -0
- package/plugins/uat/templates/testid-convention.md +42 -0
package/README.md
CHANGED
|
@@ -6,16 +6,16 @@ DevFlow 技能包 —— 80 个 AI 技能指令,一键安装到 7 种 AI 工
|
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
# 安装全部技能
|
|
9
|
-
npx devflow-skills install --tool opencode --all
|
|
9
|
+
npx @zhouhao4221/devflow-skills install --tool opencode --all
|
|
10
10
|
|
|
11
11
|
# 安装指定插件
|
|
12
|
-
npx devflow-skills install --tool cursor --plugin req
|
|
12
|
+
npx @zhouhao4221/devflow-skills install --tool cursor --plugin req
|
|
13
13
|
|
|
14
14
|
# 安装单个技能
|
|
15
|
-
npx devflow-skills install --tool claude --skill req-dev
|
|
15
|
+
npx @zhouhao4221/devflow-skills install --tool claude --skill req-dev
|
|
16
16
|
|
|
17
17
|
# 查看所有技能
|
|
18
|
-
npx devflow-skills list
|
|
18
|
+
npx @zhouhao4221/devflow-skills list
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
首次运行 `npx` 即用,无需安装任何依赖。
|
|
@@ -39,7 +39,7 @@ Claude Code 使用分层目录保留插件作用域;其余工具采用 `插件
|
|
|
39
39
|
### install — 安装技能
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
npx devflow-skills install --tool <工具名> [--all | --plugin <插件> | --skill <名>] [--dir <路径>] [-g] [--symlink]
|
|
42
|
+
npx @zhouhao4221/devflow-skills install --tool <工具名> [--all | --plugin <插件> | --skill <名>] [--dir <路径>] [-g] [--symlink]
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
| 参数 | 说明 |
|
|
@@ -55,20 +55,20 @@ npx devflow-skills install --tool <工具名> [--all | --plugin <插件> | --ski
|
|
|
55
55
|
### list — 列出技能
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
|
-
npx devflow-skills list [--plugin <插件>] [--filter <关键词>] [--format json]
|
|
58
|
+
npx @zhouhao4221/devflow-skills list [--plugin <插件>] [--filter <关键词>] [--format json]
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
### uninstall — 卸载技能
|
|
62
62
|
|
|
63
63
|
```bash
|
|
64
|
-
npx devflow-skills uninstall --tool <工具名> [--all | --skill <名>] [--dir <路径>] [-g]
|
|
64
|
+
npx @zhouhao4221/devflow-skills uninstall --tool <工具名> [--all | --skill <名>] [--dir <路径>] [-g]
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
### add — 从 GitHub 仓库安装
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
|
-
npx devflow-skills add <owner/repo> --list # 浏览仓库中的技能
|
|
71
|
-
npx devflow-skills add <owner/repo> --tool cursor --all # 安装全部
|
|
70
|
+
npx @zhouhao4221/devflow-skills add <owner/repo> --list # 浏览仓库中的技能
|
|
71
|
+
npx @zhouhao4221/devflow-skills add <owner/repo> --tool cursor --all # 安装全部
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
## 技能分类
|
|
@@ -83,7 +83,7 @@ npx devflow-skills add <owner/repo> --tool cursor --all # 安装全部
|
|
|
83
83
|
|
|
84
84
|
## 与 devflow-claude 的关系
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
本仓库是技能的唯一事实来源,[devflow-claude](https://github.com/zhouhao4221/devflow-claude)(Claude Code 专属插件)通过 `scripts/setup-claude.sh` 从此仓库同步技能文件。
|
|
87
87
|
|
|
88
88
|
## 手动安装(适配器脚本)
|
|
89
89
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# services.yaml - Diag 插件服务清单
|
|
2
|
+
# 位置:~/.claude-diag/config/services.yaml
|
|
3
|
+
#
|
|
4
|
+
# 本文件是 **唯一** 的主机白名单源:
|
|
5
|
+
# - SSH 目标主机必须在本文件 host 字段中登记,否则 Hook 直接拒绝
|
|
6
|
+
# - 每次 /diag:diagnose 都会从本文件读取服务列表让用户选择
|
|
7
|
+
#
|
|
8
|
+
# 校验规则:
|
|
9
|
+
# - 每个 service 必填 name / host / log_paths
|
|
10
|
+
# - name 必须唯一(作为服务标识)
|
|
11
|
+
# - host 对应 ~/.ssh/config 中的 Host 名,或 user@ip 形式
|
|
12
|
+
# - log_paths 至少 1 条,绝对路径
|
|
13
|
+
# - language_hint 可选,枚举:java / node / python / go / ruby / php(仅作 AI 识别提示)
|
|
14
|
+
# - tags 可选,用于筛选
|
|
15
|
+
|
|
16
|
+
services:
|
|
17
|
+
# ------ 示例条目(修改为真实服务后保留并增删) ------
|
|
18
|
+
- name: example-api
|
|
19
|
+
host: example-prod-01
|
|
20
|
+
log_paths:
|
|
21
|
+
- /var/log/app/example.log
|
|
22
|
+
language_hint: java
|
|
23
|
+
tags: [backend]
|
|
24
|
+
|
|
25
|
+
# - name: user-service
|
|
26
|
+
# host: example-prod-02
|
|
27
|
+
# log_paths:
|
|
28
|
+
# - /var/log/user-service/app.log
|
|
29
|
+
# - /var/log/user-service/error.log
|
|
30
|
+
# language_hint: node
|
|
31
|
+
# tags: [backend, user]
|
|
@@ -7,9 +7,7 @@ description: 分支管理 - 配置分支策略、查看分支状态、创建紧
|
|
|
7
7
|
|
|
8
8
|
管理项目的 Git 分支策略,与需求流程(dev/commit/done)联动。
|
|
9
9
|
|
|
10
|
-
>
|
|
11
|
-
> 此命令**不受仓库角色限制**,readonly 仓库也可执行。
|
|
12
|
-
> 不触发缓存同步。
|
|
10
|
+
> 不受仓库角色限制,readonly 可执行。不触发缓存同步。
|
|
13
11
|
|
|
14
12
|
## 命令格式
|
|
15
13
|
|
|
@@ -17,427 +15,100 @@ description: 分支管理 - 配置分支策略、查看分支状态、创建紧
|
|
|
17
15
|
/req:branch [子命令] [参数]
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
| 子命令 | 说明 |
|
|
19
|
+
|--------|------|
|
|
20
|
+
| (空) | 等同于 `status` |
|
|
21
|
+
| `init` | 交互式配置分支策略 |
|
|
22
|
+
| `status` | 查看当前策略和分支状态 |
|
|
23
|
+
| `hotfix [描述]` | 从主分支创建紧急修复分支 |
|
|
25
24
|
|
|
26
25
|
---
|
|
27
26
|
|
|
28
|
-
##
|
|
27
|
+
## init
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
交互式选择分支策略。
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
> 写入规范:读取已有 `.claude/settings.json`,合并 `branchStrategy` 字段后写回。`giteaToken` 写入 `.claude/settings.local.json`。
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
### 流程
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
选择分支管理策略:
|
|
38
|
-
|
|
39
|
-
1. GitHub Flow(推荐)
|
|
40
|
-
所有分支从 main 拉,合回 main
|
|
41
|
-
适合:持续部署、Web 应用、中小团队
|
|
35
|
+
**1. 选择策略模型**:GitHub Flow(推荐)/ Git Flow / Trunk-Based。三种策略的默认配置差异见 `branchStrategy` 字段:`model`、`mainBranch`、`developBranch`、`branchFrom`、`mergeTarget` 等。
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
功能分支从 develop 拉,合回 develop
|
|
45
|
-
适合:版本发布制、APP、大型项目
|
|
37
|
+
**2. 确认或自定义**:生成默认配置展示给用户确认,可调整各项参数。
|
|
46
38
|
|
|
47
|
-
|
|
48
|
-
短期分支或直接在 main 开发
|
|
49
|
-
适合:成熟团队、高频发布、完善的 CI/CD
|
|
39
|
+
**3. 自动检测主分支**:从 `origin/HEAD` 检测,不存在时按序探测 `main`/`master`。与默认值不同时自动更新。
|
|
50
40
|
|
|
51
|
-
|
|
52
|
-
```
|
|
41
|
+
**4. 选择仓库类型**:GitHub (`gh` CLI) / Gitea (REST API) / 其他(仅展示命令)。Gitea 需额外输入实例 URL 和 API Token。
|
|
53
42
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
根据选择生成默认配置,展示给用户确认:
|
|
57
|
-
|
|
58
|
-
**GitHub Flow 默认配置(写入 `settings.json`):**
|
|
59
|
-
```json
|
|
60
|
-
{
|
|
61
|
-
"branchStrategy": {
|
|
62
|
-
"model": "github-flow",
|
|
63
|
-
"repoType": "github",
|
|
64
|
-
"giteaUrl": null,
|
|
65
|
-
"mainBranch": "main",
|
|
66
|
-
"developBranch": null,
|
|
67
|
-
"featurePrefix": "feat/",
|
|
68
|
-
"fixPrefix": "fix/",
|
|
69
|
-
"hotfixPrefix": "hotfix/",
|
|
70
|
-
"branchFrom": "main",
|
|
71
|
-
"mergeTarget": "main",
|
|
72
|
-
"mergeMethod": "merge",
|
|
73
|
-
"deleteBranchAfterMerge": true,
|
|
74
|
-
"reviewers": []
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
43
|
+
**5. 配置默认审核人**:逗号分隔的用户名,写入 `reviewers` 数组。留空则不设置。`/req:pr` 创建时自动请求审核。
|
|
78
44
|
|
|
79
|
-
**Git Flow
|
|
80
|
-
```json
|
|
81
|
-
{
|
|
82
|
-
"branchStrategy": {
|
|
83
|
-
"model": "git-flow",
|
|
84
|
-
"repoType": "github",
|
|
85
|
-
"giteaUrl": null,
|
|
86
|
-
"mainBranch": "main",
|
|
87
|
-
"developBranch": "develop",
|
|
88
|
-
"featurePrefix": "feat/",
|
|
89
|
-
"fixPrefix": "fix/",
|
|
90
|
-
"hotfixPrefix": "hotfix/",
|
|
91
|
-
"branchFrom": "develop",
|
|
92
|
-
"mergeTarget": "develop",
|
|
93
|
-
"mergeMethod": "merge",
|
|
94
|
-
"deleteBranchAfterMerge": true,
|
|
95
|
-
"reviewers": []
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**Trunk-Based 默认配置(写入 `settings.json`):**
|
|
101
|
-
```json
|
|
102
|
-
{
|
|
103
|
-
"branchStrategy": {
|
|
104
|
-
"model": "trunk-based",
|
|
105
|
-
"repoType": "github",
|
|
106
|
-
"giteaUrl": null,
|
|
107
|
-
"mainBranch": "main",
|
|
108
|
-
"developBranch": null,
|
|
109
|
-
"featurePrefix": "feat/",
|
|
110
|
-
"fixPrefix": "fix/",
|
|
111
|
-
"hotfixPrefix": "hotfix/",
|
|
112
|
-
"branchFrom": "main",
|
|
113
|
-
"mergeTarget": "main",
|
|
114
|
-
"deleteBranchAfterMerge": true,
|
|
115
|
-
"reviewers": []
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
```
|
|
45
|
+
**6. Git Flow 额外步骤**:检查 develop 分支,不存在则从 main 创建。
|
|
119
46
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
初始化时从 `origin/HEAD` 检测实际主分支名,不存在时按序探测 `main` / `master`。检测到的主分支与默认值不同时,自动更新配置:
|
|
123
|
-
```
|
|
124
|
-
检测到主分支为 master,已自动更新配置
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
#### 4. 选择仓库托管类型
|
|
128
|
-
|
|
129
|
-
```
|
|
130
|
-
仓库托管类型:
|
|
131
|
-
|
|
132
|
-
1. GitHub
|
|
133
|
-
使用 gh CLI 创建 PR
|
|
134
|
-
|
|
135
|
-
2. Gitea
|
|
136
|
-
使用 Gitea REST API 创建 PR
|
|
137
|
-
|
|
138
|
-
3. 其他(GitLab / Bitbucket / 本地)
|
|
139
|
-
仅展示合并命令,不自动创建 PR
|
|
140
|
-
|
|
141
|
-
请选择(1/2/3,默认 1):
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
**选择 Gitea 时追加配置:**
|
|
145
|
-
|
|
146
|
-
```
|
|
147
|
-
Gitea 实例地址(如 https://git.example.com):
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
自动从 git remote URL 解析 owner/repo(SSH/HTTPS 均支持)。
|
|
151
|
-
|
|
152
|
-
**Gitea Token 说明:**
|
|
153
|
-
```
|
|
154
|
-
Gitea API Token:
|
|
155
|
-
token 存入 .claude/settings.local.json 的顶层 giteaToken 字段(不提交 git)
|
|
156
|
-
生成方式:Gitea → 设置 → 应用 → 生成令牌(需 repo 权限)
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
#### 5. 配置默认审核人(可选)
|
|
160
|
-
|
|
161
|
-
```
|
|
162
|
-
默认审核人(创建 PR 时自动设置,无需每次确认):
|
|
163
|
-
多个用逗号分隔,留空则不设置(如:alice,bob):
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
输入格式:
|
|
167
|
-
- 单人:`alice`
|
|
168
|
-
- 多人:`alice,bob,carol`
|
|
169
|
-
- 留空回车 → `reviewers: []`,PR 创建时不附带审核人
|
|
170
|
-
|
|
171
|
-
写入 `branchStrategy.reviewers`(数组)。用户名按平台规范:
|
|
172
|
-
- GitHub:账号 username
|
|
173
|
-
- Gitea:实例内 username
|
|
174
|
-
|
|
175
|
-
> 不在此校验用户是否存在;`/req:pr` 创建 PR 时调用平台 API,单个无效用户会输出 ⚠️ 但不阻塞 PR。
|
|
176
|
-
|
|
177
|
-
#### 6. Git Flow 额外步骤
|
|
178
|
-
|
|
179
|
-
如果选择 Git Flow,检查 develop 分支是否存在于远端:存在 → 使用;
|
|
180
|
-
- 不存在 → 提示创建:
|
|
181
|
-
```
|
|
182
|
-
develop 分支不存在,是否从 main 创建?
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
#### 7. 写入配置
|
|
186
|
-
|
|
187
|
-
> 写入规范见 [_storage.md](./_storage.md#settings-文件写入规范)。
|
|
188
|
-
|
|
189
|
-
**`branchStrategy`(不含 token)写入 `.claude/settings.json`**:读取已有内容,合并 `branchStrategy` 字段后写回。
|
|
190
|
-
|
|
191
|
-
**`giteaToken` 单独写入 `.claude/settings.local.json`**(顶层字段,非嵌套在 `branchStrategy` 内):
|
|
192
|
-
```json
|
|
193
|
-
{ "giteaToken": "<用户输入的 token>" }
|
|
194
|
-
```
|
|
195
|
-
非 Gitea 仓库时跳过此步骤(无需写入)。
|
|
196
|
-
|
|
197
|
-
⚠️ **禁止**创建独立的 `branchStrategy.json` 或其他文件。
|
|
198
|
-
|
|
199
|
-
```
|
|
200
|
-
✅ 分支策略已配置!
|
|
201
|
-
|
|
202
|
-
策略:GitHub Flow
|
|
203
|
-
仓库类型:Gitea(https://git.example.com)
|
|
204
|
-
主分支:main
|
|
205
|
-
功能分支:feat/REQ-XXX-slug(从 main 拉)
|
|
206
|
-
修复分支:fix/QUICK-XXX-slug(从 main 拉)
|
|
207
|
-
紧急修复:hotfix/xxx(从 main 拉)
|
|
208
|
-
合并目标:main
|
|
209
|
-
合并后删除分支:是
|
|
210
|
-
默认审核人:@alice, @bob ← reviewers 非空时输出,空数组不输出此行
|
|
211
|
-
|
|
212
|
-
后续使用:
|
|
213
|
-
- /req:dev 创建分支时会自动遵循此策略
|
|
214
|
-
- /req:commit 会检查分支合规性
|
|
215
|
-
- /req:done 会根据仓库类型自动创建 PR 或提示合并命令
|
|
216
|
-
```
|
|
47
|
+
**7. 写入配置**:输出策略摘要(模型、仓库类型、分支前缀、合并目标、审核人等)。
|
|
217
48
|
|
|
218
49
|
---
|
|
219
50
|
|
|
220
|
-
##
|
|
221
|
-
|
|
222
|
-
查看当前分支策略和各需求分支的状态。
|
|
223
|
-
|
|
224
|
-
### 执行流程
|
|
51
|
+
## status
|
|
225
52
|
|
|
226
|
-
|
|
53
|
+
### 流程
|
|
227
54
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
建议执行 /req:branch init 配置分支策略
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
#### 2. 展示策略信息
|
|
238
|
-
|
|
239
|
-
```
|
|
240
|
-
分支策略:GitHub Flow
|
|
241
|
-
|
|
242
|
-
| 配置项 | 值 |
|
|
243
|
-
|-------|-----|
|
|
244
|
-
| 模型 | github-flow |
|
|
245
|
-
| 仓库类型 | gitea(https://git.example.com)|
|
|
246
|
-
| 主分支 | main |
|
|
247
|
-
| 功能分支前缀 | feat/ |
|
|
248
|
-
| 修复分支前缀 | fix/ |
|
|
249
|
-
| 紧急修复前缀 | hotfix/ |
|
|
250
|
-
| 拉取基准 | main |
|
|
251
|
-
| 合并目标 | main |
|
|
252
|
-
| 合并后删除 | 是 |
|
|
253
|
-
| 默认审核人 | @alice, @bob(空数组显示 -) |
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
#### 3. 展示当前分支状态
|
|
257
|
-
|
|
258
|
-
获取当前分支名并展示:
|
|
259
|
-
```
|
|
260
|
-
当前分支:feat/REQ-001-user-points
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
#### 4. 展示活跃需求的分支信息
|
|
264
|
-
|
|
265
|
-
扫描活跃需求文档,提取 branch 字段:
|
|
266
|
-
|
|
267
|
-
```
|
|
268
|
-
需求分支状态:
|
|
269
|
-
|
|
270
|
-
| 需求 | 分支 | 状态 | 是否当前 |
|
|
271
|
-
|------|------|------|---------|
|
|
272
|
-
| REQ-001 用户积分 | feat/REQ-001-user-points | 开发中 | ← 当前 |
|
|
273
|
-
| QUICK-002 修复过滤 | fix/QUICK-002-order-filter | 开发中 | |
|
|
274
|
-
| REQ-003 订单管理 | - (未创建) | 评审通过 | |
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
#### 5. 检查分支健康状况
|
|
278
|
-
|
|
279
|
-
```
|
|
280
|
-
✅ 分支健康检查:
|
|
281
|
-
- 当前在需求分支,关联 REQ-001
|
|
282
|
-
- 需求分支与主分支无冲突
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
或:
|
|
286
|
-
|
|
287
|
-
```
|
|
288
|
-
⚠️ 分支注意事项:
|
|
289
|
-
- 当前在 main 分支,有 2 个活跃需求分支
|
|
290
|
-
- feat/REQ-001-user-points 落后 main 3 个提交,建议 rebase
|
|
291
|
-
```
|
|
55
|
+
1. 读取配置(未配置时提示建议执行 `init`)
|
|
56
|
+
2. 展示策略信息表
|
|
57
|
+
3. 展示当前分支
|
|
58
|
+
4. 扫描活跃需求文档,展示各需求分支状态和是否当前
|
|
59
|
+
5. 检查分支健康(当前是否在需求分支、与主分支是否有冲突、是否需要 rebase)
|
|
292
60
|
|
|
293
61
|
---
|
|
294
62
|
|
|
295
|
-
##
|
|
296
|
-
|
|
297
|
-
从主分支创建紧急修复分支,用于线上紧急问题。
|
|
63
|
+
## hotfix
|
|
298
64
|
|
|
299
|
-
|
|
65
|
+
从主分支创建紧急修复分支。
|
|
300
66
|
|
|
301
|
-
|
|
67
|
+
### 流程
|
|
302
68
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
- 问题描述(必填)
|
|
309
|
-
|
|
310
|
-
#### 3. 生成分支名
|
|
311
|
-
|
|
312
|
-
```
|
|
313
|
-
hotfix/<slug>
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
- slug:问题描述的英文翻译,lowercase kebab-case,最多 5 词
|
|
317
|
-
|
|
318
|
-
#### 4. 创建分支
|
|
319
|
-
|
|
320
|
-
**关键**:hotfix 始终从**主分支**拉取,无论当前使用什么策略。
|
|
321
|
-
|
|
322
|
-
fetch 并基于 `branchStrategy.mainBranch`(默认 main)创建 `hotfix/<slug>` 分支。
|
|
323
|
-
|
|
324
|
-
```
|
|
325
|
-
紧急修复分支已创建
|
|
326
|
-
|
|
327
|
-
分支:hotfix/fix-order-total-calc
|
|
328
|
-
基于:main (最新)
|
|
329
|
-
完成后合并到:main
|
|
330
|
-
|
|
331
|
-
后续步骤:
|
|
332
|
-
1. 修复问题
|
|
333
|
-
2. /req:commit 修复订单金额计算错误
|
|
334
|
-
3. 合并到 main:git checkout main && git merge hotfix/fix-order-total-calc
|
|
335
|
-
4. 删除分支:git branch -d hotfix/fix-order-total-calc
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
#### 5. Git Flow 额外提醒
|
|
339
|
-
|
|
340
|
-
如果使用 Git Flow 策略,hotfix 完成后需要合并到**两个分支**:
|
|
341
|
-
|
|
342
|
-
```
|
|
343
|
-
完成后需合并到:
|
|
344
|
-
1. main(生产环境)
|
|
345
|
-
2. develop(开发分支同步)
|
|
346
|
-
|
|
347
|
-
合并命令:
|
|
348
|
-
git checkout main && git merge hotfix/fix-order-total-calc
|
|
349
|
-
git checkout develop && git merge hotfix/fix-order-total-calc
|
|
350
|
-
git branch -d hotfix/fix-order-total-calc
|
|
351
|
-
```
|
|
69
|
+
1. 工作区检查(有未提交改动则终止)
|
|
70
|
+
2. 收集问题描述(必填)
|
|
71
|
+
3. 生成分支名 `hotfix/<slug>`(slug:英文翻译,kebab-case,最多 5 词)
|
|
72
|
+
4. 基于 `branchStrategy.mainBranch` 创建分支
|
|
73
|
+
5. **Git Flow 额外提醒**:hotfix 完成后需合并到 main 和 develop 两个分支
|
|
352
74
|
|
|
353
75
|
---
|
|
354
76
|
|
|
355
77
|
## 策略对各命令的影响
|
|
356
78
|
|
|
357
|
-
###
|
|
79
|
+
### `/req:dev` 分支创建
|
|
358
80
|
|
|
359
|
-
|
|
360
|
-
|-------|------|
|
|
361
|
-
| `branchFrom` | `git checkout -b <branch> <branchFrom>` 的基准分支 |
|
|
362
|
-
| `featurePrefix` | REQ-XXX 分支前缀(替代硬编码的 `feat/`) |
|
|
363
|
-
| `fixPrefix` | QUICK-XXX 分支前缀(替代硬编码的 `fix/`) |
|
|
81
|
+
`branchFrom` 决定基准分支,`featurePrefix`/`fixPrefix` 决定分支前缀。
|
|
364
82
|
|
|
365
|
-
###
|
|
83
|
+
### `/req:commit` 分支检查
|
|
366
84
|
|
|
367
85
|
| 场景 | 行为 |
|
|
368
86
|
|------|------|
|
|
369
|
-
| 在 mainBranch 上,有活跃需求 |
|
|
370
|
-
| 在
|
|
371
|
-
|
|
|
372
|
-
| 在需求分支上 | 正常提交,自动关联对应需求 |
|
|
373
|
-
| 在 hotfix 分支上 | 正常提交,类型建议选「修复」 |
|
|
374
|
-
|
|
375
|
-
### /req:pr 审核人自动设置
|
|
87
|
+
| 在 mainBranch 上,有活跃需求 | 警告建议切换 |
|
|
88
|
+
| 在 developBranch 上(Git Flow) | 警告应在功能分支 |
|
|
89
|
+
| 在需求/hotfix 分支上 | 正常提交 |
|
|
376
90
|
|
|
377
|
-
|
|
378
|
-
|-------|------|
|
|
379
|
-
| `reviewers` | 非空时创建 PR 后自动请求审核(GitHub: `gh pr create --reviewer ...`;Gitea: `POST /pulls/<N>/requested_reviewers`),不再询问用户 |
|
|
91
|
+
### `/req:pr` 审核人
|
|
380
92
|
|
|
381
|
-
|
|
93
|
+
`reviewers` 非空时创建 PR 后自动请求审核,不询问用户。
|
|
382
94
|
|
|
383
|
-
|
|
95
|
+
### `/req:done` 合并方式
|
|
384
96
|
|
|
385
97
|
| 仓库类型 | 行为 |
|
|
386
98
|
|---------|------|
|
|
387
|
-
| `gitea` |
|
|
388
|
-
| `github` |
|
|
389
|
-
| `other` |
|
|
99
|
+
| `gitea` | 推送 + API 创建 PR |
|
|
100
|
+
| `github` | 提示 `gh pr create` |
|
|
101
|
+
| `other` | 展示 `git merge` 命令 |
|
|
390
102
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
| 策略 | 合并目标 |
|
|
394
|
-
|------|---------|
|
|
395
|
-
| GitHub Flow | `main` |
|
|
396
|
-
| Git Flow | `develop`(hotfix 额外合并到 main) |
|
|
397
|
-
| Trunk-Based | `main` |
|
|
103
|
+
合并目标:GitHub Flow → `main`,Git Flow → `develop`(hotfix 额外 → main),Trunk-Based → `main`。
|
|
398
104
|
|
|
399
105
|
---
|
|
400
106
|
|
|
401
107
|
## 配置兼容性
|
|
402
108
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
所有命令保持当前默认行为,不会报错:
|
|
406
|
-
- `/req:dev`:使用硬编码的 `feat/` 和 `fix/` 前缀,自动检测主分支
|
|
407
|
-
- `/req:commit`:不做分支检查
|
|
408
|
-
- `/req:done`:通用合并提醒
|
|
409
|
-
|
|
410
|
-
### 配置存储
|
|
411
|
-
|
|
412
|
-
```jsonc
|
|
413
|
-
// .claude/settings.json(纳入 git,团队共享)
|
|
414
|
-
{
|
|
415
|
-
"requirementProject": "my-saas",
|
|
416
|
-
"requirementRole": "primary",
|
|
417
|
-
"branchStrategy": {
|
|
418
|
-
"model": "github-flow",
|
|
419
|
-
"repoType": "gitea",
|
|
420
|
-
"giteaUrl": "https://git.example.com",
|
|
421
|
-
"mainBranch": "main",
|
|
422
|
-
"developBranch": null,
|
|
423
|
-
"featurePrefix": "feat/",
|
|
424
|
-
"fixPrefix": "fix/",
|
|
425
|
-
"hotfixPrefix": "hotfix/",
|
|
426
|
-
"branchFrom": "main",
|
|
427
|
-
"mergeTarget": "main",
|
|
428
|
-
"mergeMethod": "merge",
|
|
429
|
-
"deleteBranchAfterMerge": true,
|
|
430
|
-
"reviewers": ["alice", "bob"]
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
```
|
|
109
|
+
未配置策略时所有命令保持默认行为(`feat/`/`fix/` 前缀,不做分支检查,通用合并提醒),不会报错。
|
|
434
110
|
|
|
435
|
-
|
|
436
|
-
// .claude/settings.local.json(本地,加入 .gitignore,不提交)
|
|
437
|
-
{
|
|
438
|
-
"giteaToken": "YOUR_TOKEN_HERE"
|
|
439
|
-
}
|
|
440
|
-
```
|
|
111
|
+
配置文件结构见 `.claude/settings.json`(`branchStrategy` 对象,纳入 git)和 `.claude/settings.local.json`(`giteaToken`,不提交)。
|
|
441
112
|
|
|
442
113
|
---
|
|
443
114
|
|