create-vibe-workflow 0.1.0 → 0.2.0

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.
Files changed (120) hide show
  1. package/README.md +248 -57
  2. package/dist/adapters/next-only/skills.recommend.json +1 -0
  3. package/dist/adapters/node-api/skills.recommend.json +1 -0
  4. package/dist/cli.js +163 -5
  5. package/dist/cli.js.map +1 -1
  6. package/dist/generator.d.ts.map +1 -1
  7. package/dist/generator.js +255 -44
  8. package/dist/generator.js.map +1 -1
  9. package/dist/questions.d.ts +11 -1
  10. package/dist/questions.d.ts.map +1 -1
  11. package/dist/questions.js +103 -16
  12. package/dist/questions.js.map +1 -1
  13. package/dist/templates/claude-md/CLAUDE.zh-CN.md +51 -46
  14. package/dist/templates/claude-md/next-only/CLAUDE.zh-CN.md +46 -0
  15. package/dist/templates/claude-md/node-api/CLAUDE.zh-CN.md +47 -0
  16. package/dist/templates/commands/gstack/cso.md.ejs +213 -0
  17. package/dist/templates/commands/gstack/office-hours.md.ejs +109 -0
  18. package/dist/templates/commands/gstack/review.md.ejs +192 -0
  19. package/dist/templates/commands/gstack/ship.md.ejs +256 -0
  20. package/dist/templates/commands/opsx/apply.md.ejs +106 -0
  21. package/dist/templates/commands/opsx/archive.md.ejs +88 -0
  22. package/dist/templates/commands/opsx/explore.md.ejs +84 -0
  23. package/dist/templates/commands/opsx/propose.md.ejs +185 -0
  24. package/dist/templates/commands/superpowers/brainstorm.md.ejs +240 -0
  25. package/dist/templates/commands/superpowers/tdd.md.ejs +230 -0
  26. package/dist/templates/commands/superpowers/verify.md.ejs +211 -0
  27. package/dist/templates/commands/workflow/plan.md.ejs +219 -0
  28. package/dist/templates/hooks/check-deps.mjs +66 -65
  29. package/dist/templates/memory/.gitkeep +0 -0
  30. package/dist/templates/memory/MEMORY.md.ejs +88 -0
  31. package/dist/templates/memory/dev-notes.md.ejs +61 -0
  32. package/dist/templates/memory/troubleshooting.md.ejs +30 -0
  33. package/dist/templates/rules/agents.md +49 -49
  34. package/dist/templates/rules/coding-style.md +156 -117
  35. package/dist/templates/rules/development-workflow.md +103 -50
  36. package/dist/templates/rules/git-workflow.md +103 -47
  37. package/dist/templates/rules/hooks.md +159 -0
  38. package/dist/templates/rules/hooks.md.ejs +159 -0
  39. package/dist/templates/rules/memory.md +106 -0
  40. package/dist/templates/rules/memory.md.ejs +106 -0
  41. package/dist/templates/rules/patterns.md +117 -48
  42. package/dist/templates/rules/performance.md +108 -0
  43. package/dist/templates/rules/performance.md.ejs +108 -0
  44. package/dist/templates/rules/security.md +52 -37
  45. package/dist/templates/rules/testing.md +83 -30
  46. package/dist/templates/settings/settings.template.json +18 -2
  47. package/dist/templates/skills/advanced/caveman/SKILL.md.ejs +144 -0
  48. package/dist/templates/skills/advanced/diagnose/SKILL.md.ejs +159 -0
  49. package/dist/templates/skills/advanced/grill-with-docs/SKILL.md.ejs +154 -0
  50. package/dist/templates/skills/advanced/improve-codebase-architecture/SKILL.md.ejs +172 -0
  51. package/dist/templates/skills/backend/backend-patterns/SKILL.md.ejs +263 -0
  52. package/dist/templates/skills/database/database-migrations/SKILL.md.ejs +202 -0
  53. package/dist/templates/skills/database/postgres-patterns/SKILL.md.ejs +235 -0
  54. package/dist/templates/skills/devops/deployment-patterns/SKILL.md.ejs +228 -0
  55. package/dist/templates/skills/devops/docker-patterns/SKILL.md.ejs +215 -0
  56. package/dist/templates/skills/frontend/frontend-patterns/SKILL.md.ejs +195 -0
  57. package/dist/templates/skills/skill-manifest.json +59 -0
  58. package/dist/templates/skills/skills-lock.template.json +12 -0
  59. package/dist/templates/skills/testing/e2e-testing/SKILL.md.ejs +224 -0
  60. package/dist/templates/skills/workflow/coding-standards/SKILL.md.ejs +143 -0
  61. package/dist/templates/skills/workflow/search-first/SKILL.md.ejs +103 -0
  62. package/dist/templates/skills/workflow/security-review/SKILL.md.ejs +146 -0
  63. package/dist/templates/skills/workflow/strategic-compact/SKILL.md.ejs +108 -0
  64. package/dist/templates/skills/workflow/tdd-workflow/SKILL.md.ejs +104 -0
  65. package/dist/templates/skills/workflow/verification-loop/SKILL.md.ejs +144 -0
  66. package/dist/utils.d.ts +40 -0
  67. package/dist/utils.d.ts.map +1 -0
  68. package/dist/utils.js +110 -0
  69. package/dist/utils.js.map +1 -0
  70. package/package.json +2 -2
  71. package/templates/claude-md/CLAUDE.zh-CN.md +51 -46
  72. package/templates/claude-md/next-only/CLAUDE.zh-CN.md +46 -0
  73. package/templates/claude-md/node-api/CLAUDE.zh-CN.md +47 -0
  74. package/templates/commands/gstack/cso.md.ejs +213 -0
  75. package/templates/commands/gstack/office-hours.md.ejs +109 -0
  76. package/templates/commands/gstack/review.md.ejs +192 -0
  77. package/templates/commands/gstack/ship.md.ejs +256 -0
  78. package/templates/commands/opsx/apply.md.ejs +106 -0
  79. package/templates/commands/opsx/archive.md.ejs +88 -0
  80. package/templates/commands/opsx/explore.md.ejs +84 -0
  81. package/templates/commands/opsx/propose.md.ejs +185 -0
  82. package/templates/commands/superpowers/brainstorm.md.ejs +240 -0
  83. package/templates/commands/superpowers/tdd.md.ejs +230 -0
  84. package/templates/commands/superpowers/verify.md.ejs +211 -0
  85. package/templates/commands/workflow/plan.md.ejs +219 -0
  86. package/templates/hooks/check-deps.mjs +66 -65
  87. package/templates/memory/.gitkeep +0 -0
  88. package/templates/memory/MEMORY.md.ejs +88 -0
  89. package/templates/memory/dev-notes.md.ejs +61 -0
  90. package/templates/memory/troubleshooting.md.ejs +30 -0
  91. package/templates/rules/agents.md +49 -49
  92. package/templates/rules/coding-style.md +156 -117
  93. package/templates/rules/development-workflow.md +103 -50
  94. package/templates/rules/git-workflow.md +103 -47
  95. package/templates/rules/hooks.md +159 -0
  96. package/templates/rules/memory.md +106 -0
  97. package/templates/rules/patterns.md +117 -48
  98. package/templates/rules/performance.md +108 -0
  99. package/templates/rules/security.md +52 -37
  100. package/templates/rules/testing.md +83 -30
  101. package/templates/settings/settings.template.json +18 -2
  102. package/templates/skills/advanced/caveman/SKILL.md.ejs +144 -0
  103. package/templates/skills/advanced/diagnose/SKILL.md.ejs +159 -0
  104. package/templates/skills/advanced/grill-with-docs/SKILL.md.ejs +154 -0
  105. package/templates/skills/advanced/improve-codebase-architecture/SKILL.md.ejs +172 -0
  106. package/templates/skills/backend/backend-patterns/SKILL.md.ejs +263 -0
  107. package/templates/skills/database/database-migrations/SKILL.md.ejs +202 -0
  108. package/templates/skills/database/postgres-patterns/SKILL.md.ejs +235 -0
  109. package/templates/skills/devops/deployment-patterns/SKILL.md.ejs +228 -0
  110. package/templates/skills/devops/docker-patterns/SKILL.md.ejs +215 -0
  111. package/templates/skills/frontend/frontend-patterns/SKILL.md.ejs +195 -0
  112. package/templates/skills/skill-manifest.json +59 -0
  113. package/templates/skills/skills-lock.template.json +12 -0
  114. package/templates/skills/testing/e2e-testing/SKILL.md.ejs +224 -0
  115. package/templates/skills/workflow/coding-standards/SKILL.md.ejs +143 -0
  116. package/templates/skills/workflow/search-first/SKILL.md.ejs +103 -0
  117. package/templates/skills/workflow/security-review/SKILL.md.ejs +146 -0
  118. package/templates/skills/workflow/strategic-compact/SKILL.md.ejs +108 -0
  119. package/templates/skills/workflow/tdd-workflow/SKILL.md.ejs +104 -0
  120. package/templates/skills/workflow/verification-loop/SKILL.md.ejs +144 -0
@@ -1,117 +1,156 @@
1
- ---
2
- paths:
3
- - "**/*.ts"
4
- - "**/*.tsx"
5
- - "**/*.js"
6
- - "**/*.jsx"
7
- ---
8
- # TypeScript/JavaScript Coding Style
9
-
10
- > 本文件是 TypeScript/JavaScript 项目的代码风格规范。
11
-
12
- ## Types and Interfaces
13
-
14
- Use types to make public APIs, shared models, and component props explicit, readable, and reusable.
15
-
16
- ### Public APIs
17
-
18
- - Add parameter and return types to exported functions, shared utilities, and public class methods
19
- - Let TypeScript infer obvious local variable types
20
- - Extract repeated inline object shapes into named types or interfaces
21
-
22
- ```typescript
23
- // WRONG: Exported function without explicit types
24
- export function formatUser(user) {
25
- return `${user.firstName} ${user.lastName}`
26
- }
27
-
28
- // CORRECT: Explicit types on public APIs
29
- interface User {
30
- firstName: string
31
- lastName: string
32
- }
33
-
34
- export function formatUser(user: User): string {
35
- return `${user.firstName} ${user.lastName}`
36
- }
37
- ```
38
-
39
- ### Interfaces vs. Type Aliases
40
-
41
- - Use `interface` for object shapes that may be extended or implemented
42
- - Use `type` for unions, intersections, tuples, mapped types, and utility types
43
- - Prefer string literal unions over `enum` unless an `enum` is required for interoperability
44
-
45
- ### Avoid `any`
46
-
47
- - Avoid `any` in application code
48
- - Use `unknown` for external or untrusted input, then narrow it safely
49
- - Use generics when a value's type depends on the caller
50
-
51
- ```typescript
52
- // WRONG: any removes type safety
53
- function getErrorMessage(error: any) {
54
- return error.message
55
- }
56
-
57
- // CORRECT: unknown forces safe narrowing
58
- function getErrorMessage(error: unknown): string {
59
- if (error instanceof Error) {
60
- return error.message
61
- }
62
- return 'Unexpected error'
63
- }
64
- ```
65
-
66
- ## Immutability
67
-
68
- Use spread operator for immutable updates:
69
-
70
- ```typescript
71
- // WRONG: Mutation
72
- function updateUser(user: User, name: string): User {
73
- user.name = name // MUTATION!
74
- return user
75
- }
76
-
77
- // CORRECT: Immutability
78
- function updateUser(user: Readonly<User>, name: string): User {
79
- return { ...user, name }
80
- }
81
- ```
82
-
83
- ## Error Handling
84
-
85
- Use async/await with try-catch and narrow unknown errors safely:
86
-
87
- ```typescript
88
- async function loadUser(userId: string): Promise<User> {
89
- try {
90
- return await riskyOperation(userId)
91
- } catch (error: unknown) {
92
- logger.error('Operation failed', error)
93
- throw new Error(getErrorMessage(error))
94
- }
95
- }
96
- ```
97
-
98
- ## Input Validation
99
-
100
- Use Zod for schema-based validation and infer types from the schema:
101
-
102
- ```typescript
103
- import { z } from 'zod'
104
-
105
- const userSchema = z.object({
106
- email: z.string().email(),
107
- age: z.number().int().min(0).max(150)
108
- })
109
-
110
- type UserInput = z.infer<typeof userSchema>
111
- const validated: UserInput = userSchema.parse(input)
112
- ```
113
-
114
- ## Console.log
115
-
116
- - No `console.log` statements in production code
117
- - Use proper logging libraries instead
1
+ ---
2
+ paths:
3
+ - "**/*.ts"
4
+ - "**/*.tsx"
5
+ - "**/*.js"
6
+ - "**/*.jsx"
7
+ ---
8
+ # TypeScript / JavaScript 编码规范
9
+
10
+ > 本文件是项目的代码风格规范。所有生成的代码都应遵循这些规则。
11
+
12
+ ## 类型系统
13
+
14
+ ### 公共 API
15
+ - 导出函数、共享工具类、公共类方法必须添加参数和返回类型
16
+ - 局部变量让 TypeScript 自动推断
17
+ - 重复的内联对象形状应提取为命名类型或接口
18
+
19
+ ```typescript
20
+ // 导出函数没有显式类型
21
+ export function formatUser(user) {
22
+ return `${user.firstName} ${user.lastName}`
23
+ }
24
+
25
+ // 显式类型
26
+ interface User { firstName: string; lastName: string }
27
+ export function formatUser(user: User): string {
28
+ return `${user.firstName} ${user.lastName}`
29
+ }
30
+ ```
31
+
32
+ ### Interface vs Type
33
+ - 可能需要扩展或实现的对象形状 → 用 `interface`
34
+ - 联合、交叉、元组、映射类型 `type`
35
+ - 优先用字符串字面量联合代替 `enum`(除非需要互操作性)
36
+
37
+ ### 禁止 `any`
38
+ - 应用代码中避免使用 `any`
39
+ - 外部/不可信输入用 `unknown`,然后安全收窄
40
+ - 依赖调用者决定类型的场景用泛型
41
+
42
+ ```typescript
43
+ // any 破坏了类型安全
44
+ function getErrorMessage(error: any) { return error.message }
45
+
46
+ // ✅ unknown 强制安全收窄
47
+ function getErrorMessage(error: unknown): string {
48
+ if (error instanceof Error) return error.message
49
+ return 'Unexpected error'
50
+ }
51
+ ```
52
+
53
+ ## 不可变性
54
+
55
+ 使用展开运算符进行不可变更新:
56
+
57
+ ```typescript
58
+ // 直接修改(Mutation)
59
+ function updateUser(user: User, name: string): User {
60
+ user.name = name
61
+ return user
62
+ }
63
+
64
+ // ✅ 不可变更新
65
+ function updateUser(user: Readonly<User>, name: string): User {
66
+ return { ...user, name }
67
+ }
68
+ ```
69
+
70
+ ## 错误处理
71
+
72
+ 使用 async/await + try-catch + 安全的错误收窄:
73
+
74
+ ```typescript
75
+ async function loadUser(userId: string): Promise<User> {
76
+ try {
77
+ return await riskyOperation(userId)
78
+ } catch (error: unknown) {
79
+ logger.error('操作失败', error)
80
+ throw new Error(getErrorMessage(error))
81
+ }
82
+ }
83
+ ```
84
+
85
+ > **业务层统一错误类(AppError / NotFoundError / ValidationError)及使用示例见 `.claude/rules/patterns.md` § 错误处理统一模式**
86
+ > 本节专注底层错误收窄技巧,patterns.md 定义上层错误分类体系。
87
+
88
+ ## 输入校验
89
+
90
+ 使用 Zod 做 schema 驱动的校验,并从 schema 推断类型:
91
+
92
+ ```typescript
93
+ import { z } from 'zod'
94
+
95
+ const userSchema = z.object({
96
+ email: z.string().email(),
97
+ age: z.number().int().min(0).max(150)
98
+ })
99
+
100
+ type UserInput = z.infer<typeof userSchema>
101
+ const validated: UserInput = userSchema.parse(input)
102
+ ```
103
+
104
+ ## 命名规范
105
+
106
+ | 类别 | 规范 | 示例 |
107
+ |------|------|------|
108
+ | 文件名 | kebab-case | `user-service.ts` |
109
+ | 变量/函数 | camelCase | `getUserById` |
110
+ | 类/接口/类型 | PascalCase | `UserService` |
111
+ | 常量 | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT` |
112
+ | 枚举值 | UPPER_SNAKE_CASE | `Role.ADMIN` |
113
+ | Boolean 前缀 | is/has/can/should | `isActive`, `hasPermission` |
114
+
115
+ ## 文件组织
116
+
117
+ ```
118
+ src/
119
+ ├── modules/
120
+ │ └── {module-name}/
121
+ │ ├── {module}.module.ts # 模块入口
122
+ │ ├── {module}.controller.ts # 路由处理
123
+ │ ├── {module}.service.ts # 业务逻辑
124
+ │ ├── {module}.schema.ts # Zod 校验
125
+ │ ├── dto/ # 数据传输对象
126
+ │ └── entities/ # 实体定义
127
+ ├── shared/ # 跨模块共享代码
128
+ │ ├── utils/
129
+ │ ├── types/
130
+ │ └── constants/
131
+ └── config/ # 配置
132
+ ```
133
+
134
+ ## 日志
135
+
136
+ - **禁止**在生产代码中使用 `console.log`
137
+ - 使用结构化日志库(如 winston / pino)
138
+ - 日志级别:error > warn > info > debug
139
+
140
+ ## 注释规范
141
+
142
+ ```typescript
143
+ /**
144
+ * 根据用户 ID 获取用户信息。
145
+ *
146
+ * @param userId - 用户唯一标识符
147
+ * @returns 用户对象,不存在时返回 null
148
+ * @throws {ValidationError} 当 userId 格式无效时抛出
149
+ */
150
+ async function getUserById(userId: string): Promise<User | null> {
151
+ // ...
152
+ }
153
+
154
+ // TODO(victor): 这里的缓存策略需要优化 — 后续改为 Redis
155
+ const CACHE_TTL = 3600;
156
+ ```
@@ -1,25 +1,41 @@
1
- # Development Workflow(9 环节完整流程)
1
+ # 开发工作流(9 步完整流程)
2
2
 
3
3
  > 每个环节都必须执行(除非标注了跳过条件)。
4
- > 完成标志 = 该环节产出的可验证产物,没有产物 = 没做完。
4
+ > **完成标志 = 该环节产出的可验证产物**,没有产物 = 没做完。
5
5
 
6
- ## 完整链路
6
+ ## 完整链路(含命令对应)
7
7
 
8
8
  ```
9
- ① 需求澄清 ──── OpenSpec /opsx:propose
10
- ② 计划拆分 ──── gstack /plan-ceo-review /plan-eng-review(可选)
11
- ③ 研究复用
12
- ④ TodoList编写
13
- ⑤ TDD开发 ──── Superpowers 强制执行 TDD 纪律
14
- ⑥ 代码审查 ──── code-reviewer agent(自动)
15
- ⑦ 安全审查 ──── gstack /cso(可选)+ security-reviewer(自动)
16
- ⑧ 文档反写
17
- ⑨ 提交归档 ──── gstack /ship(跑测试+生成PR)→ OpenSpec /opsx:archive
9
+ ① 需求澄清 📋 /office-hours /opsx:propose → /brainstorm
10
+ ② 计划拆分 📐 /plan
11
+ ③ 研究复用 🔍 search-first skill
12
+ ④ TodoList 📝 手写 todolist.md
13
+ ⑤ TDD开发 🧪 /tdd 完成时 /verify
14
+ ⑥ 代码审查 🔎 /review
15
+ ⑦ 安全审查 🛡️ /cso
16
+ ⑧ 文档反写 📄 每 commit 后检查 (post-commit hook)
17
+ ⑨ 提交归档 🚀 /ship /opsx:archive
18
18
  ```
19
19
 
20
- > 工具说明详见 `CLAUDE.md` § AI 协作工具链
21
-
22
- ---
20
+ ## 命令速查
21
+
22
+ | 步骤 | 命令 | 用途 | 来源 |
23
+ |------|------|------|------|
24
+ | ①-a | `/office-hours` | 需求验证:值不值得做、最小切口 | gstack |
25
+ | ①-b | `/opsx:propose` | 需求规格化:proposal + design + tasks | OpenSpec |
26
+ | ①-c | `/brainstorm` | 方案探索:多方案对比、设计文档 | Superpowers |
27
+ | ② | `/plan` | 计划拆分:P0/P1 子任务、写入 todolist.md | — |
28
+ | ③ | (search-first skill) | 研究复用:GitHub/npm/Context7 搜索 | — |
29
+ | ④ | (手动) | TodoList 编写 | — |
30
+ | ⑤-a | `/tdd` | TDD 执行:RED→GREEN→REFACTOR | Superpowers |
31
+ | ⑤-b | `/verify` | 完成前验证:编译/测试/lint/安全扫描/diff | Superpowers |
32
+ | ⑥ | `/review` | 代码审查:SQL/信任边界/副作用/错误处理 | gstack |
33
+ | ⑦ | `/cso` | 安全审查:密钥/供应链/CI/CD/OWASP/STRIDE | gstack |
34
+ | ⑧ | (post-commit hook) | 文档反写提醒 | — |
35
+ | ⑨-a | `/ship` | 发布:merge→test→review→version→PR | gstack |
36
+ | ⑨-b | `/opsx:archive` | 归档:变更移至 archive/ | OpenSpec |
37
+
38
+ > 命令是独立的 markdown 文件,位于 `.claude/commands/` 目录,重启 Claude Code 后即可使用。
23
39
 
24
40
  ## 开发前必读文档
25
41
 
@@ -32,61 +48,92 @@
32
48
  | 5 | `docs/ui-ux-spec.md` | 页面线框图 + 组件规范(有前端时) |
33
49
  | 6 | 相邻已完成模块代码 | 复用实现模式 |
34
50
 
35
- 缺少信息?先补设计文档,再写代码。
51
+ 缺少信息?**先补设计文档,再写代码。**
36
52
 
37
53
  ---
38
54
 
39
55
  ## 各环节
40
56
 
41
57
  ### ① 需求澄清
42
- - 动作: 对照 PRD 确认功能边界和优先级
43
- - **新功能必须先用 OpenSpec**: `/opsx:propose 你的需求描述` → 生成结构化规格 + 任务清单
44
- - **复杂需求可选 gstack**: `/office-hours` 验证想法,`/plan-ceo-review` 挑战假设
45
- - ✅ 完成标志: OpenSpec 任务清单已生成 + 明确了做什么、不做什么、P0/P1 划分
46
- - 跳过条件: 纯技术任务(重构、升级依赖等)
58
+
59
+ ```
60
+ /office-hours 验证需求 /opsx:propose → 规格化 → /brainstorm → 方案设计
61
+ ```
62
+
63
+ - **动作**: 先验证需求合理性(/office-hours),再结构化规格(/opsx:propose),最后设计技术方案(/brainstorm)
64
+ - **新功能必须走完整三步**:验证 → 规格 → 方案
65
+ - **/office-hours**: 用六个强制性问题验证需求真伪——用户现在怎么解决的?痛点有多深?最小切口是什么?
66
+ - **/opsx:propose**: 产出 proposal.md(做什么+为什么)、design.md(怎么做)、tasks.md(任务清单)
67
+ - **/brainstorm**: 探索 2-3 种方案、选最佳路径、写设计文档
68
+ - ✅ **完成标志**: 设计文档已提交 + 明确了做什么/不做什么/P0P1 划分
69
+ - **跳过条件**: 纯技术任务(重构、升级依赖等),可直接从 /plan 开始
47
70
 
48
71
  ### ② 计划拆分
49
- - 动作: 拆分为可独立提交的子任务(每个 50-300 行)
50
- - 复杂功能使用 **planner** agent
51
- - **P0 优先策略**:新模块只先实现 P0,P1 完整列出放待开发区
52
- - ✅ 完成标志: 有明确的子任务列表,每个子任务对应一个 commit
53
- - 跳过条件: 单文件小修改(<50 行)
72
+
73
+ ```
74
+ /plan todolist.md
75
+ ```
76
+
77
+ - **动作**: 将设计文档拆分为可独立提交的子任务(每个 50-300 行)
78
+ - **P0 优先策略**: 新模块只先实现 P0,P1 完整列出放"后续"区
79
+ - **/plan** 命令自动生成 todolist.md,每个子任务对应一个独立 commit
80
+ - ✅ **完成标志**: todolist.md 已更新,每个子任务对应一个 commit
81
+ - **跳过条件**: 单文件小修改(<50 行)
54
82
 
55
83
  ### ③ 研究复用
56
- - 动作: GitHub code search → Context7 → npm → 相邻模块代码
57
- - 完成标志: 确认了实现模式(复用现有 or 新写)
58
- - 跳过条件: 已有明确模式可复用
84
+ - **动作**: GitHub code search → npm → 项目内相邻模块代码
85
+ - **search-first skill** 提供结构化搜索流程:并行搜索 评估(复用/扩展/组合/自建)→ 决定
86
+ - **完成标志**: 确认了实现模式(复用现有 or 新写)
87
+ - **跳过条件**: 已有明确模式可复用
59
88
 
60
89
  ### ④ TodoList 编写
61
- - 动作: 将子任务写入 `todolist.md`
62
- - 粒度: 一个子任务 = 一个可独立 commit 的变更
63
- - ✅ 完成标志: `todolist.md` 已更新,包含所有 P0 + P1 任务
90
+ - **动作**: 将子任务写入 `todolist.md`(若 /plan 已生成则确认)
91
+ - **粒度**: 一个子任务 = 一个可独立 commit 的变更
92
+ - ✅ **完成标志**: `todolist.md` 已更新,包含所有 P0 + P1 任务
64
93
  - **不可跳过**
65
94
 
66
95
  ### ⑤ TDD 开发
67
- - 动作: RED → GREEN → REFACTOR,覆盖率 ≥80%
68
- - **Superpowers 强制执行**: `tdd-workflow` skill 确保先写测试再写代码,禁止跳过
69
- - **按 OpenSpec 任务清单逐项实现**,每完成一项标记 done
70
- - ✅ 完成标志: 测试通过 + 编译通过
96
+
97
+ ```
98
+ /tdd (循环) 所有任务完成 → /verify (一次性)
99
+ ```
100
+
101
+ - **动作**: RED → GREEN → REFACTOR,覆盖率 ≥80%
102
+ - **/tdd** 命令强制执行 TDD 纪律:先写失败测试 → 最简实现 → 重构
103
+ - **按任务清单逐项实现**,每完成一项标记 done
104
+ - **所有 P0 任务完成后**,运行 `/verify`:编译→类型检查→Lint→测试→安全扫描→Diff 审查
105
+ - ✅ **完成标志**: /verify 全部通过 + 覆盖率 ≥80%
71
106
  - **不可跳过**
107
+ > 完整 TDD 工作流(含测试文件组织 / 命名规范 / 反模式)见 `.claude/rules/testing.md`
72
108
 
73
109
  ### ⑥ 代码审查
74
- - 动作: 使用 **code-reviewer** agent
75
- - ✅ 完成标志: CRITICAL/HIGH 问题已修复
110
+
111
+ ```
112
+ /review
113
+ ```
114
+
115
+ - **动作**: 运行 `/review`,检查 5 维度——SQL 安全性、LLM 信任边界、条件副作用、错误处理、安全
116
+ - **问题分级**: CRITICAL(必须修)> HIGH(应该修)> MEDIUM(可修)> LOW(风格偏好)
117
+ - ✅ **完成标志**: 无 CRITICAL/HIGH 问题
76
118
  - **不可跳过**(纯文档/配置变更除外)
77
119
 
78
120
  ### ⑦ 安全审查
79
- - 动作: 使用 **security-reviewer** agent
80
- - ✅ 完成标志: 无 CRITICAL 安全问题
81
- - 触发: 仅 auth / finance / system 模块
82
- - 跳过条件: 非安全敏感模块
83
121
 
84
- ### ⑧ 文档反写(每个 commit 后立即执行,不可跳过)
122
+ ```
123
+ /cso
124
+ ```
85
125
 
86
- > 这是最容易遗漏的环节。代码改了但文档没同步 = 技术债。
87
- > 小功能/临时需求可能不在 PRD 中,反写是唯一让文档跟上代码的机会。
126
+ - **动作**: 运行 `/cso`,5 阶段审计——密钥考古 → 依赖供应链 → CI/CD 管道 → OWASP Top 10 → STRIDE 威胁建模
127
+ - **两种模式**: 日常(零噪音,高置信度门槛)和全面(月度深度扫描)
128
+ - ✅ **完成标志**: 无 CRITICAL 安全问题
129
+ - **触发条件**: 仅 auth / finance / system 模块
130
+ - **跳过条件**: 非安全敏感模块
88
131
 
89
- **逐条检查,改了哪个就同步哪个:**
132
+ ### ⑧ 文档反写(**每个 commit 后立即执行,不可跳过**)
133
+
134
+ > 这是最容易遗漏的环节。**代码改了但文档没同步 = 技术债。**
135
+
136
+ post-commit hook 会在每次 commit 后自动提醒检查以下对应关系:
90
137
 
91
138
  | 改了什么 | 必须同步到 |
92
139
  |----------|-----------|
@@ -101,13 +148,19 @@
101
148
  | 完成了 todolist 中的子任务 | `todolist.md` 删除/勾选 |
102
149
  | 模块完成/里程碑 | `memory/MEMORY.md` |
103
150
 
104
- 完成标志: `git diff` 中包含对应的文档文件变更
151
+ **完成标志**: `git diff` 中包含对应的文档文件变更
105
152
 
106
153
  ### ⑨ 提交归档
107
- - 动作: `/ship` → 自动跑全量测试 + 检查覆盖率 + 生成 PR 描述 + push + 创建 PR
108
- - PR merge 后执行 `/opsx:archive` 将变更移至 archive
154
+
155
+ ```
156
+ /ship → PR 合并后 → /opsx:archive
157
+ ```
158
+
159
+ - **/ship 命令自动执行**: merge base → `/verify` → `/review` → bump version → update changelog → commit → push → create PR
160
+ - **如果 verify 失败或 review 发现 CRITICAL 问题,/ship 自动中止**
161
+ - PR 合并后运行 `/opsx:archive` 将变更移至 `openspec/changes/archive/YYYY-MM-DD-<name>/`
109
162
  - 小改动(<50行)可直接 `git commit`(遵循 `git-workflow.md` 格式和粒度规范)
110
- - ✅ 完成标志: PR 已创建(或 commit 成功)+ OpenSpec 已归档
163
+ - ✅ **完成标志**: PR 已创建(或 commit 成功)+ 变更已归档
111
164
  - **不可跳过**
112
165
 
113
166
  ---
@@ -1,47 +1,103 @@
1
- # Git Workflow
2
-
3
- ## Commit Message Format
4
- ```
5
- <type>: <description>
6
-
7
- <optional body>
8
- ```
9
-
10
- Types: feat, fix, refactor, docs, test, chore, perf, ci
11
-
12
- ## Commit 粒度规范
13
-
14
- 一个 commit = todolist.md 中的一个子任务,满足:
15
- - 代码可编译通过
16
- - 相关测试通过
17
- - 变更文件 1-8 个,行数 50-300
18
- - 超过 500 行应继续拆分
19
-
20
- ### 典型 commit 序列(后端模块)
21
-
22
- ```
23
- feat: 添加{模块}Zod schema # shared schema
24
- feat: 实现 {Module}Service # service 层
25
- test: 添加 {Module}Service 单元测试 # 测试
26
- feat: 实现 {Module}Controller # controller
27
- feat: 注册 {Module}Module # module
28
- docs: 同步{模块}治理文档 # 文档反写
29
- ```
30
-
31
- ### 典型 commit 序列(前端页面)
32
-
33
- ```
34
- feat: 实现{模块}列表页 # 列表
35
- feat: 实现{模块}详情页 # 详情
36
- feat: 实现{模块}表单 # 表单
37
- docs: 同步{模块}治理文档 # 文档反写
38
- ```
39
-
40
- ## Pull Request Workflow
41
-
42
- When creating PRs:
43
- 1. Analyze full commit history (not just latest commit)
44
- 2. Use `git diff [base-branch]...HEAD` to see all changes
45
- 3. Draft comprehensive PR summary
46
- 4. Include test plan with TODOs
47
- 5. Push with `-u` flag if new branch
1
+ # Git 工作流规范(Git Workflow
2
+
3
+ ## Commit Message 格式
4
+
5
+ ```
6
+ <type>(<scope>): <subject>
7
+
8
+ <body>
9
+ ```
10
+
11
+ ### Type 类型
12
+
13
+ | Type | 说明 |
14
+ |------|------|
15
+ | `feat` | 新功能 (feature) |
16
+ | `fix` | Bug 修复 (bugfix) |
17
+ | `refactor` | 重构(不增加功能、不修复 bug) |
18
+ | `docs` | 文档变更 |
19
+ | `test` | 测试相关变更 |
20
+ | `chore` | 构建过程/辅助工具变动 |
21
+ | `perf` | 性能优化 |
22
+ | `ci` | CI/CD 配置变更 |
23
+
24
+ ### 格式要求
25
+
26
+ - **subject**:不超过 50 字符,使用中文或英文,不要结尾加句号
27
+ - **body**:解释 what 和 why(不是 how),每行不超过 72 字符
28
+ - 使用祈使语气("添加" 而不是 "添加了")
29
+
30
+ ```bash
31
+ # 好的提交信息
32
+ feat(user): 添加用户注册接口
33
+
34
+ - 支持 email + 用户名两种注册方式
35
+ - 注册后自动发送验证邮件
36
+ - 包含 Zod schema 校验
37
+
38
+ # ❌ 不好的提交信息
39
+ fix: 修了个bug
40
+ 随便改了点东西
41
+ ```
42
+
43
+ ## Commit 粒度规范
44
+
45
+ > 一个 commit = todolist.md 中的一个子任务
46
+
47
+ 每个 commit 应满足:
48
+ - 代码可编译通过
49
+ - 相关测试通过
50
+ - 变更文件数:1-8 个
51
+ - 代码行数:50-300 行
52
+ - ⚠️ **超过 500 行应继续拆分**
53
+
54
+ ### 典型 commit 序列 — 后端模块
55
+
56
+ ```
57
+ feat: 添加{模块}Zod schema # 共享校验层
58
+ feat: 实现 {Module}Service # 业务逻辑层
59
+ test: 添加 {Module}Service 单元测试 # 测试覆盖
60
+ feat: 实现 {Module}Controller # API 控制器
61
+ feat: 注册 {Module}Module # 模块注册
62
+ docs: 同步{模块}设计文档 # 文档反写
63
+ ```
64
+
65
+ ### 典型 commit 序列 — 前端页面
66
+
67
+ ```
68
+ feat: 实现{模块}列表页 # 列表视图
69
+ feat: 实现{模块}详情页 # 详情视图
70
+ feat: 实现{模块}表单 # 创建/编辑表单
71
+ docs: 同步{模块}设计文档 # 文档反写
72
+ ```
73
+
74
+ ## 分支策略
75
+
76
+ ```
77
+ main ──────────────────────────────── 生产环境
78
+ ├── develop ────────────────────── 开发集成分支
79
+ │ ├── feature/user-register 功能分支
80
+ │ └── feature/payment-integrate
81
+ └── hotfix/critical-fix-001 紧急修复分支(直接合并 main)
82
+ ```
83
+
84
+ - `feature/*` — 新功能开发,从 develop 创建,完成后 PR 回 develop
85
+ - `hotfix/*` — 紧急线上修复,从 main 创建,完成后 PR 回 main + cherry-pick 到 develop
86
+ - PR 标题格式与 commit message 一致
87
+
88
+ ## Pull Request 工作流
89
+
90
+ 创建 PR 时:
91
+ 1. 分析**完整提交历史**(不只是最新一个 commit)
92
+ 2. 使用 `git diff [base-branch]...HEAD` 查看所有变更
93
+ 3. 编写全面的 PR 摘要(包括做了什么、为什么、怎么验证)
94
+ 4. 包含带 TODO 的测试计划
95
+ 5. 新分支首次推送时使用 `-u` 标志
96
+
97
+ ## Git Hooks 配置建议
98
+
99
+ | Hook | 用途 | 建议工具 |
100
+ |------|------|----------|
101
+ | pre-commit | lint + format | Husky + lint-staged / simple-git-hooks |
102
+ | commit-msg | message 格式校验 | commitlint |
103
+ | pre-push | 全量测试通过 | vitest / npm test |