@kl-c/matrixos 0.1.7 → 0.1.9

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 (123) hide show
  1. package/.agents/command/adopt.md +50 -0
  2. package/.agents/command/features.md +35 -0
  3. package/.opencode/command/adopt.md +50 -0
  4. package/.opencode/command/features.md +35 -0
  5. package/dist/cli/config-manager/write-gateway-env.d.ts +7 -0
  6. package/dist/cli/index.js +941 -788
  7. package/dist/cli/install-validators.d.ts +1 -0
  8. package/dist/cli/skills/debugging/references/methodology/02-investigate.md +1 -1
  9. package/dist/cli/skills/refactor/SKILL.md +1 -1
  10. package/dist/cli/skills/superpowers-brainstorming/SKILL.md +162 -0
  11. package/dist/cli/skills/superpowers-brainstorming/SUPERPOWERS_LICENSE +21 -0
  12. package/dist/cli/skills/superpowers-brainstorming/scripts/frame-template.html +213 -0
  13. package/dist/cli/skills/superpowers-brainstorming/scripts/helper.js +167 -0
  14. package/dist/cli/skills/superpowers-brainstorming/scripts/server.cjs +723 -0
  15. package/dist/cli/skills/superpowers-brainstorming/scripts/start-server.sh +209 -0
  16. package/dist/cli/skills/superpowers-brainstorming/scripts/stop-server.sh +120 -0
  17. package/dist/cli/skills/superpowers-brainstorming/spec-document-reviewer-prompt.md +49 -0
  18. package/dist/cli/skills/superpowers-brainstorming/visual-companion.md +291 -0
  19. package/dist/cli/skills/superpowers-receiving-code-review/SKILL.md +216 -0
  20. package/dist/cli/skills/superpowers-receiving-code-review/SUPERPOWERS_LICENSE +21 -0
  21. package/dist/cli/skills/superpowers-systematic-debugging/CREATION-LOG.md +119 -0
  22. package/dist/cli/skills/superpowers-systematic-debugging/SKILL.md +299 -0
  23. package/dist/cli/skills/superpowers-systematic-debugging/SUPERPOWERS_LICENSE +21 -0
  24. package/dist/cli/skills/superpowers-systematic-debugging/condition-based-waiting-example.ts +158 -0
  25. package/dist/cli/skills/superpowers-systematic-debugging/condition-based-waiting.md +115 -0
  26. package/dist/cli/skills/superpowers-systematic-debugging/defense-in-depth.md +122 -0
  27. package/dist/cli/skills/superpowers-systematic-debugging/find-polluter.sh +63 -0
  28. package/dist/cli/skills/superpowers-systematic-debugging/root-cause-tracing.md +169 -0
  29. package/dist/cli/skills/superpowers-systematic-debugging/test-academic.md +14 -0
  30. package/dist/cli/skills/superpowers-systematic-debugging/test-pressure-1.md +58 -0
  31. package/dist/cli/skills/superpowers-systematic-debugging/test-pressure-2.md +68 -0
  32. package/dist/cli/skills/superpowers-systematic-debugging/test-pressure-3.md +69 -0
  33. package/dist/cli/skills/superpowers-writing-skills/SKILL.md +692 -0
  34. package/dist/cli/skills/superpowers-writing-skills/SUPERPOWERS_LICENSE +21 -0
  35. package/dist/cli/skills/superpowers-writing-skills/anthropic-best-practices.md +1150 -0
  36. package/dist/cli/skills/superpowers-writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  37. package/dist/cli/skills/superpowers-writing-skills/graphviz-conventions.dot +172 -0
  38. package/dist/cli/skills/superpowers-writing-skills/persuasion-principles.md +187 -0
  39. package/dist/cli/skills/superpowers-writing-skills/render-graphs.js +168 -0
  40. package/dist/cli/skills/superpowers-writing-skills/testing-skills-with-subagents.md +384 -0
  41. package/dist/cli/types.d.ts +4 -0
  42. package/dist/cli-node/index.js +941 -788
  43. package/dist/config/schema/oh-my-opencode-config.d.ts +6 -0
  44. package/dist/config/schema/watchdog.d.ts +6 -0
  45. package/dist/features/anti-loop/background-registry.d.ts +10 -0
  46. package/dist/features/dashboard/frontend/css/style.css +211 -0
  47. package/dist/features/dashboard/frontend/index.html +173 -0
  48. package/dist/features/dashboard/frontend/js/api.js +2 -0
  49. package/dist/features/dashboard/frontend/js/app.js +349 -0
  50. package/dist/features/matrix-inventory/features.d.ts +45 -0
  51. package/dist/hooks/agent-anti-loop/hook.d.ts +16 -0
  52. package/dist/index.js +220 -45
  53. package/dist/oh-my-opencode.schema.json +42 -0
  54. package/dist/plugin/agent-anti-loop.d.ts +6 -0
  55. package/dist/skills/debugging/references/methodology/02-investigate.md +1 -1
  56. package/dist/skills/refactor/SKILL.md +1 -1
  57. package/dist/skills/superpowers-brainstorming/SKILL.md +162 -0
  58. package/dist/skills/superpowers-brainstorming/SUPERPOWERS_LICENSE +21 -0
  59. package/dist/skills/superpowers-brainstorming/scripts/frame-template.html +213 -0
  60. package/dist/skills/superpowers-brainstorming/scripts/helper.js +167 -0
  61. package/dist/skills/superpowers-brainstorming/scripts/server.cjs +723 -0
  62. package/dist/skills/superpowers-brainstorming/scripts/start-server.sh +209 -0
  63. package/dist/skills/superpowers-brainstorming/scripts/stop-server.sh +120 -0
  64. package/dist/skills/superpowers-brainstorming/spec-document-reviewer-prompt.md +49 -0
  65. package/dist/skills/superpowers-brainstorming/visual-companion.md +291 -0
  66. package/dist/skills/superpowers-receiving-code-review/SKILL.md +216 -0
  67. package/dist/skills/superpowers-receiving-code-review/SUPERPOWERS_LICENSE +21 -0
  68. package/dist/skills/superpowers-systematic-debugging/CREATION-LOG.md +119 -0
  69. package/dist/skills/superpowers-systematic-debugging/SKILL.md +299 -0
  70. package/dist/skills/superpowers-systematic-debugging/SUPERPOWERS_LICENSE +21 -0
  71. package/dist/skills/superpowers-systematic-debugging/condition-based-waiting-example.ts +158 -0
  72. package/dist/skills/superpowers-systematic-debugging/condition-based-waiting.md +115 -0
  73. package/dist/skills/superpowers-systematic-debugging/defense-in-depth.md +122 -0
  74. package/dist/skills/superpowers-systematic-debugging/find-polluter.sh +63 -0
  75. package/dist/skills/superpowers-systematic-debugging/root-cause-tracing.md +169 -0
  76. package/dist/skills/superpowers-systematic-debugging/test-academic.md +14 -0
  77. package/dist/skills/superpowers-systematic-debugging/test-pressure-1.md +58 -0
  78. package/dist/skills/superpowers-systematic-debugging/test-pressure-2.md +68 -0
  79. package/dist/skills/superpowers-systematic-debugging/test-pressure-3.md +69 -0
  80. package/dist/skills/superpowers-writing-skills/SKILL.md +692 -0
  81. package/dist/skills/superpowers-writing-skills/SUPERPOWERS_LICENSE +21 -0
  82. package/dist/skills/superpowers-writing-skills/anthropic-best-practices.md +1150 -0
  83. package/dist/skills/superpowers-writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  84. package/dist/skills/superpowers-writing-skills/graphviz-conventions.dot +172 -0
  85. package/dist/skills/superpowers-writing-skills/persuasion-principles.md +187 -0
  86. package/dist/skills/superpowers-writing-skills/render-graphs.js +168 -0
  87. package/dist/skills/superpowers-writing-skills/testing-skills-with-subagents.md +384 -0
  88. package/dist/testing/create-gateway-relay.d.ts +26 -0
  89. package/dist/tui.js +13 -0
  90. package/package.json +2 -1
  91. package/packages/shared-skills/skills/debugging/references/methodology/02-investigate.md +1 -1
  92. package/packages/shared-skills/skills/refactor/SKILL.md +1 -1
  93. package/packages/shared-skills/skills/superpowers-brainstorming/SKILL.md +162 -0
  94. package/packages/shared-skills/skills/superpowers-brainstorming/SUPERPOWERS_LICENSE +21 -0
  95. package/packages/shared-skills/skills/superpowers-brainstorming/scripts/frame-template.html +213 -0
  96. package/packages/shared-skills/skills/superpowers-brainstorming/scripts/helper.js +167 -0
  97. package/packages/shared-skills/skills/superpowers-brainstorming/scripts/server.cjs +723 -0
  98. package/packages/shared-skills/skills/superpowers-brainstorming/scripts/start-server.sh +209 -0
  99. package/packages/shared-skills/skills/superpowers-brainstorming/scripts/stop-server.sh +120 -0
  100. package/packages/shared-skills/skills/superpowers-brainstorming/spec-document-reviewer-prompt.md +49 -0
  101. package/packages/shared-skills/skills/superpowers-brainstorming/visual-companion.md +291 -0
  102. package/packages/shared-skills/skills/superpowers-receiving-code-review/SKILL.md +216 -0
  103. package/packages/shared-skills/skills/superpowers-receiving-code-review/SUPERPOWERS_LICENSE +21 -0
  104. package/packages/shared-skills/skills/superpowers-systematic-debugging/CREATION-LOG.md +119 -0
  105. package/packages/shared-skills/skills/superpowers-systematic-debugging/SKILL.md +299 -0
  106. package/packages/shared-skills/skills/superpowers-systematic-debugging/SUPERPOWERS_LICENSE +21 -0
  107. package/packages/shared-skills/skills/superpowers-systematic-debugging/condition-based-waiting-example.ts +158 -0
  108. package/packages/shared-skills/skills/superpowers-systematic-debugging/condition-based-waiting.md +115 -0
  109. package/packages/shared-skills/skills/superpowers-systematic-debugging/defense-in-depth.md +122 -0
  110. package/packages/shared-skills/skills/superpowers-systematic-debugging/find-polluter.sh +63 -0
  111. package/packages/shared-skills/skills/superpowers-systematic-debugging/root-cause-tracing.md +169 -0
  112. package/packages/shared-skills/skills/superpowers-systematic-debugging/test-academic.md +14 -0
  113. package/packages/shared-skills/skills/superpowers-systematic-debugging/test-pressure-1.md +58 -0
  114. package/packages/shared-skills/skills/superpowers-systematic-debugging/test-pressure-2.md +68 -0
  115. package/packages/shared-skills/skills/superpowers-systematic-debugging/test-pressure-3.md +69 -0
  116. package/packages/shared-skills/skills/superpowers-writing-skills/SKILL.md +692 -0
  117. package/packages/shared-skills/skills/superpowers-writing-skills/SUPERPOWERS_LICENSE +21 -0
  118. package/packages/shared-skills/skills/superpowers-writing-skills/anthropic-best-practices.md +1150 -0
  119. package/packages/shared-skills/skills/superpowers-writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  120. package/packages/shared-skills/skills/superpowers-writing-skills/graphviz-conventions.dot +172 -0
  121. package/packages/shared-skills/skills/superpowers-writing-skills/persuasion-principles.md +187 -0
  122. package/packages/shared-skills/skills/superpowers-writing-skills/render-graphs.js +168 -0
  123. package/packages/shared-skills/skills/superpowers-writing-skills/testing-skills-with-subagents.md +384 -0
@@ -0,0 +1,692 @@
1
+ ---
2
+ name: writing-skills
3
+ description: Use when creating new skills, editing existing skills, or verifying skills work before deployment
4
+ ---
5
+ > **Forked from [obra/superpowers](https://github.com/obra/superpowers) — MIT License, Copyright (c) 2025 Jesse Vincent.**
6
+ > Vendored as a native MaTrixOS skill. The original MIT license text is in `SUPERPOWERS_LICENSE` in this folder.
7
+ > Routing rule: MaTrixOS owns plan/execute/verify (ulw-plan, start-work, review-work). This skill is a complementary aid, invoked on demand.
8
+
9
+ # Writing Skills
10
+
11
+ ## Overview
12
+
13
+ **Writing skills IS Test-Driven Development applied to process documentation.**
14
+
15
+ **Personal skills live in your runtime's skills directory**
16
+
17
+ You write test cases (pressure scenarios with subagents), watch them fail (baseline behavior), write the skill (documentation), watch tests pass (agents comply), and refactor (close loopholes).
18
+
19
+ **Core principle:** If you didn't watch an agent fail without the skill, you don't know if the skill teaches the right thing.
20
+
21
+ **REQUIRED BACKGROUND:** You MUST understand superpowers:test-driven-development before using this skill. That skill defines the fundamental RED-GREEN-REFACTOR cycle. This skill adapts TDD to documentation.
22
+
23
+ **Official guidance:** For Anthropic's official skill authoring best practices, see anthropic-best-practices.md. This document provides additional patterns and guidelines that complement the TDD-focused approach in this skill.
24
+
25
+ ## What is a Skill?
26
+
27
+ A **skill** is a reference guide for proven techniques, patterns, or tools. Skills help future agents find and apply effective approaches.
28
+
29
+ **Skills are:** Reusable techniques, patterns, tools, reference guides
30
+
31
+ **Skills are NOT:** Narratives about how you solved a problem once
32
+
33
+ ## TDD Mapping for Skills
34
+
35
+ | TDD Concept | Skill Creation |
36
+ |-------------|----------------|
37
+ | **Test case** | Pressure scenario with subagent |
38
+ | **Production code** | Skill document (SKILL.md) |
39
+ | **Test fails (RED)** | Agent violates rule without skill (baseline) |
40
+ | **Test passes (GREEN)** | Agent complies with skill present |
41
+ | **Refactor** | Close loopholes while maintaining compliance |
42
+ | **Write test first** | Run baseline scenario BEFORE writing skill |
43
+ | **Watch it fail** | Document exact rationalizations agent uses |
44
+ | **Minimal code** | Write skill addressing those specific violations |
45
+ | **Watch it pass** | Verify agent now complies |
46
+ | **Refactor cycle** | Find new rationalizations → plug → re-verify |
47
+
48
+ The entire skill creation process follows RED-GREEN-REFACTOR.
49
+
50
+ ## When to Create a Skill
51
+
52
+ **Create when:**
53
+ - Technique wasn't intuitively obvious to you
54
+ - You'd reference this again across projects
55
+ - Pattern applies broadly (not project-specific)
56
+ - Others would benefit
57
+
58
+ **Don't create for:**
59
+ - One-off solutions
60
+ - Standard practices well-documented elsewhere
61
+ - Project-specific conventions (put in your instructions file)
62
+ - Mechanical constraints (if it's enforceable with regex/validation, automate it—save documentation for judgment calls)
63
+
64
+ ## Skill Types
65
+
66
+ ### Technique
67
+ Concrete method with steps to follow (condition-based-waiting, root-cause-tracing)
68
+
69
+ ### Pattern
70
+ Way of thinking about problems (flatten-with-flags, test-invariants)
71
+
72
+ ### Reference
73
+ API docs, syntax guides, tool documentation (office docs)
74
+
75
+ ## Directory Structure
76
+
77
+
78
+ ```
79
+ skills/
80
+ skill-name/
81
+ SKILL.md # Main reference (required)
82
+ supporting-file.* # Only if needed
83
+ ```
84
+
85
+ **Flat namespace** - all skills in one searchable namespace
86
+
87
+ **Separate files for:**
88
+ 1. **Heavy reference** (100+ lines) - API docs, comprehensive syntax
89
+ 2. **Reusable tools** - Scripts, utilities, templates
90
+
91
+ **Keep inline:**
92
+ - Principles and concepts
93
+ - Code patterns (< 50 lines)
94
+ - Everything else
95
+
96
+ ## SKILL.md Structure
97
+
98
+ **Frontmatter (YAML):**
99
+ - Two required fields: `name` and `description` (see [agentskills.io/specification](https://agentskills.io/specification) for all supported fields)
100
+ - Max 1024 characters total
101
+ - `name`: Use letters, numbers, and hyphens only (no parentheses, special chars)
102
+ - `description`: Third-person, describes ONLY when to use (NOT what it does)
103
+ - Start with "Use when..." to focus on triggering conditions
104
+ - Include specific symptoms, situations, and contexts
105
+ - **NEVER summarize the skill's process or workflow** (see SDO section for why)
106
+ - Keep under 500 characters if possible
107
+
108
+ ```markdown
109
+ ---
110
+ name: Skill-Name-With-Hyphens
111
+ description: Use when [specific triggering conditions and symptoms]
112
+ ---
113
+
114
+ # Skill Name
115
+
116
+ ## Overview
117
+ What is this? Core principle in 1-2 sentences.
118
+
119
+ ## When to Use
120
+ [Small inline flowchart IF decision non-obvious]
121
+
122
+ Bullet list with SYMPTOMS and use cases
123
+ When NOT to use
124
+
125
+ ## Core Pattern (for techniques/patterns)
126
+ Before/after code comparison
127
+
128
+ ## Quick Reference
129
+ Table or bullets for scanning common operations
130
+
131
+ ## Implementation
132
+ Inline code for simple patterns
133
+ Link to file for heavy reference or reusable tools
134
+
135
+ ## Common Mistakes
136
+ What goes wrong + fixes
137
+
138
+ ## Real-World Impact (optional)
139
+ Concrete results
140
+ ```
141
+
142
+
143
+ ## Skill Discovery Optimization (SDO)
144
+
145
+ **Critical for discovery:** Future agents need to FIND your skill
146
+
147
+ ### 1. Rich Description Field
148
+
149
+ **Purpose:** Your agent reads the description to decide which skills to load for a given task. Make it answer: "Should I read this skill right now?"
150
+
151
+ **Format:** Start with "Use when..." to focus on triggering conditions
152
+
153
+ **CRITICAL: Description = When to Use, NOT What the Skill Does**
154
+
155
+ The description should ONLY describe triggering conditions. Do NOT summarize the skill's process or workflow in the description.
156
+
157
+ **Why this matters:** Testing revealed that when a description summarizes the skill's workflow, an agent may follow the description instead of reading the full skill content. A description saying "code review between tasks" caused an agent to do ONE review, even though the skill's flowchart clearly showed TWO reviews (spec compliance then code quality).
158
+
159
+ When the description was changed to just "Use when executing implementation plans with independent tasks" (no workflow summary), the agent correctly read the flowchart and followed the two-stage review process.
160
+
161
+ **The trap:** Descriptions that summarize workflow create a shortcut agents will take. The skill body becomes documentation agents skip.
162
+
163
+ ```yaml
164
+ # ❌ BAD: Summarizes workflow - agents may follow this instead of reading skill
165
+ description: Use when executing plans - dispatches subagent per task with code review between tasks
166
+
167
+ # ❌ BAD: Too much process detail
168
+ description: Use for TDD - write test first, watch it fail, write minimal code, refactor
169
+
170
+ # ✅ GOOD: Just triggering conditions, no workflow summary
171
+ description: Use when executing implementation plans with independent tasks in the current session
172
+
173
+ # ✅ GOOD: Triggering conditions only
174
+ description: Use when implementing any feature or bugfix, before writing implementation code
175
+ ```
176
+
177
+ **Content:**
178
+ - Use concrete triggers, symptoms, and situations that signal this skill applies
179
+ - Describe the *problem* (race conditions, inconsistent behavior) not *language-specific symptoms* (setTimeout, sleep)
180
+ - Keep triggers technology-agnostic unless the skill itself is technology-specific
181
+ - If skill is technology-specific, make that explicit in the trigger
182
+ - Write in third person (injected into system prompt)
183
+ - **NEVER summarize the skill's process or workflow**
184
+
185
+ ```yaml
186
+ # ❌ BAD: Too abstract, vague, doesn't include when to use
187
+ description: For async testing
188
+
189
+ # ❌ BAD: First person
190
+ description: I can help you with async tests when they're flaky
191
+
192
+ # ❌ BAD: Mentions technology but skill isn't specific to it
193
+ description: Use when tests use setTimeout/sleep and are flaky
194
+
195
+ # ✅ GOOD: Starts with "Use when", describes problem, no workflow
196
+ description: Use when tests have race conditions, timing dependencies, or pass/fail inconsistently
197
+
198
+ # ✅ GOOD: Technology-specific skill with explicit trigger
199
+ description: Use when using React Router and handling authentication redirects
200
+ ```
201
+
202
+ ### 2. Keyword Coverage
203
+
204
+ Use words an agent would search for:
205
+ - Error messages: "Hook timed out", "ENOTEMPTY", "race condition"
206
+ - Symptoms: "flaky", "hanging", "zombie", "pollution"
207
+ - Synonyms: "timeout/hang/freeze", "cleanup/teardown/afterEach"
208
+ - Tools: Actual commands, library names, file types
209
+
210
+ ### 3. Descriptive Naming
211
+
212
+ **Use active voice, verb-first:**
213
+ - ✅ `creating-skills` not `skill-creation`
214
+ - ✅ `condition-based-waiting` not `async-test-helpers`
215
+
216
+ ### 4. Token Efficiency (Critical)
217
+
218
+ **Problem:** getting-started and frequently-referenced skills load into EVERY conversation. Every token counts.
219
+
220
+ **Target word counts:**
221
+ - getting-started workflows: <150 words each
222
+ - Frequently-loaded skills: <200 words total
223
+ - Other skills: <500 words (still be concise)
224
+
225
+ **Techniques:**
226
+
227
+ **Move details to tool help:**
228
+ ```bash
229
+ # ❌ BAD: Document all flags in SKILL.md
230
+ search-conversations supports --text, --both, --after DATE, --before DATE, --limit N
231
+
232
+ # ✅ GOOD: Reference --help
233
+ search-conversations supports multiple modes and filters. Run --help for details.
234
+ ```
235
+
236
+ **Use cross-references:**
237
+ ```markdown
238
+ # ❌ BAD: Repeat workflow details
239
+ When searching, dispatch subagent with template...
240
+ [20 lines of repeated instructions]
241
+
242
+ # ✅ GOOD: Reference other skill
243
+ Always use subagents (50-100x context savings). REQUIRED: Use [other-skill-name] for workflow.
244
+ ```
245
+
246
+ **Compress examples:**
247
+ ```markdown
248
+ # ❌ BAD: Verbose example (42 words)
249
+ your human partner: "How did we handle authentication errors in React Router before?"
250
+ You: I'll search past conversations for React Router authentication patterns.
251
+ [Dispatch subagent with search query: "React Router authentication error handling 401"]
252
+
253
+ # ✅ GOOD: Minimal example (20 words)
254
+ Partner: "How did we handle auth errors in React Router?"
255
+ You: Searching...
256
+ [Dispatch subagent → synthesis]
257
+ ```
258
+
259
+ **Eliminate redundancy:**
260
+ - Don't repeat what's in cross-referenced skills
261
+ - Don't explain what's obvious from command
262
+ - Don't include multiple examples of same pattern
263
+
264
+ **Verification:**
265
+ ```bash
266
+ wc -w skills/path/SKILL.md
267
+ # getting-started workflows: aim for <150 each
268
+ # Other frequently-loaded: aim for <200 total
269
+ ```
270
+
271
+ **Name by what you DO or core insight:**
272
+ - ✅ `condition-based-waiting` > `async-test-helpers`
273
+ - ✅ `using-skills` not `skill-usage`
274
+ - ✅ `flatten-with-flags` > `data-structure-refactoring`
275
+ - ✅ `root-cause-tracing` > `debugging-techniques`
276
+
277
+ **Gerunds (-ing) work well for processes:**
278
+ - `creating-skills`, `testing-skills`, `debugging-with-logs`
279
+ - Active, describes the action you're taking
280
+
281
+ ### 5. Cross-Referencing Other Skills
282
+
283
+ **When writing documentation that references other skills:**
284
+
285
+ Use skill name only, with explicit requirement markers:
286
+ - ✅ Good: `**REQUIRED SUB-SKILL:** Use superpowers:test-driven-development`
287
+ - ✅ Good: `**REQUIRED BACKGROUND:** You MUST understand superpowers:systematic-debugging`
288
+ - ❌ Bad: `See skills/testing/test-driven-development` (unclear if required)
289
+ - ❌ Bad: `@skills/testing/test-driven-development/SKILL.md` (force-loads, burns context)
290
+
291
+ **Why no @ links:** `@` syntax force-loads files immediately, consuming 200k+ context before you need them.
292
+
293
+ ## Flowchart Usage
294
+
295
+ ```dot
296
+ digraph when_flowchart {
297
+ "Need to show information?" [shape=diamond];
298
+ "Decision where I might go wrong?" [shape=diamond];
299
+ "Use markdown" [shape=box];
300
+ "Small inline flowchart" [shape=box];
301
+
302
+ "Need to show information?" -> "Decision where I might go wrong?" [label="yes"];
303
+ "Decision where I might go wrong?" -> "Small inline flowchart" [label="yes"];
304
+ "Decision where I might go wrong?" -> "Use markdown" [label="no"];
305
+ }
306
+ ```
307
+
308
+ **Use flowcharts ONLY for:**
309
+ - Non-obvious decision points
310
+ - Process loops where you might stop too early
311
+ - "When to use A vs B" decisions
312
+
313
+ **Never use flowcharts for:**
314
+ - Reference material → Tables, lists
315
+ - Code examples → Markdown blocks
316
+ - Linear instructions → Numbered lists
317
+ - Labels without semantic meaning (step1, helper2)
318
+
319
+ See `graphviz-conventions.dot` in this directory for graphviz style rules.
320
+
321
+ **Visualizing for your human partner:** Use `render-graphs.js` in this directory to render a skill's flowcharts to SVG:
322
+ ```bash
323
+ ./render-graphs.js ../some-skill # Each diagram separately
324
+ ./render-graphs.js ../some-skill --combine # All diagrams in one SVG
325
+ ```
326
+
327
+ ## Code Examples
328
+
329
+ **One excellent example beats many mediocre ones**
330
+
331
+ Choose most relevant language:
332
+ - Testing techniques → TypeScript/JavaScript
333
+ - System debugging → Shell/Python
334
+ - Data processing → Python
335
+
336
+ **Good example:**
337
+ - Complete and runnable
338
+ - Well-commented explaining WHY
339
+ - From real scenario
340
+ - Shows pattern clearly
341
+ - Ready to adapt (not generic template)
342
+
343
+ **Don't:**
344
+ - Implement in 5+ languages
345
+ - Create fill-in-the-blank templates
346
+ - Write contrived examples
347
+
348
+ You're good at porting - one great example is enough.
349
+
350
+ ## File Organization
351
+
352
+ ### Self-Contained Skill
353
+ ```
354
+ defense-in-depth/
355
+ SKILL.md # Everything inline
356
+ ```
357
+ When: All content fits, no heavy reference needed
358
+
359
+ ### Skill with Reusable Tool
360
+ ```
361
+ condition-based-waiting/
362
+ SKILL.md # Overview + patterns
363
+ example.ts # Working helpers to adapt
364
+ ```
365
+ When: Tool is reusable code, not just narrative
366
+
367
+ ### Skill with Heavy Reference
368
+ ```
369
+ pptx/
370
+ SKILL.md # Overview + workflows
371
+ pptxgenjs.md # 600 lines API reference
372
+ ooxml.md # 500 lines XML structure
373
+ scripts/ # Executable tools
374
+ ```
375
+ When: Reference material too large for inline
376
+
377
+ ## The Iron Law (Same as TDD)
378
+
379
+ ```
380
+ NO SKILL WITHOUT A FAILING TEST FIRST
381
+ ```
382
+
383
+ This applies to NEW skills AND EDITS to existing skills.
384
+
385
+ Write skill before testing? Delete it. Start over.
386
+ Edit skill without testing? Same violation.
387
+
388
+ **No exceptions:**
389
+ - Not for "simple additions"
390
+ - Not for "just adding a section"
391
+ - Not for "documentation updates"
392
+ - Don't keep untested changes as "reference"
393
+ - Don't "adapt" while running tests
394
+ - Delete means delete
395
+
396
+ **REQUIRED BACKGROUND:** The superpowers:test-driven-development skill explains why this matters. Same principles apply to documentation.
397
+
398
+ ## Testing All Skill Types
399
+
400
+ Different skill types need different test approaches:
401
+
402
+ ### Discipline-Enforcing Skills (rules/requirements)
403
+
404
+ **Examples:** TDD, verification-before-completion, designing-before-coding
405
+
406
+ **Test with:**
407
+ - Academic questions: Do they understand the rules?
408
+ - Pressure scenarios: Do they comply under stress?
409
+ - Multiple pressures combined: time + sunk cost + exhaustion
410
+ - Identify rationalizations and add explicit counters
411
+
412
+ **Success criteria:** Agent follows rule under maximum pressure
413
+
414
+ ### Technique Skills (how-to guides)
415
+
416
+ **Examples:** condition-based-waiting, root-cause-tracing, defensive-programming
417
+
418
+ **Test with:**
419
+ - Application scenarios: Can they apply the technique correctly?
420
+ - Variation scenarios: Do they handle edge cases?
421
+ - Missing information tests: Do instructions have gaps?
422
+
423
+ **Success criteria:** Agent successfully applies technique to new scenario
424
+
425
+ ### Pattern Skills (mental models)
426
+
427
+ **Examples:** reducing-complexity, information-hiding concepts
428
+
429
+ **Test with:**
430
+ - Recognition scenarios: Do they recognize when pattern applies?
431
+ - Application scenarios: Can they use the mental model?
432
+ - Counter-examples: Do they know when NOT to apply?
433
+
434
+ **Success criteria:** Agent correctly identifies when/how to apply pattern
435
+
436
+ ### Reference Skills (documentation/APIs)
437
+
438
+ **Examples:** API documentation, command references, library guides
439
+
440
+ **Test with:**
441
+ - Retrieval scenarios: Can they find the right information?
442
+ - Application scenarios: Can they use what they found correctly?
443
+ - Gap testing: Are common use cases covered?
444
+
445
+ **Success criteria:** Agent finds and correctly applies reference information
446
+
447
+ ## Common Rationalizations for Skipping Testing
448
+
449
+ | Excuse | Reality |
450
+ |--------|---------|
451
+ | "Skill is obviously clear" | Clear to you ≠ clear to other agents. Test it. |
452
+ | "It's just a reference" | References can have gaps, unclear sections. Test retrieval. |
453
+ | "Testing is overkill" | Untested skills have issues. Always. 15 min testing saves hours. |
454
+ | "I'll test if problems emerge" | Problems = agents can't use skill. Test BEFORE deploying. |
455
+ | "Too tedious to test" | Testing is less tedious than debugging bad skill in production. |
456
+ | "I'm confident it's good" | Overconfidence guarantees issues. Test anyway. |
457
+ | "Academic review is enough" | Reading ≠ using. Test application scenarios. |
458
+ | "No time to test" | Deploying untested skill wastes more time fixing it later. |
459
+
460
+ **All of these mean: Test before deploying. No exceptions.**
461
+
462
+ ## Match the Form to the Failure
463
+
464
+ Before writing guidance, classify the baseline failure. The form that bulletproofs one failure type measurably backfires on another.
465
+
466
+ | Baseline failure | Right form | Wrong form |
467
+ |---|---|---|
468
+ | Skips/violates a rule under pressure (knows better, does it anyway) | Prohibition + rationalization table + red flags (see Bulletproofing below) | Soft guidance ("prefer...", "consider...") |
469
+ | Complies, but output has the wrong shape (bloated prompt, buried verdict, restated spec) | Positive recipe or contract: state what the output IS — its parts, in order | Prohibition list ("don't restate", "never narrate") |
470
+ | Omits a required element from something they already produce | Structural: REQUIRED field or slot in the template they fill in | Prose reminders near the template |
471
+ | Behavior should depend on a condition | Conditional keyed to an observable predicate ("if the brief exists, reference it") | Unconditional rule + exemption clauses |
472
+
473
+ **Why prohibitions backfire on shaping problems:** under a competing incentive ("make the prompt self-contained"), agents negotiate with "don't X". In head-to-head wording tests on dispatch-prompt guidance, the prohibition arm produced clearly more of the unwanted content than the recipe arm (fully separated distributions), and trended worse than even the no-guidance control — micro-test your own case rather than assuming, but never reach for the prohibition by default. A recipe leaves nothing to negotiate: the output matches the stated shape or it doesn't.
474
+
475
+ **Rules for whichever form you pick:**
476
+ - **No nuance clauses.** "Don't X unless it matters" reopens the negotiation — appending a single nuance clause to a winning recipe degraded it from consistent to noisy in the same wording tests. Express a real exception as its own conditional on an observable predicate.
477
+ - **Exemption clauses don't scope.** "This limit doesn't apply to code blocks" still suppresses code blocks. If part of the output must be exempt, restructure so the rule can't reach it.
478
+
479
+ ## Bulletproofing Skills Against Rationalization
480
+
481
+ Skills that enforce discipline (like TDD) need to resist rationalization. Agents are smart and will find loopholes when under pressure.
482
+
483
+ **Scope:** this toolkit is for discipline failures — an agent that knows the rule and skips it under pressure. For wrong-shaped output or omitted elements, prohibition-based bulletproofing backfires; use the forms in Match the Form to the Failure instead.
484
+
485
+ **Psychology note:** Understanding WHY persuasion techniques work helps you apply them systematically. See persuasion-principles.md for research foundation (Cialdini, 2021; Meincke et al., 2025) on authority, commitment, scarcity, social proof, and unity principles.
486
+
487
+ ### Close Every Loophole Explicitly
488
+
489
+ Don't just state the rule - forbid specific workarounds:
490
+
491
+ <Bad>
492
+ ```markdown
493
+ Write code before test? Delete it.
494
+ ```
495
+ </Bad>
496
+
497
+ <Good>
498
+ ```markdown
499
+ Write code before test? Delete it. Start over.
500
+
501
+ **No exceptions:**
502
+ - Don't keep it as "reference"
503
+ - Don't "adapt" it while writing tests
504
+ - Don't look at it
505
+ - Delete means delete
506
+ ```
507
+ </Good>
508
+
509
+ ### Address "Spirit vs Letter" Arguments
510
+
511
+ Add foundational principle early:
512
+
513
+ ```markdown
514
+ **Violating the letter of the rules is violating the spirit of the rules.**
515
+ ```
516
+
517
+ This cuts off entire class of "I'm following the spirit" rationalizations.
518
+
519
+ ### Build Rationalization Table
520
+
521
+ Capture rationalizations from baseline testing (see Testing section below). Every excuse agents make goes in the table:
522
+
523
+ ```markdown
524
+ | Excuse | Reality |
525
+ |--------|---------|
526
+ | "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
527
+ | "I'll test after" | Tests passing immediately prove nothing. |
528
+ | "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
529
+ ```
530
+
531
+ ### Create Red Flags List
532
+
533
+ Make it easy for agents to self-check when rationalizing:
534
+
535
+ ```markdown
536
+ ## Red Flags - STOP and Start Over
537
+
538
+ - Code before test
539
+ - "I already manually tested it"
540
+ - "Tests after achieve the same purpose"
541
+ - "It's about spirit not ritual"
542
+ - "This is different because..."
543
+
544
+ **All of these mean: Delete code. Start over with TDD.**
545
+ ```
546
+
547
+ ### Update SDO for Violation Symptoms
548
+
549
+ Add to description: symptoms of when you're ABOUT to violate the rule:
550
+
551
+ ```yaml
552
+ description: use when implementing any feature or bugfix, before writing implementation code
553
+ ```
554
+
555
+ ## RED-GREEN-REFACTOR for Skills
556
+
557
+ Follow the TDD cycle:
558
+
559
+ ### RED: Write Failing Test (Baseline)
560
+
561
+ Run pressure scenario with subagent WITHOUT the skill. Document exact behavior:
562
+ - What choices did they make?
563
+ - What rationalizations did they use (verbatim)?
564
+ - Which pressures triggered violations?
565
+
566
+ This is "watch the test fail" - you must see what agents naturally do before writing the skill.
567
+
568
+ ### GREEN: Write Minimal Skill
569
+
570
+ Write skill that addresses those specific rationalizations. Don't add extra content for hypothetical cases.
571
+
572
+ Run same scenarios WITH skill. Agent should now comply.
573
+
574
+ ### REFACTOR: Close Loopholes
575
+
576
+ Agent found new rationalization? Add explicit counter. Re-test until bulletproof.
577
+
578
+ ### Micro-Test Wording Before Full Scenarios
579
+
580
+ Full pressure-scenario runs are the final gate, but they are slow and expensive per iteration. Verify the wording itself first with micro-tests:
581
+
582
+ 1. **One fresh-context sample per call** — a raw API call, or a single-shot subagent if you don't have API access. System prompt = the realistic context the guidance will live in (the full skill or prompt template, not the guidance in isolation); user message = a task that tempts the failure.
583
+ 2. **Always include a no-guidance control.** If the control doesn't exhibit the failure, there is nothing to fix — stop, don't author the guidance.
584
+ 3. **5+ reps per variant.** Single samples lie.
585
+ 4. **Manually read every flagged match.** Score programmatically if you like, but template echoes and quoted counter-examples masquerade as hits; automated counts alone overstate both failure and success.
586
+ 5. **Variance is a metric.** When guidance lands, reps converge on the same shape. Five different interpretations across five reps means the wording isn't binding — tighten the form before adding words.
587
+
588
+ Micro-tests verify wording; they do not replace pressure scenarios for discipline skills.
589
+
590
+ **Testing methodology:** See [testing-skills-with-subagents.md](testing-skills-with-subagents.md) for the complete testing methodology:
591
+ - How to write pressure scenarios
592
+ - Pressure types (time, sunk cost, authority, exhaustion)
593
+ - Plugging holes systematically
594
+ - Meta-testing techniques
595
+
596
+ ## Anti-Patterns
597
+
598
+ ### ❌ Narrative Example
599
+ "In session 2025-10-03, we found empty projectDir caused..."
600
+ **Why bad:** Too specific, not reusable
601
+
602
+ ### ❌ Multi-Language Dilution
603
+ example-js.js, example-py.py, example-go.go
604
+ **Why bad:** Mediocre quality, maintenance burden
605
+
606
+ ### ❌ Code in Flowcharts
607
+ ```dot
608
+ step1 [label="import fs"];
609
+ step2 [label="read file"];
610
+ ```
611
+ **Why bad:** Can't copy-paste, hard to read
612
+
613
+ ### ❌ Generic Labels
614
+ helper1, helper2, step3, pattern4
615
+ **Why bad:** Labels should have semantic meaning
616
+
617
+ ## STOP: Before Moving to Next Skill
618
+
619
+ **After writing ANY skill, you MUST STOP and complete the deployment process.**
620
+
621
+ **Do NOT:**
622
+ - Create multiple skills in batch without testing each
623
+ - Move to next skill before current one is verified
624
+ - Skip testing because "batching is more efficient"
625
+
626
+ **The deployment checklist below is MANDATORY for EACH skill.**
627
+
628
+ Deploying untested skills = deploying untested code. It's a violation of quality standards.
629
+
630
+ ## Skill Creation Checklist (TDD Adapted)
631
+
632
+ **IMPORTANT: Create a todo for EACH checklist item below.**
633
+
634
+ **RED Phase - Write Failing Test:**
635
+ - [ ] Create pressure scenarios (3+ combined pressures for discipline skills)
636
+ - [ ] Run scenarios WITHOUT skill - document baseline behavior verbatim
637
+ - [ ] Identify patterns in rationalizations/failures
638
+
639
+ **GREEN Phase - Write Minimal Skill:**
640
+ - [ ] Name uses only letters, numbers, hyphens (no parentheses/special chars)
641
+ - [ ] YAML frontmatter with required `name` and `description` fields (max 1024 chars; see [spec](https://agentskills.io/specification))
642
+ - [ ] Description starts with "Use when..." and includes specific triggers/symptoms
643
+ - [ ] Description written in third person
644
+ - [ ] Keywords throughout for search (errors, symptoms, tools)
645
+ - [ ] Clear overview with core principle
646
+ - [ ] Address specific baseline failures identified in RED
647
+ - [ ] Guidance form matches the failure type (see Match the Form to the Failure)
648
+ - [ ] For behavior-shaping guidance: wording micro-tested against a no-guidance control (5+ reps, every flagged match read manually) — N/A for pure reference skills
649
+ - [ ] Code inline OR link to separate file
650
+ - [ ] One excellent example (not multi-language)
651
+ - [ ] Run scenarios WITH skill - verify agents now comply
652
+
653
+ **REFACTOR Phase - Close Loopholes:**
654
+ - [ ] Identify NEW rationalizations from testing
655
+ - [ ] Add explicit counters (if discipline skill)
656
+ - [ ] Build rationalization table from all test iterations
657
+ - [ ] Create red flags list
658
+ - [ ] Re-test until bulletproof
659
+
660
+ **Quality Checks:**
661
+ - [ ] Small flowchart only if decision non-obvious
662
+ - [ ] Quick reference table
663
+ - [ ] Common mistakes section
664
+ - [ ] No narrative storytelling
665
+ - [ ] Supporting files only for tools or heavy reference
666
+
667
+ **Deployment:**
668
+ - [ ] Commit skill to git and push to your fork (if configured)
669
+ - [ ] Consider contributing back via PR (if broadly useful)
670
+
671
+ ## Discovery Workflow
672
+
673
+ How future agents find your skill:
674
+
675
+ 1. **Encounters problem** ("tests are flaky")
676
+ 2. **Searches skills** (greps descriptions, browses categories)
677
+ 3. **Finds SKILL** (description matches)
678
+ 4. **Scans overview** (is this relevant?)
679
+ 5. **Reads patterns** (quick reference table)
680
+ 6. **Loads example** (only when implementing)
681
+
682
+ **Optimize for this flow** - put searchable terms early and often.
683
+
684
+ ## The Bottom Line
685
+
686
+ **Creating skills IS TDD for process documentation.**
687
+
688
+ Same Iron Law: No skill without failing test first.
689
+ Same cycle: RED (baseline) → GREEN (write skill) → REFACTOR (close loopholes).
690
+ Same benefits: Better quality, fewer surprises, bulletproof results.
691
+
692
+ If you follow TDD for code, follow it for skills. It's the same discipline applied to documentation.