@ia-ccun/code-agent-cli 0.0.14 → 0.0.16

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