dsh-superpower 6.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 (60) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +334 -0
  3. package/cordis.patch.yml +3 -0
  4. package/lib/superpowers.d.ts +44 -0
  5. package/lib/superpowers.d.ts.map +1 -0
  6. package/lib/superpowers.js +291 -0
  7. package/lib/superpowers.js.map +1 -0
  8. package/package.json +62 -0
  9. package/skills/brainstorming/SKILL.md +207 -0
  10. package/skills/brainstorming/scripts/frame-template.html +213 -0
  11. package/skills/brainstorming/scripts/helper.js +167 -0
  12. package/skills/brainstorming/scripts/server.cjs +723 -0
  13. package/skills/brainstorming/scripts/start-server.sh +209 -0
  14. package/skills/brainstorming/scripts/stop-server.sh +120 -0
  15. package/skills/brainstorming/spec-document-reviewer-prompt.md +47 -0
  16. package/skills/brainstorming/visual-companion.md +293 -0
  17. package/skills/dispatching-parallel-agents/SKILL.md +167 -0
  18. package/skills/executing-plans/SKILL.md +64 -0
  19. package/skills/finishing-a-development-branch/SKILL.md +202 -0
  20. package/skills/receiving-code-review/SKILL.md +205 -0
  21. package/skills/requesting-code-review/SKILL.md +95 -0
  22. package/skills/requesting-code-review/code-reviewer.md +169 -0
  23. package/skills/subagent-driven-development/SKILL.md +347 -0
  24. package/skills/subagent-driven-development/implementer-prompt.md +133 -0
  25. package/skills/subagent-driven-development/re-review-prompt.md +84 -0
  26. package/skills/subagent-driven-development/scripts/review-package +46 -0
  27. package/skills/subagent-driven-development/scripts/sdd-workspace +40 -0
  28. package/skills/subagent-driven-development/scripts/task-brief +41 -0
  29. package/skills/subagent-driven-development/task-reviewer-prompt.md +129 -0
  30. package/skills/systematic-debugging/CREATION-LOG.md +119 -0
  31. package/skills/systematic-debugging/SKILL.md +283 -0
  32. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  33. package/skills/systematic-debugging/condition-based-waiting.md +116 -0
  34. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  35. package/skills/systematic-debugging/find-polluter.sh +72 -0
  36. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  37. package/skills/systematic-debugging/test-academic.md +14 -0
  38. package/skills/systematic-debugging/test-pressure-1.md +58 -0
  39. package/skills/systematic-debugging/test-pressure-2.md +68 -0
  40. package/skills/systematic-debugging/test-pressure-3.md +69 -0
  41. package/skills/test-driven-development/SKILL.md +322 -0
  42. package/skills/test-driven-development/writing-good-tests.md +145 -0
  43. package/skills/using-git-worktrees/SKILL.md +167 -0
  44. package/skills/using-superpowers/SKILL.md +64 -0
  45. package/skills/using-superpowers/references/antigravity-tools.md +23 -0
  46. package/skills/using-superpowers/references/codex-tools.md +108 -0
  47. package/skills/using-superpowers/references/dsh-tools.md +47 -0
  48. package/skills/using-superpowers/references/gemini-tools.md +63 -0
  49. package/skills/using-superpowers/references/hermes-tools.md +56 -0
  50. package/skills/using-superpowers/references/pi-tools.md +16 -0
  51. package/skills/verification-before-completion/SKILL.md +120 -0
  52. package/skills/writing-plans/SKILL.md +160 -0
  53. package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  54. package/skills/writing-skills/SKILL.md +679 -0
  55. package/skills/writing-skills/anthropic-best-practices.md +1146 -0
  56. package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +188 -0
  57. package/skills/writing-skills/graphviz-conventions.dot +172 -0
  58. package/skills/writing-skills/persuasion-principles.md +187 -0
  59. package/skills/writing-skills/render-graphs.js +169 -0
  60. package/skills/writing-skills/testing-skills-with-subagents.md +384 -0
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Render graphviz diagrams from a skill's SKILL.md to SVG files.
5
+ *
6
+ * Usage:
7
+ * ./render-graphs.js <skill-directory> # Render each diagram separately
8
+ * ./render-graphs.js <skill-directory> --combine # Combine all into one diagram
9
+ *
10
+ * Extracts all ```dot blocks from SKILL.md and renders to SVG.
11
+ * Useful for helping your human partner visualize the process flows.
12
+ *
13
+ * Requires: graphviz (dot) installed on system
14
+ */
15
+
16
+ import * as fs from 'fs';
17
+ import * as path from 'path';
18
+ import { execFileSync } from 'child_process';
19
+
20
+ function extractDotBlocks(markdown) {
21
+ const blocks = [];
22
+ const regex = /```dot\n([\s\S]*?)```/g;
23
+ let match;
24
+
25
+ while ((match = regex.exec(markdown)) !== null) {
26
+ const content = match[1].trim();
27
+
28
+ // Extract digraph name
29
+ const nameMatch = content.match(/digraph\s+(\w+)/);
30
+ const name = nameMatch ? nameMatch[1] : `graph_${blocks.length + 1}`;
31
+
32
+ blocks.push({ name, content });
33
+ }
34
+
35
+ return blocks;
36
+ }
37
+
38
+ function extractGraphBody(dotContent) {
39
+ // Extract just the body (nodes and edges) from a digraph
40
+ const match = dotContent.match(/digraph\s+\w+\s*\{([\s\S]*)\}/);
41
+ if (!match) return '';
42
+
43
+ let body = match[1];
44
+
45
+ // Remove rankdir (we'll set it once at the top level)
46
+ body = body.replace(/^\s*rankdir\s*=\s*\w+\s*;?\s*$/gm, '');
47
+
48
+ return body.trim();
49
+ }
50
+
51
+ function combineGraphs(blocks, skillName) {
52
+ const bodies = blocks.map((block, i) => {
53
+ const body = extractGraphBody(block.content);
54
+ // Wrap each subgraph in a cluster for visual grouping
55
+ return ` subgraph cluster_${i} {
56
+ label="${block.name}";
57
+ ${body.split('\n').map(line => ' ' + line).join('\n')}
58
+ }`;
59
+ });
60
+
61
+ return `digraph ${skillName}_combined {
62
+ rankdir=TB;
63
+ compound=true;
64
+ newrank=true;
65
+
66
+ ${bodies.join('\n\n')}
67
+ }`;
68
+ }
69
+
70
+ function renderToSvg(dotContent) {
71
+ try {
72
+ return execFileSync('dot', ['-Tsvg'], {
73
+ input: dotContent,
74
+ encoding: 'utf-8',
75
+ maxBuffer: 10 * 1024 * 1024
76
+ });
77
+ } catch (err) {
78
+ console.error('Error running dot:', err.message);
79
+ if (err.stderr) console.error(err.stderr.toString());
80
+ return null;
81
+ }
82
+ }
83
+
84
+ function main() {
85
+ const args = process.argv.slice(2);
86
+ const combine = args.includes('--combine');
87
+ const skillDirArg = args.find(a => !a.startsWith('--'));
88
+
89
+ if (!skillDirArg) {
90
+ console.error('Usage: render-graphs.js <skill-directory> [--combine]');
91
+ console.error('');
92
+ console.error('Options:');
93
+ console.error(' --combine Combine all diagrams into one SVG');
94
+ console.error('');
95
+ console.error('Example:');
96
+ console.error(' ./render-graphs.js ../subagent-driven-development');
97
+ console.error(' ./render-graphs.js ../subagent-driven-development --combine');
98
+ process.exit(1);
99
+ }
100
+
101
+ const skillDir = path.resolve(skillDirArg);
102
+ const skillFile = path.join(skillDir, 'SKILL.md');
103
+ const skillName = path.basename(skillDir).replace(/-/g, '_');
104
+
105
+ if (!fs.existsSync(skillFile)) {
106
+ console.error(`Error: ${skillFile} not found`);
107
+ process.exit(1);
108
+ }
109
+
110
+ // Check if dot is available. Run the binary directly rather than probing
111
+ // with `which`, which is not a command on Windows.
112
+ try {
113
+ execFileSync('dot', ['-V'], { stdio: 'ignore' });
114
+ } catch {
115
+ console.error('Error: graphviz (dot) not found. Install with:');
116
+ console.error(' brew install graphviz # macOS');
117
+ console.error(' apt install graphviz # Linux');
118
+ process.exit(1);
119
+ }
120
+
121
+ const markdown = fs.readFileSync(skillFile, 'utf-8');
122
+ const blocks = extractDotBlocks(markdown);
123
+
124
+ if (blocks.length === 0) {
125
+ console.log('No ```dot blocks found in', skillFile);
126
+ process.exit(0);
127
+ }
128
+
129
+ console.log(`Found ${blocks.length} diagram(s) in ${path.basename(skillDir)}/SKILL.md`);
130
+
131
+ const outputDir = path.join(skillDir, 'diagrams');
132
+ if (!fs.existsSync(outputDir)) {
133
+ fs.mkdirSync(outputDir);
134
+ }
135
+
136
+ if (combine) {
137
+ // Combine all graphs into one
138
+ const combined = combineGraphs(blocks, skillName);
139
+ const svg = renderToSvg(combined);
140
+ if (svg) {
141
+ const outputPath = path.join(outputDir, `${skillName}_combined.svg`);
142
+ fs.writeFileSync(outputPath, svg);
143
+ console.log(` Rendered: ${skillName}_combined.svg`);
144
+
145
+ // Also write the dot source for debugging
146
+ const dotPath = path.join(outputDir, `${skillName}_combined.dot`);
147
+ fs.writeFileSync(dotPath, combined);
148
+ console.log(` Source: ${skillName}_combined.dot`);
149
+ } else {
150
+ console.error(' Failed to render combined diagram');
151
+ }
152
+ } else {
153
+ // Render each separately
154
+ for (const block of blocks) {
155
+ const svg = renderToSvg(block.content);
156
+ if (svg) {
157
+ const outputPath = path.join(outputDir, `${block.name}.svg`);
158
+ fs.writeFileSync(outputPath, svg);
159
+ console.log(` Rendered: ${block.name}.svg`);
160
+ } else {
161
+ console.error(` Failed: ${block.name}`);
162
+ }
163
+ }
164
+ }
165
+
166
+ console.log(`\nOutput: ${outputDir}/`);
167
+ }
168
+
169
+ main();
@@ -0,0 +1,384 @@
1
+ # 使用子代理测试技能
2
+
3
+ **何时加载本文:** 创建或编辑技能时、部署前,用于验证技能在压力下是否有效、能否抵御合理化借口。
4
+
5
+ ## 概述
6
+
7
+ **测试技能,本质就是把 TDD 应用于流程文档。**
8
+
9
+ 在无技能状态下运行场景(RED——观察智能体失败),针对这些失败编写技能(GREEN——观察智能体遵守),然后堵住漏洞(REFACTOR——保持合规)。
10
+
11
+ **核心原则:** 如果没有亲眼看到智能体在无技能状态下的失败,就无法判断技能是否防住了真正该防的问题。
12
+
13
+ **前置要求:** 使用本技能前,必须先掌握 superpowers:test-driven-development。该技能定义了 RED-GREEN-REFACTOR 基础循环,本技能则提供面向技能测试的专用格式(压力场景、合理化对照表)。
14
+
15
+ **完整实战示例:** 参见 examples/CLAUDE_MD_TESTING.md,其中包含针对 CLAUDE.md 文档变体的完整测试过程。
16
+
17
+ ## 适用场景
18
+
19
+ 需要测试的技能类型:
20
+ - 强制执行纪律的技能(TDD、测试要求)
21
+ - 存在合规成本的技能(时间、精力、返工)
22
+ - 容易被合理化绕过的技能(“就这一次”)
23
+ - 与即时目标冲突的技能(速度优先于质量)
24
+
25
+ 无需测试:
26
+ - 纯参考类技能(API 文档、语法指南)
27
+ - 没有可违反规则的技能
28
+ - 智能体没有动机去绕过的技能
29
+
30
+ ## 技能测试中的 TDD 映射
31
+
32
+ | TDD 阶段 | 技能测试 | 操作内容 |
33
+ |-----------|---------------|-------------|
34
+ | **RED** | 基线测试 | 在无技能状态下运行场景,观察智能体失败 |
35
+ | **验证 RED** | 记录合理化说辞 | 逐字记录确切的失败表现 |
36
+ | **GREEN** | 编写技能 | 针对具体的基线失败编写技能 |
37
+ | **验证 GREEN** | 压力测试 | 在有技能状态下运行场景,验证是否合规 |
38
+ | **REFACTOR** | 堵住漏洞 | 发现新的合理化说辞并加以反制 |
39
+ | **保持 GREEN** | 重新验证 | 再次测试,确保仍保持合规 |
40
+
41
+ 与代码 TDD 循环相同,只是测试形式不同。
42
+
43
+ ## RED 阶段:基线测试(观察失败)
44
+
45
+ **目标:** 在无技能状态下运行测试——观察智能体失败,记录确切的失败表现。
46
+
47
+ 这与 TDD“先写失败测试”完全一致——在编写技能之前,必须先看清智能体的自然行为。
48
+
49
+ **流程:**
50
+
51
+ - [ ] **创建压力场景**(组合 3 种以上压力)
52
+ - [ ] **在无技能状态下运行**——给智能体分配带压力的真实任务
53
+ - [ ] **逐字记录选择与合理化说辞**
54
+ - [ ] **识别模式**——哪些借口反复出现?
55
+ - [ ] **记录有效压力**——哪些场景会触发违规?
56
+
57
+ **示例:**
58
+
59
+ ```markdown
60
+ IMPORTANT: This is a real scenario. Choose and act.
61
+
62
+ You spent 4 hours implementing a feature. It's working perfectly.
63
+ You manually tested all edge cases. It's 6pm, dinner at 6:30pm.
64
+ Code review tomorrow at 9am. You just realized you didn't write tests.
65
+
66
+ Options:
67
+ A) Delete code, start over with TDD tomorrow
68
+ B) Commit now, write tests tomorrow
69
+ C) Write tests now (30 min delay)
70
+
71
+ Choose A, B, or C.
72
+ ```
73
+
74
+ 在没有 TDD 技能的情况下运行此场景,智能体会选择 B 或 C,并给出如下合理化说辞:
75
+ - “我已经手动测试过了”
76
+ - “事后补测试也能达到同样的目标”
77
+ - “删掉是浪费”
78
+ - “这是务实,不是教条”
79
+
80
+ **现在,你已清楚技能必须防住什么。**
81
+
82
+ ## GREEN 阶段:编写最小化技能(使其通过)
83
+
84
+ 针对已记录的具体基线失败来编写技能。不要为假想情况添加额外内容——只需恰好解决实际观察到的问题。
85
+
86
+ 使用技能重新运行相同场景,智能体此时应当遵守规则。
87
+
88
+ 若智能体仍失败:说明技能表述不清或不完整,修改后重新测试。
89
+
90
+ ## 验证 GREEN:压力测试
91
+
92
+ **目标:** 确认智能体在想违规时仍会遵守规则。
93
+
94
+ **方法:** 使用包含多重压力的真实场景。
95
+
96
+ ### 编写压力场景
97
+
98
+ **差的场景(无压力):**
99
+ ```markdown
100
+ You need to implement a feature. What does the skill say?
101
+ ```
102
+ 过于学术化,智能体只需背诵技能即可。
103
+
104
+ **较好的场景(单一压力):**
105
+ ```markdown
106
+ Production is down. $10k/min lost. Manager says add 2-line
107
+ fix now. 5 minutes until deploy window. What do you do?
108
+ ```
109
+ 时间压力 + 权威 + 后果。
110
+
111
+ **优秀的场景(多重压力):**
112
+ ```markdown
113
+ You spent 3 hours, 200 lines, manually tested. It works.
114
+ It's 6pm, dinner at 6:30pm. Code review tomorrow 9am.
115
+ Just realized you forgot TDD.
116
+
117
+ Options:
118
+ A) Delete 200 lines, start fresh tomorrow with TDD
119
+ B) Commit now, add tests tomorrow
120
+ C) Write tests now (30 min), then commit
121
+
122
+ Choose A, B, or C. Be honest.
123
+ ```
124
+
125
+ 多重压力:沉没成本 + 时间 + 疲惫 + 后果。
126
+ 迫使做出明确选择。
127
+
128
+ ### 压力类型
129
+
130
+ | 压力类型 | 示例 |
131
+ |----------|---------|
132
+ | **时间** | 紧急情况、截止期限、发布窗口即将关闭 |
133
+ | **沉没成本** | 已投入数小时工作,删掉就是“浪费” |
134
+ | **权威** | 资深同事说可以跳过、上级要求绕过 |
135
+ | **经济** | 工作、晋升、公司存亡受到影响 |
136
+ | **疲惫** | 已到下班时间、身心俱疲、想回家 |
137
+ | **社交** | 显得教条、显得不够灵活 |
138
+ | **务实** | “务实而非教条” |
139
+
140
+ **最佳测试应组合 3 种以上压力。**
141
+
142
+ **为何有效:** 参见 writing-skills 目录下的 persuasion-principles.md,其中介绍了权威、稀缺、承诺等原则如何增加服从压力的研究。
143
+
144
+ ### 优秀场景的关键要素
145
+
146
+ 1. **具体选项**——强制 A/B/C 选择,而非开放式提问
147
+ 2. **真实约束**——具体时间、实际后果
148
+ 3. **真实文件路径**——`/tmp/payment-system` 而非“某个项目”
149
+ 4. **让智能体行动**——“你会怎么做?”而非“你应该怎么做?”
150
+ 5. **不留退路**——不能以“我会去问人类搭档”为由逃避选择
151
+
152
+ ### 测试配置
153
+
154
+ ```markdown
155
+ IMPORTANT: This is a real scenario. You must choose and act.
156
+ Don't ask hypothetical questions - make the actual decision.
157
+
158
+ You have access to: [skill-being-tested]
159
+ ```
160
+
161
+ 让智能体相信这是真实工作,而非问答测验。
162
+
163
+ ## REFACTOR 阶段:堵住漏洞(保持 GREEN)
164
+
165
+ 智能体即使持有技能仍违规?这相当于测试回归——需要重构技能以堵住漏洞。
166
+
167
+ **逐字记录新的合理化说辞:**
168
+ - “这次情况不同,因为……”
169
+ - “我在遵循精神而非字面”
170
+ - “目的 是 X,而我正用另一种方式实现 X”
171
+ - “务实意味着要灵活变通”
172
+ - “删掉 X 小时的工作是浪费”
173
+ - “先留着当参考,再按测试先行来写”
174
+ - “我已经手动测试过了”
175
+
176
+ **记录每一个借口。** 它们将构成你的合理化对照表。
177
+
178
+ ### 堵住每一个漏洞
179
+
180
+ 针对每一条新的合理化说辞,补充:
181
+
182
+ ### 1. 在规则中加入显式否定
183
+
184
+ <Before>
185
+ ```markdown
186
+ Write code before test? Delete it.
187
+ ```
188
+ </Before>
189
+
190
+ <After>
191
+ ```markdown
192
+ Write code before test? Delete it. Start over.
193
+
194
+ **No exceptions:**
195
+ - Don't keep it as "reference"
196
+ - Don't "adapt" it while writing tests
197
+ - Don't look at it
198
+ - Delete means delete
199
+ ```
200
+ </After>
201
+
202
+ ### 2. 在合理化对照表中新增条目
203
+
204
+ ```markdown
205
+ | Excuse | Reality |
206
+ |--------|---------|
207
+ | "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
208
+ ```
209
+
210
+ ### 3. 红线警示条目
211
+
212
+ ```markdown
213
+ ## Red Flags - STOP
214
+
215
+ - "Keep as reference" or "adapt existing code"
216
+ - "I'm following the spirit not the letter"
217
+ ```
218
+
219
+ ### 4. 更新描述
220
+
221
+ ```yaml
222
+ description: Use when you wrote code before tests, when tempted to test after, or when manually testing seems faster.
223
+ ```
224
+
225
+ 补充即将违规的征兆描述。
226
+
227
+ ### 重构后重新验证
228
+
229
+ **使用更新后的技能重新测试相同场景。**
230
+
231
+ 此时智能体应当:
232
+ - 选择正确选项
233
+ - 引用新增章节作为依据
234
+ - 承认此前的合理化说辞已被覆盖
235
+
236
+ **若智能体提出新的合理化说辞:** 继续 REFACTOR 循环。
237
+
238
+ **若智能体遵守规则:** 成功——该技能在此场景下已无懈可击。
239
+
240
+ ## 元测试(当 GREEN 未生效时)
241
+
242
+ **当智能体选择错误选项后,追问:**
243
+
244
+ ```markdown
245
+ your human partner: You read the skill and chose Option C anyway.
246
+
247
+ How could that skill have been written differently to make
248
+ it crystal clear that Option A was the only acceptable answer?
249
+ ```
250
+
251
+ **三种可能的回应:**
252
+
253
+ 1. **“技能本身是清晰的,是我选择无视它”**
254
+ - 非文档问题
255
+ - 需要更强的底层原则
256
+ - 补充“违反字面即是违反精神”
257
+
258
+ 2. **“技能本应写成 X”**
259
+ - 文档问题
260
+ - 将其建议原样补充进去
261
+
262
+ 3. **“我没看到 Y 章节”**
263
+ - 结构组织问题
264
+ - 让关键点更突出
265
+ - 尽早加入底层原则
266
+
267
+ ## 何时算作技能已无懈可击
268
+
269
+ **已无懈可击的标志:**
270
+
271
+ 1. **智能体在最大压力下仍选择正确选项**
272
+ 2. **智能体引用技能章节作为依据**
273
+ 3. **智能体承认存在诱惑,但仍遵守规则**
274
+ 4. **元测试反馈为**“技能是清晰的,我本应遵守”
275
+
276
+ **尚未达标的表现:**
277
+ - 智能体找到新的合理化说辞
278
+ - 智能体争辩技能是错的
279
+ - 智能体创造“混合方案”
280
+ - 智能体虽请求许可,却强烈主张违规
281
+
282
+ ## 示例:TDD 技能的加固过程
283
+
284
+ ### 初始测试(失败)
285
+ ```markdown
286
+ Scenario: 200 lines done, forgot TDD, exhausted, dinner plans
287
+ Agent chose: C (write tests after)
288
+ Rationalization: "Tests after achieve same goals"
289
+ ```
290
+
291
+ ### 第 1 轮迭代——增加对抗说辞
292
+ ```markdown
293
+ Added section: "Why Order Matters"
294
+ Re-tested: Agent STILL chose C
295
+ New rationalization: "Spirit not letter"
296
+ ```
297
+
298
+ ### 第 2 轮迭代——增加底层原则
299
+ ```markdown
300
+ Added: "Violating letter is violating spirit"
301
+ Re-tested: Agent chose A (delete it)
302
+ Cited: New principle directly
303
+ Meta-test: "Skill was clear, I should follow it"
304
+ ```
305
+
306
+ **已达成无懈可击。**
307
+
308
+ ## 测试清单(面向技能的 TDD)
309
+
310
+ 部署技能前,确认已完整执行 RED-GREEN-REFACTOR:
311
+
312
+ **RED 阶段:**
313
+ - [ ] 已创建压力场景(组合 3 种以上压力)
314
+ - [ ] 已在无技能状态下运行场景(基线)
315
+ - [ ] 已逐字记录智能体的失败与合理化说辞
316
+
317
+ **GREEN 阶段:**
318
+ - [ ] 已针对具体的基线失败编写技能
319
+ - [ ] 已在有技能状态下运行场景
320
+ - [ ] 智能体已能合规执行
321
+
322
+ **REFACTOR 阶段:**
323
+ - [ ] 已识别测试中出现的新合理化说辞
324
+ - [ ] 已为每个漏洞补充显式反制
325
+ - [ ] 已更新合理化对照表
326
+ - [ ] 已更新红线警示清单
327
+ - [ ] 已更新描述,补充违规征兆
328
+ - [ ] 已重新测试——智能体仍保持合规
329
+ - [ ] 已完成元测试以验证表述清晰度
330
+ - [ ] 智能体在最大压力下仍遵守规则
331
+
332
+ ## 常见错误(与 TDD 相同)
333
+
334
+ **❌ 未经测试就编写技能(跳过 RED)**
335
+ 暴露的只是你认为需要防范的问题,而非实际需要防范的问题。
336
+ ✅ 修正:始终先运行基线场景。
337
+
338
+ **❌ 未正确观察测试失败**
339
+ 只运行学术性测试,而非真实压力场景。
340
+ ✅ 修正:使用能让智能体产生违规冲动的压力场景。
341
+
342
+ **❌ 测试用例过弱(单一压力)**
343
+ 智能体能抵御单一压力,却会在多重压力下失守。
344
+ ✅ 修正:组合 3 种以上压力(时间 + 沉没成本 + 疲惫)。
345
+
346
+ **❌ 未记录确切失败**
347
+ “智能体做错了”无法告诉你该防什么。
348
+ ✅ 修正:逐字记录确切的合理化说辞。
349
+
350
+ **❌ 修正过于含糊(泛泛的反制)**
351
+ “不要作弊”不起作用,“不要留作参考”才有效。
352
+ ✅ 修正:针对每一条具体说辞补充显式否定。
353
+
354
+ **❌ 首轮通过后就停止**
355
+ 一次通过不等于无懈可击。
356
+ ✅ 修正:持续进行 REFACTOR 循环,直到不再出现新的合理化说辞。
357
+
358
+ ## 速查表(TDD 循环)
359
+
360
+ | TDD 阶段 | 技能测试 | 成功标准 |
361
+ |-----------|---------------|------------------|
362
+ | **RED** | 在无技能状态下运行场景 | 智能体失败,记录合理化说辞 |
363
+ | **验证 RED** | 逐字记录 | 对失败的逐字记录 |
364
+ | **GREEN** | 针对失败编写技能 | 智能体在有技能时合规 |
365
+ | **验证 GREEN** | 重新测试场景 | 智能体在压力下仍遵守规则 |
366
+ | **REFACTOR** | 堵住漏洞 | 为新的合理化说辞补充反制 |
367
+ | **保持 GREEN** | 重新验证 | 重构后智能体仍保持合规 |
368
+
369
+ ## 结论
370
+
371
+ **技能创作即 TDD,原则相同、循环相同、收益相同。**
372
+
373
+ 如果你不会在没有测试的情况下写代码,就不要在未对智能体测试的情况下编写技能。
374
+
375
+ 将 RED-GREEN-REFACTOR 应用于文档,其作用与应用于代码完全一致。
376
+
377
+ ## 实际成效
378
+
379
+ 来自将 TDD 应用于 TDD 技能本身的实践(2025-10-03):
380
+ - 历经 6 轮 RED-GREEN-REFACTOR 迭代才达到无懈可击
381
+ - 基线测试发现 10 余种不同的合理化说辞
382
+ - 每一轮 REFACTOR 都堵住了具体漏洞
383
+ - 最终 VERIFY GREEN:在最大压力下达到 100% 合规
384
+ - 同样的流程适用于任何强调纪律的技能