specops 0.2.4 → 0.3.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 (160) hide show
  1. package/.opencode/agent/specops-codebase-mapper.md +764 -0
  2. package/.opencode/agent/specops-debugger.md +1246 -0
  3. package/.opencode/agent/specops-executor.md +469 -0
  4. package/.opencode/agent/specops-integration-checker.md +443 -0
  5. package/.opencode/agent/specops-phase-researcher.md +547 -0
  6. package/.opencode/agent/specops-plan-checker.md +690 -0
  7. package/.opencode/agent/specops-planner.md +575 -0
  8. package/.opencode/agent/specops-project-researcher.md +354 -0
  9. package/.opencode/agent/specops-research-synthesizer.md +239 -0
  10. package/.opencode/agent/specops-roadmapper.md +642 -0
  11. package/.opencode/agent/specops-work-verifier.md +573 -0
  12. package/.opencode/references/checkpoints.md +776 -0
  13. package/.opencode/references/continuation-format.md +249 -0
  14. package/.opencode/references/decimal-phase-calculation.md +65 -0
  15. package/.opencode/references/git-integration.md +248 -0
  16. package/.opencode/references/git-planning-commit.md +38 -0
  17. package/.opencode/references/model-profile-resolution.md +34 -0
  18. package/.opencode/references/model-profiles.md +92 -0
  19. package/.opencode/references/phase-argument-parsing.md +61 -0
  20. package/.opencode/references/planning-config.md +196 -0
  21. package/.opencode/references/questioning.md +145 -0
  22. package/.opencode/references/tdd.md +263 -0
  23. package/.opencode/references/ui-brand.md +160 -0
  24. package/.opencode/references/verification-patterns.md +612 -0
  25. package/.opencode/skills/demand-analysis/SKILL.md +142 -10
  26. package/.opencode/templates/DEBUG.md +164 -0
  27. package/.opencode/templates/UAT.md +180 -0
  28. package/.opencode/templates/VALIDATION.md +76 -0
  29. package/.opencode/templates/codebase/architecture.md +255 -0
  30. package/.opencode/templates/codebase/concerns.md +310 -0
  31. package/.opencode/templates/codebase/conventions.md +307 -0
  32. package/.opencode/templates/codebase/integrations.md +280 -0
  33. package/.opencode/templates/codebase/stack.md +186 -0
  34. package/.opencode/templates/codebase/structure.md +285 -0
  35. package/.opencode/templates/codebase/testing.md +480 -0
  36. package/.opencode/templates/context.md +221 -0
  37. package/.opencode/templates/continue-here.md +78 -0
  38. package/.opencode/templates/debug-subagent-prompt.md +91 -0
  39. package/.opencode/templates/discovery.md +147 -0
  40. package/.opencode/templates/milestone-archive.md +123 -0
  41. package/.opencode/templates/milestone.md +115 -0
  42. package/.opencode/templates/phase-prompt.md +333 -0
  43. package/.opencode/templates/planner-subagent-prompt.md +117 -0
  44. package/.opencode/templates/project.md +184 -0
  45. package/.opencode/templates/requirements.md +130 -0
  46. package/.opencode/templates/research-project/ARCHITECTURE.md +204 -0
  47. package/.opencode/templates/research-project/FEATURES.md +147 -0
  48. package/.opencode/templates/research-project/PITFALLS.md +200 -0
  49. package/.opencode/templates/research-project/STACK.md +120 -0
  50. package/.opencode/templates/research-project/SUMMARY.md +170 -0
  51. package/.opencode/templates/research.md +278 -0
  52. package/.opencode/templates/retrospective.md +54 -0
  53. package/.opencode/templates/roadmap.md +202 -0
  54. package/.opencode/templates/state.md +176 -0
  55. package/.opencode/templates/summary-complex.md +59 -0
  56. package/.opencode/templates/summary-minimal.md +41 -0
  57. package/.opencode/templates/summary-standard.md +48 -0
  58. package/.opencode/templates/summary.md +248 -0
  59. package/.opencode/templates/user-setup.md +311 -0
  60. package/.opencode/templates/verification-report.md +322 -0
  61. package/.opencode/workflows/add-phase.md +111 -0
  62. package/.opencode/workflows/add-tests.md +350 -0
  63. package/.opencode/workflows/add-todo.md +157 -0
  64. package/.opencode/workflows/audit-milestone.md +297 -0
  65. package/.opencode/workflows/check-todos.md +176 -0
  66. package/.opencode/workflows/cleanup.md +152 -0
  67. package/.opencode/workflows/complete-milestone.md +763 -0
  68. package/.opencode/workflows/diagnose-issues.md +219 -0
  69. package/.opencode/workflows/discovery-phase.md +288 -0
  70. package/.opencode/workflows/discuss-phase.md +542 -0
  71. package/.opencode/workflows/execute-phase.md +449 -0
  72. package/.opencode/workflows/execute-plan.md +447 -0
  73. package/.opencode/workflows/health.md +156 -0
  74. package/.opencode/workflows/help.md +489 -0
  75. package/.opencode/workflows/insert-phase.md +129 -0
  76. package/.opencode/workflows/list-phase-assumptions.md +178 -0
  77. package/.opencode/workflows/map-codebase.md +315 -0
  78. package/.opencode/workflows/new-milestone.md +382 -0
  79. package/.opencode/workflows/new-project.md +1116 -0
  80. package/.opencode/workflows/pause-work.md +122 -0
  81. package/.opencode/workflows/plan-milestone-gaps.md +274 -0
  82. package/.opencode/workflows/plan-phase.md +569 -0
  83. package/.opencode/workflows/progress.md +381 -0
  84. package/.opencode/workflows/quick.md +453 -0
  85. package/.opencode/workflows/remove-phase.md +154 -0
  86. package/.opencode/workflows/research-phase.md +73 -0
  87. package/.opencode/workflows/resume-project.md +304 -0
  88. package/.opencode/workflows/set-profile.md +80 -0
  89. package/.opencode/workflows/settings.md +213 -0
  90. package/.opencode/workflows/transition.md +544 -0
  91. package/.opencode/workflows/update.md +219 -0
  92. package/.opencode/workflows/verify-phase.md +242 -0
  93. package/.opencode/workflows/verify-work.md +569 -0
  94. package/commands/specops/add-phase.md +43 -0
  95. package/commands/specops/add-tests.md +41 -0
  96. package/commands/specops/add-todo.md +47 -0
  97. package/commands/specops/audit-milestone.md +36 -0
  98. package/commands/specops/check-todos.md +45 -0
  99. package/commands/specops/cleanup.md +18 -0
  100. package/commands/specops/complete-milestone.md +136 -0
  101. package/commands/specops/debug.md +167 -0
  102. package/commands/specops/discuss-phase.md +83 -0
  103. package/commands/specops/execute-phase.md +41 -0
  104. package/commands/specops/health.md +22 -0
  105. package/commands/specops/help.md +22 -0
  106. package/commands/specops/insert-phase.md +32 -0
  107. package/commands/specops/join-discord.md +18 -0
  108. package/commands/specops/list-phase-assumptions.md +46 -0
  109. package/commands/specops/map-codebase.md +71 -0
  110. package/commands/specops/new-milestone.md +44 -0
  111. package/commands/specops/new-project.md +42 -0
  112. package/commands/specops/pause-work.md +38 -0
  113. package/commands/specops/plan-milestone-gaps.md +34 -0
  114. package/commands/specops/plan-phase.md +45 -0
  115. package/commands/specops/progress.md +24 -0
  116. package/commands/specops/quick.md +41 -0
  117. package/commands/specops/reapply-patches.md +111 -0
  118. package/commands/specops/remove-phase.md +31 -0
  119. package/commands/specops/research-phase.md +189 -0
  120. package/commands/specops/resume-work.md +40 -0
  121. package/commands/specops/set-profile.md +34 -0
  122. package/commands/specops/settings.md +36 -0
  123. package/commands/specops/update.md +37 -0
  124. package/commands/specops/verify-work.md +38 -0
  125. package/dist/__e2e__/01-state-engine.e2e.test.js +1 -1
  126. package/dist/acceptance/lazyDetector.js +1 -1
  127. package/dist/acceptance/lazyDetector.test.js +1 -1
  128. package/dist/acceptance/reporter.js +1 -1
  129. package/dist/acceptance/reporter.test.js +1 -1
  130. package/dist/acceptance/runner.js +1 -1
  131. package/dist/acceptance/runner.test.js +1 -1
  132. package/dist/cli.js +1 -1
  133. package/dist/context/index.js +1 -1
  134. package/dist/context/promptTemplate.js +1 -1
  135. package/dist/context/promptTemplate.test.js +1 -1
  136. package/dist/context/techContextLoader.js +1 -1
  137. package/dist/context/techContextLoader.test.js +1 -1
  138. package/dist/engine.js +1 -1
  139. package/dist/evolution/distiller.js +1 -1
  140. package/dist/evolution/index.js +1 -1
  141. package/dist/evolution/memoryGraph.js +1 -1
  142. package/dist/evolution/selector.js +1 -1
  143. package/dist/evolution/signals.js +1 -1
  144. package/dist/evolution/solidify.js +1 -1
  145. package/dist/evolution/store.js +1 -1
  146. package/dist/evolution/types.js +1 -1
  147. package/dist/init.d.ts +4 -3
  148. package/dist/init.js +1 -1
  149. package/dist/machines/agentMachine.js +1 -1
  150. package/dist/machines/agentMachine.test.js +1 -1
  151. package/dist/machines/supervisorMachine.js +1 -1
  152. package/dist/machines/supervisorMachine.test.js +1 -1
  153. package/dist/persistence/schema.js +1 -1
  154. package/dist/persistence/stateFile.js +1 -1
  155. package/dist/persistence/stateFile.test.js +1 -1
  156. package/dist/plugin-engine.js +1 -1
  157. package/dist/plugin.js +1 -1
  158. package/dist/types/index.js +1 -1
  159. package/dist/utils/id.js +1 -1
  160. package/package.json +2 -1
@@ -0,0 +1,776 @@
1
+ <overview>
2
+ 计划自主执行。检查点将需要人工验证或决策的交互点正式化。
3
+
4
+ **核心原则:** Claude 用 CLI/API 自动化一切。检查点用于验证和决策,而非手动工作。
5
+
6
+ **黄金规则:**
7
+ 1. **如果 Claude 能运行,Claude 就运行** - 永远不要让用户执行 CLI 命令、启动服务器或运行构建
8
+ 2. **Claude 设置验证环境** - 启动开发服务器、填充数据库、配置环境变量
9
+ 3. **用户只做需要人类判断的事** - 视觉检查、UX 评估、「这感觉对吗?」
10
+ 4. **密钥来自用户,自动化来自 Claude** - 询问 API 密钥,然后 Claude 通过 CLI 使用它们
11
+ 5. **自动模式跳过验证/决策检查点** — 当配置中 `workflow.auto_advance` 为 true 时:human-verify 自动批准,decision 自动选择第一个选项,human-action 仍然停止(认证门控不能自动化)
12
+ </overview>
13
+
14
+ <checkpoint_types>
15
+
16
+ <type name="human-verify">
17
+ ## checkpoint:human-verify(最常见 - 90%)
18
+
19
+ **何时:** Claude 完成了自动化工作,人工确认其正确工作。
20
+
21
+ **用于:**
22
+ - 视觉 UI 检查(布局、样式、响应式)
23
+ - 交互流程(点击向导、测试用户流程)
24
+ - 功能验证(特性按预期工作)
25
+ - 音频/视频播放质量
26
+ - 动画流畅度
27
+ - 无障碍测试
28
+
29
+ **结构:**
30
+ ```xml
31
+ <task type="checkpoint:human-verify" gate="blocking">
32
+ <what-built>[Claude 自动化并部署/构建了什么]</what-built>
33
+ <how-to-verify>
34
+ [精确的测试步骤 - URL、命令、预期行为]
35
+ </how-to-verify>
36
+ <resume-signal>[如何继续 - "approved"、"yes" 或描述问题]</resume-signal>
37
+ </task>
38
+ ```
39
+
40
+ **示例:UI 组件(展示关键模式:Claude 在检查点之前启动服务器)**
41
+ ```xml
42
+ <task type="auto">
43
+ <name>Build responsive dashboard layout</name>
44
+ <files>src/components/Dashboard.tsx, src/app/dashboard/page.tsx</files>
45
+ <action>Create dashboard with sidebar, header, and content area. Use Tailwind responsive classes for mobile.</action>
46
+ <verify>npm run build succeeds, no TypeScript errors</verify>
47
+ <done>Dashboard component builds without errors</done>
48
+ </task>
49
+
50
+ <task type="auto">
51
+ <name>Start dev server for verification</name>
52
+ <action>Run `npm run dev` in background, wait for "ready" message, capture port</action>
53
+ <verify>curl http://localhost:3000 returns 200</verify>
54
+ <done>Dev server running at http://localhost:3000</done>
55
+ </task>
56
+
57
+ <task type="checkpoint:human-verify" gate="blocking">
58
+ <what-built>Responsive dashboard layout - dev server running at http://localhost:3000</what-built>
59
+ <how-to-verify>
60
+ Visit http://localhost:3000/dashboard and verify:
61
+ 1. Desktop (>1024px): Sidebar left, content right, header top
62
+ 2. Tablet (768px): Sidebar collapses to hamburger menu
63
+ 3. Mobile (375px): Single column layout, bottom nav appears
64
+ 4. No layout shift or horizontal scroll at any size
65
+ </how-to-verify>
66
+ <resume-signal>Type "approved" or describe layout issues</resume-signal>
67
+ </task>
68
+ ```
69
+
70
+ **示例:Xcode 构建**
71
+ ```xml
72
+ <task type="auto">
73
+ <name>Build macOS app with Xcode</name>
74
+ <files>App.xcodeproj, Sources/</files>
75
+ <action>Run `xcodebuild -project App.xcodeproj -scheme App build`. Check for compilation errors in output.</action>
76
+ <verify>Build output contains "BUILD SUCCEEDED", no errors</verify>
77
+ <done>App builds successfully</done>
78
+ </task>
79
+
80
+ <task type="checkpoint:human-verify" gate="blocking">
81
+ <what-built>Built macOS app at DerivedData/Build/Products/Debug/App.app</what-built>
82
+ <how-to-verify>
83
+ Open App.app and test:
84
+ - App launches without crashes
85
+ - Menu bar icon appears
86
+ - Preferences window opens correctly
87
+ - No visual glitches or layout issues
88
+ </how-to-verify>
89
+ <resume-signal>Type "approved" or describe issues</resume-signal>
90
+ </task>
91
+ ```
92
+ </type>
93
+
94
+ <type name="decision">
95
+ ## checkpoint:decision(9%)
96
+
97
+ **何时:** 人工必须做出影响实现方向的选择。
98
+
99
+ **用于:**
100
+ - 技术选型(哪个认证提供商、哪个数据库)
101
+ - 架构决策(monorepo vs 独立仓库)
102
+ - 设计选择(配色方案、布局方式)
103
+ - 特性优先级(构建哪个变体)
104
+ - 数据模型决策(schema 结构)
105
+
106
+ **结构:**
107
+ ```xml
108
+ <task type="checkpoint:decision" gate="blocking">
109
+ <decision>[正在决定什么]</decision>
110
+ <context>[为什么这个决策重要]</context>
111
+ <options>
112
+ <option id="option-a">
113
+ <name>[选项名称]</name>
114
+ <pros>[优点]</pros>
115
+ <cons>[权衡]</cons>
116
+ </option>
117
+ <option id="option-b">
118
+ <name>[选项名称]</name>
119
+ <pros>[优点]</pros>
120
+ <cons>[权衡]</cons>
121
+ </option>
122
+ </options>
123
+ <resume-signal>[如何表示选择]</resume-signal>
124
+ </task>
125
+ ```
126
+
127
+ **示例:认证提供商选择**
128
+ ```xml
129
+ <task type="checkpoint:decision" gate="blocking">
130
+ <decision>Select authentication provider</decision>
131
+ <context>
132
+ Need user authentication for the app. Three solid options with different tradeoffs.
133
+ </context>
134
+ <options>
135
+ <option id="supabase">
136
+ <name>Supabase Auth</name>
137
+ <pros>Built-in with Supabase DB we're using, generous free tier, row-level security integration</pros>
138
+ <cons>Less customizable UI, tied to Supabase ecosystem</cons>
139
+ </option>
140
+ <option id="clerk">
141
+ <name>Clerk</name>
142
+ <pros>Beautiful pre-built UI, best developer experience, excellent docs</pros>
143
+ <cons>Paid after 10k MAU, vendor lock-in</cons>
144
+ </option>
145
+ <option id="nextauth">
146
+ <name>NextAuth.js</name>
147
+ <pros>Free, self-hosted, maximum control, widely adopted</pros>
148
+ <cons>More setup work, you manage security updates, UI is DIY</cons>
149
+ </option>
150
+ </options>
151
+ <resume-signal>Select: supabase, clerk, or nextauth</resume-signal>
152
+ </task>
153
+ ```
154
+
155
+ **示例:数据库选择**
156
+ ```xml
157
+ <task type="checkpoint:decision" gate="blocking">
158
+ <decision>Select database for user data</decision>
159
+ <context>
160
+ App needs persistent storage for users, sessions, and user-generated content.
161
+ Expected scale: 10k users, 1M records first year.
162
+ </context>
163
+ <options>
164
+ <option id="supabase">
165
+ <name>Supabase (Postgres)</name>
166
+ <pros>Full SQL, generous free tier, built-in auth, real-time subscriptions</pros>
167
+ <cons>Vendor lock-in for real-time features, less flexible than raw Postgres</cons>
168
+ </option>
169
+ <option id="planetscale">
170
+ <name>PlanetScale (MySQL)</name>
171
+ <pros>Serverless scaling, branching workflow, excellent DX</pros>
172
+ <cons>MySQL not Postgres, no foreign keys in free tier</cons>
173
+ </option>
174
+ <option id="convex">
175
+ <name>Convex</name>
176
+ <pros>Real-time by default, TypeScript-native, automatic caching</pros>
177
+ <cons>Newer platform, different mental model, less SQL flexibility</cons>
178
+ </option>
179
+ </options>
180
+ <resume-signal>Select: supabase, planetscale, or convex</resume-signal>
181
+ </task>
182
+ ```
183
+ </type>
184
+
185
+ <type name="human-action">
186
+ ## checkpoint:human-action(1% - 罕见)
187
+
188
+ **何时:** 操作没有 CLI/API 且需要人工交互,或 Claude 在自动化过程中遇到认证门控。
189
+
190
+ **仅用于:**
191
+ - **认证门控** - Claude 尝试了 CLI/API 但需要凭据(这不是失败)
192
+ - 邮件验证链接(点击邮件)
193
+ - 短信 2FA 验证码(手机验证)
194
+ - 手动账户审批(平台需要人工审核)
195
+ - 信用卡 3D Secure 流程(基于 Web 的支付授权)
196
+ - OAuth 应用审批(基于 Web 的审批)
197
+
198
+ **不要用于预先计划的手动工作:**
199
+ - 部署(使用 CLI - 需要时设认证门控)
200
+ - 创建 webhook/数据库(使用 API/CLI - 需要时设认证门控)
201
+ - 运行构建/测试(使用 Bash 工具)
202
+ - 创建文件(使用 Write 工具)
203
+
204
+ **结构:**
205
+ ```xml
206
+ <task type="checkpoint:human-action" gate="blocking">
207
+ <action>[人工必须做什么 - Claude 已经做了所有可自动化的]</action>
208
+ <instructions>
209
+ [Claude 已经自动化了什么]
210
+ [需要人工操作的那一件事]
211
+ </instructions>
212
+ <verification>[Claude 之后可以检查什么]</verification>
213
+ <resume-signal>[如何继续]</resume-signal>
214
+ </task>
215
+ ```
216
+
217
+ **示例:邮件验证**
218
+ ```xml
219
+ <task type="auto">
220
+ <name>Create SendGrid account via API</name>
221
+ <action>Use SendGrid API to create subuser account with provided email. Request verification email.</action>
222
+ <verify>API returns 201, account created</verify>
223
+ <done>Account created, verification email sent</done>
224
+ </task>
225
+
226
+ <task type="checkpoint:human-action" gate="blocking">
227
+ <action>Complete email verification for SendGrid account</action>
228
+ <instructions>
229
+ I created the account and requested verification email.
230
+ Check your inbox for SendGrid verification link and click it.
231
+ </instructions>
232
+ <verification>SendGrid API key works: curl test succeeds</verification>
233
+ <resume-signal>Type "done" when email verified</resume-signal>
234
+ </task>
235
+ ```
236
+
237
+ **示例:认证门控(动态检查点)**
238
+ ```xml
239
+ <task type="auto">
240
+ <name>Deploy to Vercel</name>
241
+ <files>.vercel/, vercel.json</files>
242
+ <action>Run `vercel --yes` to deploy</action>
243
+ <verify>vercel ls shows deployment, curl returns 200</verify>
244
+ </task>
245
+
246
+ <!-- 如果 vercel 返回 "Error: Not authenticated",Claude 动态创建检查点 -->
247
+
248
+ <task type="checkpoint:human-action" gate="blocking">
249
+ <action>Authenticate Vercel CLI so I can continue deployment</action>
250
+ <instructions>
251
+ I tried to deploy but got authentication error.
252
+ Run: vercel login
253
+ This will open your browser - complete the authentication flow.
254
+ </instructions>
255
+ <verification>vercel whoami returns your account email</verification>
256
+ <resume-signal>Type "done" when authenticated</resume-signal>
257
+ </task>
258
+
259
+ <!-- 认证后,Claude 重试部署 -->
260
+
261
+ <task type="auto">
262
+ <name>Retry Vercel deployment</name>
263
+ <action>Run `vercel --yes` (now authenticated)</action>
264
+ <verify>vercel ls shows deployment, curl returns 200</verify>
265
+ </task>
266
+ ```
267
+
268
+ **关键区别:** 认证门控是 Claude 遇到认证错误时动态创建的。不是预先计划的,Claude 先自动化,只在被阻塞时才请求凭据。
269
+ </type>
270
+ </checkpoint_types>
271
+
272
+ <execution_protocol>
273
+
274
+ 当 Claude 遇到 `type="checkpoint:*"` 时:
275
+
276
+ 1. **立即停止** - 不要继续下一个任务
277
+ 2. **清晰显示检查点** - 使用以下格式
278
+ 3. **等待用户响应** - 不要幻想完成
279
+ 4. **如果可能则验证** - 检查文件、运行测试等
280
+ 5. **恢复执行** - 仅在确认后继续下一个任务
281
+
282
+ **对于 checkpoint:human-verify:**
283
+ ```
284
+ ╔═══════════════════════════════════════════════════════╗
285
+ ║ CHECKPOINT: Verification Required ║
286
+ ╚═══════════════════════════════════════════════════════╝
287
+
288
+ Progress: 5/8 tasks complete
289
+ Task: Responsive dashboard layout
290
+
291
+ Built: Responsive dashboard at /dashboard
292
+
293
+ How to verify:
294
+ 1. Visit: http://localhost:3000/dashboard
295
+ 2. Desktop (>1024px): Sidebar visible, content fills remaining space
296
+ 3. Tablet (768px): Sidebar collapses to icons
297
+ 4. Mobile (375px): Sidebar hidden, hamburger menu appears
298
+
299
+ ────────────────────────────────────────────────────────
300
+ → YOUR ACTION: Type "approved" or describe issues
301
+ ────────────────────────────────────────────────────────
302
+ ```
303
+
304
+ **对于 checkpoint:decision:**
305
+ ```
306
+ ╔═══════════════════════════════════════════════════════╗
307
+ ║ CHECKPOINT: Decision Required ║
308
+ ╚═══════════════════════════════════════════════════════╝
309
+
310
+ Progress: 2/6 tasks complete
311
+ Task: Select authentication provider
312
+
313
+ Decision: Which auth provider should we use?
314
+
315
+ Context: Need user authentication. Three options with different tradeoffs.
316
+
317
+ Options:
318
+ 1. supabase - Built-in with our DB, free tier
319
+ Pros: Row-level security integration, generous free tier
320
+ Cons: Less customizable UI, ecosystem lock-in
321
+
322
+ 2. clerk - Best DX, paid after 10k users
323
+ Pros: Beautiful pre-built UI, excellent documentation
324
+ Cons: Vendor lock-in, pricing at scale
325
+
326
+ 3. nextauth - Self-hosted, maximum control
327
+ Pros: Free, no vendor lock-in, widely adopted
328
+ Cons: More setup work, DIY security updates
329
+
330
+ ────────────────────────────────────────────────────────
331
+ → YOUR ACTION: Select supabase, clerk, or nextauth
332
+ ────────────────────────────────────────────────────────
333
+ ```
334
+
335
+ **对于 checkpoint:human-action:**
336
+ ```
337
+ ╔═══════════════════════════════════════════════════════╗
338
+ ║ CHECKPOINT: Action Required ║
339
+ ╚═══════════════════════════════════════════════════════╝
340
+
341
+ Progress: 3/8 tasks complete
342
+ Task: Deploy to Vercel
343
+
344
+ Attempted: vercel --yes
345
+ Error: Not authenticated. Please run 'vercel login'
346
+
347
+ What you need to do:
348
+ 1. Run: vercel login
349
+ 2. Complete browser authentication when it opens
350
+ 3. Return here when done
351
+
352
+ I'll verify: vercel whoami returns your account
353
+
354
+ ────────────────────────────────────────────────────────
355
+ → YOUR ACTION: Type "done" when authenticated
356
+ ────────────────────────────────────────────────────────
357
+ ```
358
+ </execution_protocol>
359
+
360
+ <authentication_gates>
361
+
362
+ **认证门控 = Claude 尝试了 CLI/API,遇到认证错误。** 不是失败,而是需要人工输入来解除阻塞的门控。
363
+
364
+ **模式:** Claude 尝试自动化 -> 认证错误 -> 创建 checkpoint:human-action -> 用户认证 -> Claude 重试 -> 继续
365
+
366
+ **门控协议:**
367
+ 1. 认识到这不是失败 - 缺少认证是预期的
368
+ 2. 停止当前任务 - 不要反复重试
369
+ 3. 动态创建 checkpoint:human-action
370
+ 4. 提供精确的认证步骤
371
+ 5. 验证认证是否有效
372
+ 6. 重试原始任务
373
+ 7. 正常继续
374
+
375
+ **关键区别:**
376
+ - 预先计划的检查点:「我需要你做 X」(错误 - Claude 应该自动化)
377
+ - 认证门控:「我尝试自动化 X 但需要凭据」(正确 - 解除自动化阻塞)
378
+
379
+ </authentication_gates>
380
+
381
+ <automation_reference>
382
+
383
+ **规则:** 如果有 CLI/API,Claude 就做。永远不要让人工执行可自动化的工作。
384
+
385
+ ## 服务 CLI 参考
386
+
387
+ | 服务 | CLI/API | 关键命令 | 认证门控 |
388
+ |------|---------|----------|----------|
389
+ | Vercel | `vercel` | `--yes`, `env add`, `--prod`, `ls` | `vercel login` |
390
+ | Railway | `railway` | `init`, `up`, `variables set` | `railway login` |
391
+ | Fly | `fly` | `launch`, `deploy`, `secrets set` | `fly auth login` |
392
+ | Stripe | `stripe` + API | `listen`, `trigger`, API calls | API key in .env |
393
+ | Supabase | `supabase` | `init`, `link`, `db push`, `gen types` | `supabase login` |
394
+ | Upstash | `upstash` | `redis create`, `redis get` | `upstash auth login` |
395
+ | PlanetScale | `pscale` | `database create`, `branch create` | `pscale auth login` |
396
+ | GitHub | `gh` | `repo create`, `pr create`, `secret set` | `gh auth login` |
397
+ | Node | `npm`/`pnpm` | `install`, `run build`, `test`, `run dev` | N/A |
398
+ | Xcode | `xcodebuild` | `-project`, `-scheme`, `build`, `test` | N/A |
399
+ | Convex | `npx convex` | `dev`, `deploy`, `env set`, `env get` | `npx convex login` |
400
+
401
+ ## 环境变量自动化
402
+
403
+ **Env 文件:** 使用 Write/Edit 工具。永远不要让人工手动创建 .env。
404
+
405
+ **通过 CLI 设置平台环境变量:**
406
+
407
+ | 平台 | CLI 命令 | 示例 |
408
+ |------|----------|------|
409
+ | Convex | `npx convex env set` | `npx convex env set OPENAI_API_KEY sk-...` |
410
+ | Vercel | `vercel env add` | `vercel env add STRIPE_KEY production` |
411
+ | Railway | `railway variables set` | `railway variables set API_KEY=value` |
412
+ | Fly | `fly secrets set` | `fly secrets set DATABASE_URL=...` |
413
+ | Supabase | `supabase secrets set` | `supabase secrets set MY_SECRET=value` |
414
+
415
+ **密钥收集模式:**
416
+ ```xml
417
+ <!-- 错误:让用户在仪表板中添加环境变量 -->
418
+ <task type="checkpoint:human-action">
419
+ <action>Add OPENAI_API_KEY to Convex dashboard</action>
420
+ <instructions>Go to dashboard.convex.dev → Settings → Environment Variables → Add</instructions>
421
+ </task>
422
+
423
+ <!-- 正确:Claude 请求值,然后通过 CLI 添加 -->
424
+ <task type="checkpoint:human-action">
425
+ <action>Provide your OpenAI API key</action>
426
+ <instructions>
427
+ I need your OpenAI API key for Convex backend.
428
+ Get it from: https://platform.openai.com/api-keys
429
+ Paste the key (starts with sk-)
430
+ </instructions>
431
+ <verification>I'll add it via `npx convex env set` and verify</verification>
432
+ <resume-signal>Paste your API key</resume-signal>
433
+ </task>
434
+
435
+ <task type="auto">
436
+ <name>Configure OpenAI key in Convex</name>
437
+ <action>Run `npx convex env set OPENAI_API_KEY {user-provided-key}`</action>
438
+ <verify>`npx convex env get OPENAI_API_KEY` returns the key (masked)</verify>
439
+ </task>
440
+ ```
441
+
442
+ ## 开发服务器自动化
443
+
444
+ | 框架 | 启动命令 | 就绪信号 | 默认 URL |
445
+ |------|----------|----------|----------|
446
+ | Next.js | `npm run dev` | "Ready in" or "started server" | http://localhost:3000 |
447
+ | Vite | `npm run dev` | "ready in" | http://localhost:5173 |
448
+ | Convex | `npx convex dev` | "Convex functions ready" | N/A(仅后端) |
449
+ | Express | `npm start` | "listening on port" | http://localhost:3000 |
450
+ | Django | `python manage.py runserver` | "Starting development server" | http://localhost:8000 |
451
+
452
+ **服务器生命周期:**
453
+ ```bash
454
+ # 后台运行,捕获 PID
455
+ npm run dev &
456
+ DEV_SERVER_PID=$!
457
+
458
+ # 等待就绪(最多 30 秒)
459
+ timeout 30 bash -c 'until curl -s localhost:3000 > /dev/null 2>&1; do sleep 1; done'
460
+ ```
461
+
462
+ **端口冲突:** 杀死残留进程(`lsof -ti:3000 | xargs kill`)或使用备用端口(`--port 3001`)。
463
+
464
+ **服务器在检查点期间保持运行。** 仅在计划完成、切换到生产环境或端口被其他服务需要时才终止。
465
+
466
+ ## CLI 安装处理
467
+
468
+ | CLI | 自动安装? | 命令 |
469
+ |-----|-----------|------|
470
+ | npm/pnpm/yarn | 否 - 询问用户 | 用户选择包管理器 |
471
+ | vercel | 是 | `npm i -g vercel` |
472
+ | gh (GitHub) | 是 | `brew install gh`(macOS)或 `apt install gh`(Linux) |
473
+ | stripe | 是 | `npm i -g stripe` |
474
+ | supabase | 是 | `npm i -g supabase` |
475
+ | convex | 否 - 使用 npx | `npx convex`(无需安装) |
476
+ | fly | 是 | `brew install flyctl` 或 curl 安装器 |
477
+ | railway | 是 | `npm i -g @railway/cli` |
478
+
479
+ **协议:** 尝试命令 -> "command not found" -> 可自动安装?-> 是:静默安装,重试 -> 否:设置检查点让用户安装。
480
+
481
+ ## 检查点前自动化失败
482
+
483
+ | 失败 | 响应 |
484
+ |------|------|
485
+ | 服务器无法启动 | 检查错误,修复问题,重试(不要继续到检查点) |
486
+ | 端口被占用 | 杀死残留进程或使用备用端口 |
487
+ | 缺少依赖 | 运行 `npm install`,重试 |
488
+ | 构建错误 | 先修复错误(是 bug,不是检查点问题) |
489
+ | 认证错误 | 创建认证门控检查点 |
490
+ | 网络超时 | 带退避重试,持续则设检查点 |
491
+
492
+ **永远不要在验证环境损坏的情况下呈现检查点。** 如果 `curl localhost:3000` 失败,不要让用户「访问 localhost:3000」。
493
+
494
+ ```xml
495
+ <!-- 错误:环境损坏的检查点 -->
496
+ <task type="checkpoint:human-verify">
497
+ <what-built>Dashboard (server failed to start)</what-built>
498
+ <how-to-verify>Visit http://localhost:3000...</how-to-verify>
499
+ </task>
500
+
501
+ <!-- 正确:先修复,再设检查点 -->
502
+ <task type="auto">
503
+ <name>Fix server startup issue</name>
504
+ <action>Investigate error, fix root cause, restart server</action>
505
+ <verify>curl http://localhost:3000 returns 200</verify>
506
+ </task>
507
+
508
+ <task type="checkpoint:human-verify">
509
+ <what-built>Dashboard - server running at http://localhost:3000</what-built>
510
+ <how-to-verify>Visit http://localhost:3000/dashboard...</how-to-verify>
511
+ </task>
512
+ ```
513
+
514
+ ## 可自动化快速参考
515
+
516
+ | 操作 | 可自动化? | Claude 做? |
517
+ |------|-----------|------------|
518
+ | 部署到 Vercel | 是(`vercel`) | 是 |
519
+ | 创建 Stripe webhook | 是(API) | 是 |
520
+ | 写 .env 文件 | 是(Write 工具) | 是 |
521
+ | 创建 Upstash DB | 是(`upstash`) | 是 |
522
+ | 运行测试 | 是(`npm test`) | 是 |
523
+ | 启动开发服务器 | 是(`npm run dev`) | 是 |
524
+ | 添加环境变量到 Convex | 是(`npx convex env set`) | 是 |
525
+ | 添加环境变量到 Vercel | 是(`vercel env add`) | 是 |
526
+ | 填充数据库 | 是(CLI/API) | 是 |
527
+ | 点击邮件验证链接 | 否 | 否 |
528
+ | 输入带 3DS 的信用卡 | 否 | 否 |
529
+ | 在浏览器中完成 OAuth | 否 | 否 |
530
+ | 视觉验证 UI 是否正确 | 否 | 否 |
531
+ | 测试交互式用户流程 | 否 | 否 |
532
+
533
+ </automation_reference>
534
+
535
+ <writing_guidelines>
536
+
537
+ **要做:**
538
+ - 在检查点前用 CLI/API 自动化一切
539
+ - 具体:「Visit https://myapp.vercel.app」而非「check deployment」
540
+ - 编号验证步骤
541
+ - 说明预期结果:「You should see X」
542
+ - 提供上下文:为什么这个检查点存在
543
+
544
+ **不要做:**
545
+ - 让人工做 Claude 能自动化的工作 ❌
546
+ - 假设知识:「Configure the usual settings」 ❌
547
+ - 跳过步骤:「Set up database」(太模糊) ❌
548
+ - 在一个检查点中混合多个验证 ❌
549
+
550
+ **放置位置:**
551
+ - **自动化完成后** - 不是在 Claude 做工作之前
552
+ - **UI 构建后** - 在声明阶段完成之前
553
+ - **依赖工作之前** - 决策在实现之前
554
+ - **集成点** - 配置外部服务之后
555
+
556
+ **错误放置:** 自动化之前 ❌ | 太频繁 ❌ | 太晚(依赖任务已经需要结果) ❌
557
+ </writing_guidelines>
558
+
559
+ <examples>
560
+
561
+ ### 示例 1:数据库设置(不需要检查点)
562
+
563
+ ```xml
564
+ <task type="auto">
565
+ <name>Create Upstash Redis database</name>
566
+ <files>.env</files>
567
+ <action>
568
+ 1. Run `upstash redis create myapp-cache --region us-east-1`
569
+ 2. Capture connection URL from output
570
+ 3. Write to .env: UPSTASH_REDIS_URL={url}
571
+ 4. Verify connection with test command
572
+ </action>
573
+ <verify>
574
+ - upstash redis list shows database
575
+ - .env contains UPSTASH_REDIS_URL
576
+ - Test connection succeeds
577
+ </verify>
578
+ <done>Redis database created and configured</done>
579
+ </task>
580
+
581
+ <!-- 不需要检查点 - Claude 自动化了一切并通过程序化验证 -->
582
+ ```
583
+
584
+ ### 示例 2:完整认证流程(最后一个检查点)
585
+
586
+ ```xml
587
+ <task type="auto">
588
+ <name>Create user schema</name>
589
+ <files>src/db/schema.ts</files>
590
+ <action>Define User, Session, Account tables with Drizzle ORM</action>
591
+ <verify>npm run db:generate succeeds</verify>
592
+ </task>
593
+
594
+ <task type="auto">
595
+ <name>Create auth API routes</name>
596
+ <files>src/app/api/auth/[...nextauth]/route.ts</files>
597
+ <action>Set up NextAuth with GitHub provider, JWT strategy</action>
598
+ <verify>TypeScript compiles, no errors</verify>
599
+ </task>
600
+
601
+ <task type="auto">
602
+ <name>Create login UI</name>
603
+ <files>src/app/login/page.tsx, src/components/LoginButton.tsx</files>
604
+ <action>Create login page with GitHub OAuth button</action>
605
+ <verify>npm run build succeeds</verify>
606
+ </task>
607
+
608
+ <task type="auto">
609
+ <name>Start dev server for auth testing</name>
610
+ <action>Run `npm run dev` in background, wait for ready signal</action>
611
+ <verify>curl http://localhost:3000 returns 200</verify>
612
+ <done>Dev server running at http://localhost:3000</done>
613
+ </task>
614
+
615
+ <!-- 最后一个检查点验证完整流程 -->
616
+ <task type="checkpoint:human-verify" gate="blocking">
617
+ <what-built>Complete authentication flow - dev server running at http://localhost:3000</what-built>
618
+ <how-to-verify>
619
+ 1. Visit: http://localhost:3000/login
620
+ 2. Click "Sign in with GitHub"
621
+ 3. Complete GitHub OAuth flow
622
+ 4. Verify: Redirected to /dashboard, user name displayed
623
+ 5. Refresh page: Session persists
624
+ 6. Click logout: Session cleared
625
+ </how-to-verify>
626
+ <resume-signal>Type "approved" or describe issues</resume-signal>
627
+ </task>
628
+ ```
629
+ </examples>
630
+
631
+ <anti_patterns>
632
+
633
+ ### ❌ 错误:让用户启动开发服务器
634
+
635
+ ```xml
636
+ <task type="checkpoint:human-verify" gate="blocking">
637
+ <what-built>Dashboard component</what-built>
638
+ <how-to-verify>
639
+ 1. Run: npm run dev
640
+ 2. Visit: http://localhost:3000/dashboard
641
+ 3. Check layout is correct
642
+ </how-to-verify>
643
+ </task>
644
+ ```
645
+
646
+ **为什么错误:** Claude 可以运行 `npm run dev`。用户应该只访问 URL,不执行命令。
647
+
648
+ ### ✅ 正确:Claude 启动服务器,用户访问
649
+
650
+ ```xml
651
+ <task type="auto">
652
+ <name>Start dev server</name>
653
+ <action>Run `npm run dev` in background</action>
654
+ <verify>curl localhost:3000 returns 200</verify>
655
+ </task>
656
+
657
+ <task type="checkpoint:human-verify" gate="blocking">
658
+ <what-built>Dashboard at http://localhost:3000/dashboard (server running)</what-built>
659
+ <how-to-verify>
660
+ Visit http://localhost:3000/dashboard and verify:
661
+ 1. Layout matches design
662
+ 2. No console errors
663
+ </how-to-verify>
664
+ </task>
665
+ ```
666
+
667
+ ### ❌ 错误:让人工部署 / ✅ 正确:Claude 自动化
668
+
669
+ ```xml
670
+ <!-- 错误:让用户通过仪表板部署 -->
671
+ <task type="checkpoint:human-action" gate="blocking">
672
+ <action>Deploy to Vercel</action>
673
+ <instructions>Visit vercel.com/new → Import repo → Click Deploy → Copy URL</instructions>
674
+ </task>
675
+
676
+ <!-- 正确:Claude 部署,用户验证 -->
677
+ <task type="auto">
678
+ <name>Deploy to Vercel</name>
679
+ <action>Run `vercel --yes`. Capture URL.</action>
680
+ <verify>vercel ls shows deployment, curl returns 200</verify>
681
+ </task>
682
+
683
+ <task type="checkpoint:human-verify">
684
+ <what-built>Deployed to {url}</what-built>
685
+ <how-to-verify>Visit {url}, check homepage loads</how-to-verify>
686
+ <resume-signal>Type "approved"</resume-signal>
687
+ </task>
688
+ ```
689
+
690
+ ### ❌ 错误:太多检查点 / ✅ 正确:单个检查点
691
+
692
+ ```xml
693
+ <!-- 错误:每个任务后都有检查点 -->
694
+ <task type="auto">Create schema</task>
695
+ <task type="checkpoint:human-verify">Check schema</task>
696
+ <task type="auto">Create API route</task>
697
+ <task type="checkpoint:human-verify">Check API</task>
698
+ <task type="auto">Create UI form</task>
699
+ <task type="checkpoint:human-verify">Check form</task>
700
+
701
+ <!-- 正确:最后一个检查点 -->
702
+ <task type="auto">Create schema</task>
703
+ <task type="auto">Create API route</task>
704
+ <task type="auto">Create UI form</task>
705
+
706
+ <task type="checkpoint:human-verify">
707
+ <what-built>Complete auth flow (schema + API + UI)</what-built>
708
+ <how-to-verify>Test full flow: register, login, access protected page</how-to-verify>
709
+ <resume-signal>Type "approved"</resume-signal>
710
+ </task>
711
+ ```
712
+
713
+ ### ❌ 错误:模糊验证 / ✅ 正确:具体步骤
714
+
715
+ ```xml
716
+ <!-- 错误 -->
717
+ <task type="checkpoint:human-verify">
718
+ <what-built>Dashboard</what-built>
719
+ <how-to-verify>Check it works</how-to-verify>
720
+ </task>
721
+
722
+ <!-- 正确 -->
723
+ <task type="checkpoint:human-verify">
724
+ <what-built>Responsive dashboard - server running at http://localhost:3000</what-built>
725
+ <how-to-verify>
726
+ Visit http://localhost:3000/dashboard and verify:
727
+ 1. Desktop (>1024px): Sidebar visible, content area fills remaining space
728
+ 2. Tablet (768px): Sidebar collapses to icons
729
+ 3. Mobile (375px): Sidebar hidden, hamburger menu in header
730
+ 4. No horizontal scroll at any size
731
+ </how-to-verify>
732
+ <resume-signal>Type "approved" or describe layout issues</resume-signal>
733
+ </task>
734
+ ```
735
+
736
+ ### ❌ 错误:让用户运行 CLI 命令
737
+
738
+ ```xml
739
+ <task type="checkpoint:human-action">
740
+ <action>Run database migrations</action>
741
+ <instructions>Run: npx prisma migrate deploy && npx prisma db seed</instructions>
742
+ </task>
743
+ ```
744
+
745
+ **为什么错误:** Claude 可以运行这些命令。用户永远不应该执行 CLI 命令。
746
+
747
+ ### ❌ 错误:让用户在服务之间复制值
748
+
749
+ ```xml
750
+ <task type="checkpoint:human-action">
751
+ <action>Configure webhook URL in Stripe</action>
752
+ <instructions>Copy deployment URL → Stripe Dashboard → Webhooks → Add endpoint → Copy secret → Add to .env</instructions>
753
+ </task>
754
+ ```
755
+
756
+ **为什么错误:** Stripe 有 API。Claude 应该通过 API 创建 webhook 并直接写入 .env。
757
+
758
+ </anti_patterns>
759
+
760
+ <summary>
761
+
762
+ 检查点将人在回路中的验证和决策点正式化,而非手动工作。
763
+
764
+ **黄金规则:** 如果 Claude 能自动化,Claude 必须自动化。
765
+
766
+ **检查点优先级:**
767
+ 1. **checkpoint:human-verify**(90%)- Claude 自动化了一切,人工确认视觉/功能正确性
768
+ 2. **checkpoint:decision**(9%)- 人工做架构/技术选择
769
+ 3. **checkpoint:human-action**(1%)- 真正不可避免的、没有 API/CLI 的手动步骤
770
+
771
+ **何时不使用检查点:**
772
+ - Claude 可以通过程序化验证的事情(测试、构建)
773
+ - 文件操作(Claude 可以读取文件)
774
+ - 代码正确性(测试和静态分析)
775
+ - 任何可通过 CLI/API 自动化的事情
776
+ </summary>