Writing skills

Use when creating new skills, editing existing skills, or verifying skills work before deployment

by davila7·MIT license·★ 32,299 Stars on the repo·GitHub ↗

Use now

Files of Writing skills

davila7/main1 file shown
SKILL.md
Show the full text738 lines

Writing Skills

Overview

Writing skills IS Test-Driven Development applied to process documentation.

Personal skills live in agent-specific directories (~/.claude/skills for Claude Code, ~/.codex/skills for Codex)

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).

Core principle: If you didn't watch an agent fail without the skill, you don't know if the skill teaches the right thing.

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.

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.

What is a Skill?

A skill is a reference guide for proven techniques, patterns, or tools. Skills help future Claude instances find and apply effective approaches.

Skills are: Reusable techniques, patterns, tools, reference guides

Skills are NOT: Narratives about how you solved a problem once

TDD Mapping for Skills

TDD Concept Skill Creation
Test case Pressure scenario with subagent
Production code Skill document (SKILL.md)
Test fails (RED) Agent violates rule without skill (baseline)
Test passes (GREEN) Agent complies with skill present
Refactor Close loopholes while maintaining compliance
Write test first Run baseline scenario BEFORE writing skill
Watch it fail Document exact rationalizations agent uses
Minimal code Write skill addressing those specific violations
Watch it pass Verify agent now complies
Refactor cycle Find new rationalizations → plug → re-verify

The entire skill creation process follows RED-GREEN-REFACTOR.

When to Create a Skill

Create when:

  • Technique wasn't intuitively obvious to you
  • You'd reference this again across projects
  • Pattern applies broadly (not project-specific)
  • Others would benefit

Don't create for:

  • One-off solutions
  • Standard practices well-documented elsewhere
  • Project-specific conventions (put in CLAUDE.md)
  • Mechanical constraints (if it's enforceable with regex/validation, automate it—save documentation for judgment calls)

Skill Types

Technique

Concrete method with steps to follow (condition-based-waiting, root-cause-tracing)

Pattern

Way of thinking about problems (flatten-with-flags, test-invariants)

Reference

API docs, syntax guides, tool documentation (office docs)

Directory Structure

skills/
  skill-name/
    SKILL.md              # Main reference (required)
    supporting-file.*     # Only if needed

Flat namespace - all skills in one searchable namespace

Separate files for:

  1. Heavy reference (100+ lines) - API docs, comprehensive syntax
  2. Reusable tools - Scripts, utilities, templates

Keep inline:

  • Principles and concepts
  • Code patterns (< 50 lines)
  • Everything else

Set Appropriate Degrees of Freedom

Match the level of specificity to the task's fragility and variability:

  • High freedom (text-based instructions): Use when multiple approaches are valid or decisions depend on context.
  • Medium freedom (pseudocode or scripts with parameters): Use when a preferred pattern exists but some variation is acceptable.
  • Low freedom (specific scripts, no-context instructions): Use when operations are fragile, error-prone, or consistency is critical.

Progressive Disclosure

Manage context efficiently by splitting detailed information into separate files:

  1. Metadata (name + description): Always loaded for discovery.
  2. SKILL.md body: Core workflow and high-level guidance. Keep under 500 lines.
  3. Bundled resources:
    • scripts/: Deterministic code/logic.
    • references/: Detailed schemas, API docs, or domain knowledge.
    • assets/: Templates, images, or static files.

Pattern: Link to advanced content or variant-specific details (e.g., aws.md vs gcp.md) from the main SKILL.md.

SKILL.md Structure

Frontmatter (YAML):

  • Only two fields supported: name and description
  • Max 1024 characters total
  • name: Use letters, numbers, and hyphens only (no parentheses, special chars)
  • description: Third-person, describes ONLY when to use (NOT what it does)
    • Start with "Use when..." to focus on triggering conditions
    • Include specific symptoms, situations, and contexts
    • NEVER summarize the skill's process or workflow (see CSO section for why)
    • Keep under 500 characters if possible
---
name: Skill-Name-With-Hyphens
description: Use when [specific triggering conditions and symptoms]
---

# Skill Name

## Overview

What is this? Core principle in 1-2 sentences.

## When to Use

[Small inline flowchart IF decision non-obvious]

Bullet list with SYMPTOMS and use cases
When NOT to use

## Core Pattern (for techniques/patterns)

Before/after code comparison

## Quick Reference

Table or bullets for scanning common operations

## Implementation

Inline code for simple patterns
Link to file for heavy reference or reusable tools

## Common Mistakes

What goes wrong + fixes

## Real-World Impact (optional)

Concrete results

Claude Search Optimization (CSO)

Critical for discovery: Future Claude needs to FIND your skill

1. Rich Description Field

Purpose: Claude reads description to decide which skills to load for a given task. Make it answer: "Should I read this skill right now?"

Format: Start with "Use when..." to focus on triggering conditions

CRITICAL: Description = When to Use, NOT What the Skill Does

The description should ONLY describe triggering conditions. Do NOT summarize the skill's process or workflow in the description.

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).

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.

The trap: Descriptions that summarize workflow create a shortcut Claude will take. The skill body becomes documentation Claude skips.

# ❌ BAD: Summarizes workflow - Claude may follow this instead of reading skill
description: Use when executing plans - dispatches subagent per task with code review between tasks

# ❌ BAD: Too much process detail
description: Use for TDD - write test first, watch it fail, write minimal code, refactor

# ✅ GOOD: Just triggering conditions, no workflow summary
description: Use when executing implementation plans with independent tasks in the current session

# ✅ GOOD: Triggering conditions only
description: Use when implementing any feature or bugfix, before writing implementation code

Content:

  • Use concrete triggers, symptoms, and situations that signal this skill applies
  • Describe the problem (race conditions, inconsistent behavior) not language-specific symptoms (setTimeout, sleep)
  • Keep triggers technology-agnostic unless the skill itself is technology-specific
  • If skill is technology-specific, make that explicit in the trigger
  • Write in third person (injected into system prompt)
  • NEVER summarize the skill's process or workflow
# ❌ BAD: Too abstract, vague, doesn't include when to use
description: For async testing

# ❌ BAD: First person
description: I can help you with async tests when they're flaky

# ❌ BAD: Mentions technology but skill isn't specific to it
description: Use when tests use setTimeout/sleep and are flaky

# ✅ GOOD: Starts with "Use when", describes problem, no workflow
description: Use when tests have race conditions, timing dependencies, or pass/fail inconsistently

# ✅ GOOD: Technology-specific skill with explicit trigger
description: Use when using React Router and handling authentication redirects
2. Keyword Coverage

Use words Claude would search for:

  • Error messages: "Hook timed out", "ENOTEMPTY", "race condition"
  • Symptoms: "flaky", "hanging", "zombie", "pollution"
  • Synonyms: "timeout/hang/freeze", "cleanup/teardown/afterEach"
  • Tools: Actual commands, library names, file types
3. Descriptive Naming

Use active voice, verb-first:

  • ✅ creating-skills not skill-creation
  • ✅ condition-based-waiting not async-test-helpers
4. Token Efficiency (Critical)

Problem: getting-started and frequently-referenced skills load into EVERY conversation. Every token counts.

Target word counts:

  • getting-started workflows: <150 words each
  • Frequently-loaded skills: <200 words total
  • Other skills: <500 words (still be concise)

Techniques:

Move details to tool help:

# ❌ BAD: Document all flags in SKILL.md
search-conversations supports --text, --both, --after DATE, --before DATE, --limit N

# ✅ GOOD: Reference --help
search-conversations supports multiple modes and filters. Run --help for details.

Use cross-references:

# ❌ BAD: Repeat workflow details

When searching, dispatch subagent with template...
[20 lines of repeated instructions]

# ✅ GOOD: Reference other skill

Always use subagents (50-100x context savings). REQUIRED: Use [other-skill-name] for workflow.

Compress examples:

# ❌ BAD: Verbose example (42 words)

your human partner: "How did we handle authentication errors in React Router before?"
You: I'll search past conversations for React Router authentication patterns.
[Dispatch subagent with search query: "React Router authentication error handling 401"]

# ✅ GOOD: Minimal example (20 words)

Partner: "How did we handle auth errors in React Router?"
You: Searching...
[Dispatch subagent → synthesis]

Eliminate redundancy:

  • Don't repeat what's in cross-referenced skills
  • Don't explain what's obvious from command
  • Don't include multiple examples of same pattern

Verification:

wc -w skills/path/SKILL.md
# getting-started workflows: aim for <150 each
# Other frequently-loaded: aim for <200 total

Name by what you DO or core insight:

  • ✅ condition-based-waiting > async-test-helpers
  • ✅ using-skills not skill-usage
  • ✅ flatten-with-flags > data-structure-refactoring
  • ✅ root-cause-tracing > debugging-techniques

Gerunds (-ing) work well for processes:

  • creating-skills, testing-skills, debugging-with-logs
  • Active, describes the action you're taking
4. Cross-Referencing Other Skills

When writing documentation that references other skills:

Use skill name only, with explicit requirement markers:

  • ✅ Good: **REQUIRED SUB-SKILL:** Use superpowers:test-driven-development
  • ✅ Good: **REQUIRED BACKGROUND:** You MUST understand superpowers:systematic-debugging
  • ❌ Bad: See skills/testing/test-driven-development (unclear if required)
  • ❌ Bad: @skills/testing/test-driven-development/SKILL.md (force-loads, burns context)

Why no @ links: @ syntax force-loads files immediately, consuming 200k+ context before you need them.

Flowchart Usage

digraph when_flowchart {
    "Need to show information?" [shape=diamond];
    "Decision where I might go wrong?" [shape=diamond];
    "Use markdown" [shape=box];
    "Small inline flowchart" [shape=box];

    "Need to show information?" -> "Decision where I might go wrong?" [label="yes"];
    "Decision where I might go wrong?" -> "Small inline flowchart" [label="yes"];
    "Decision where I might go wrong?" -> "Use markdown" [label="no"];
}

Use flowcharts ONLY for:

  • Non-obvious decision points
  • Process loops where you might stop too early
  • "When to use A vs B" decisions

Never use flowcharts for:

  • Reference material → Tables, lists
  • Code examples → Markdown blocks
  • Linear instructions → Numbered lists
  • Labels without semantic meaning (step1, helper2)

See @graphviz-conventions.dot for graphviz style rules.

Visualizing for your human partner: Use render-graphs.js in this directory to render a skill's flowcharts to SVG:

./render-graphs.js ../some-skill           # Each diagram separately
./render-graphs.js ../some-skill --combine # All diagrams in one SVG

Code Examples

One excellent example beats many mediocre ones

Choose most relevant language:

  • Testing techniques → TypeScript/JavaScript
  • System debugging → Shell/Python
  • Data processing → Python

Good example:

  • Complete and runnable
  • Well-commented explaining WHY
  • From real scenario
  • Shows pattern clearly
  • Ready to adapt (not generic template)

Don't:

  • Implement in 5+ languages
  • Create fill-in-the-blank templates
  • Write contrived examples

You're good at porting - one great example is enough.

File Organization

Self-Contained Skill
defense-in-depth/
  SKILL.md    # Everything inline

When: All content fits, no heavy reference needed

Skill with Reusable Tool
condition-based-waiting/
  SKILL.md    # Overview + patterns
  example.ts  # Working helpers to adapt

When: Tool is reusable code, not just narrative

Skill with Heavy Reference
pptx/
  SKILL.md       # Overview + workflows
  pptxgenjs.md   # 600 lines API reference
  ooxml.md       # 500 lines XML structure
  scripts/       # Executable tools

When: Reference material too large for inline

The Iron Law (Same as TDD)

NO SKILL WITHOUT A FAILING TEST FIRST

This applies to NEW skills AND EDITS to existing skills.

Write skill before testing? Delete it. Start over. Edit skill without testing? Same violation.

No exceptions:

  • Not for "simple additions"
  • Not for "just adding a section"
  • Not for "documentation updates"
  • Don't keep untested changes as "reference"
  • Don't "adapt" while running tests
  • Delete means delete

REQUIRED BACKGROUND: The superpowers:test-driven-development skill explains why this matters. Same principles apply to documentation.

Testing All Skill Types

Different skill types need different test approaches:

Discipline-Enforcing Skills (rules/requirements)

Examples: TDD, verification-before-completion, designing-before-coding

Test with:

  • Academic questions: Do they understand the rules?
  • Pressure scenarios: Do they comply under stress?
  • Multiple pressures combined: time + sunk cost + exhaustion
  • Identify rationalizations and add explicit counters

Success criteria: Agent follows rule under maximum pressure

Technique Skills (how-to guides)

Examples: condition-based-waiting, root-cause-tracing, defensive-programming

Test with:

  • Application scenarios: Can they apply the technique correctly?
  • Variation scenarios: Do they handle edge cases?
  • Missing information tests: Do instructions have gaps?

Success criteria: Agent successfully applies technique to new scenario

Pattern Skills (mental models)

Examples: reducing-complexity, information-hiding concepts

Test with:

  • Recognition scenarios: Do they recognize when pattern applies?
  • Application scenarios: Can they use the mental model?
  • Counter-examples: Do they know when NOT to apply?

Success criteria: Agent correctly identifies when/how to apply pattern

Reference Skills (documentation/APIs)

Examples: API documentation, command references, library guides

Test with:

  • Retrieval scenarios: Can they find the right information?
  • Application scenarios: Can they use what they found correctly?
  • Gap testing: Are common use cases covered?

Success criteria: Agent finds and correctly applies reference information

Common Rationalizations for Skipping Testing

Excuse Reality
"Skill is obviously clear" Clear to you ≠ clear to other agents. Test it.
"It's just a reference" References can have gaps, unclear sections. Test retrieval.
"Testing is overkill" Untested skills have issues. Always. 15 min testing saves hours.
"I'll test if problems emerge" Problems = agents can't use skill. Test BEFORE deploying.
"Too tedious to test" Testing is less tedious than debugging bad skill in production.
"I'm confident it's good" Overconfidence guarantees issues. Test anyway.
"Academic review is enough" Reading ≠ using. Test application scenarios.
"No time to test" Deploying untested skill wastes more time fixing it later.

All of these mean: Test before deploying. No exceptions.

Bulletproofing Skills Against Rationalization

Skills that enforce discipline (like TDD) need to resist rationalization. Agents are smart and will find loopholes when under pressure.

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.

Close Every Loophole Explicitly

Don't just state the rule - forbid specific workarounds:

<Bad> ```markdown Write code before test? Delete it. ``` </Bad><Good> ```markdown Write code before test? Delete it. Start over.

No exceptions:

  • Don't keep it as "reference"
  • Don't "adapt" it while writing tests
  • Don't look at it
  • Delete means delete
</Good>

### Address "Spirit vs Letter" Arguments

Add foundational principle early:

```markdown
**Violating the letter of the rules is violating the spirit of the rules.**

This cuts off entire class of "I'm following the spirit" rationalizations.

Build Rationalization Table

Capture rationalizations from baseline testing (see Testing section below). Every excuse agents make goes in the table:

| Excuse                           | Reality                                                                 |
| -------------------------------- | ----------------------------------------------------------------------- |
| "Too simple to test"             | Simple code breaks. Test takes 30 seconds.                              |
| "I'll test after"                | Tests passing immediately prove nothing.                                |
| "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
Create Red Flags List

Make it easy for agents to self-check when rationalizing:

## Red Flags - STOP and Start Over

- Code before test
- "I already manually tested it"
- "Tests after achieve the same purpose"
- "It's about spirit not ritual"
- "This is different because..."

**All of these mean: Delete code. Start over with TDD.**
Update CSO for Violation Symptoms

Add to description: symptoms of when you're ABOUT to violate the rule:

description: use when implementing any feature or bugfix, before writing implementation code

RED-GREEN-REFACTOR for Skills

Follow the TDD cycle:

RED: Write Failing Test (Baseline)

Run pressure scenario with subagent WITHOUT the skill. Document exact behavior:

  • What choices did they make?
  • What rationalizations did they use (verbatim)?
  • Which pressures triggered violations?

This is "watch the test fail" - you must see what agents naturally do before writing the skill.

GREEN: Write Minimal Skill

Write skill that addresses those specific rationalizations. Don't add extra content for hypothetical cases.

Run same scenarios WITH skill. Agent should now comply.

REFACTOR: Close Loopholes

Agent found new rationalization? Add explicit counter. Re-test until bulletproof.

Testing methodology: See @testing-skills-with-subagents.md for the complete testing methodology:

  • How to write pressure scenarios
  • Pressure types (time, sunk cost, authority, exhaustion)
  • Plugging holes systematically
  • Meta-testing techniques

Anti-Patterns

❌ Narrative Example

"In session 2025-10-03, we found empty projectDir caused..." Why bad: Too specific, not reusable

❌ Multi-Language Dilution

example-js.js, example-py.py, example-go.go Why bad: Mediocre quality, maintenance burden

❌ Code in Flowcharts
step1 [label="import fs"];
step2 [label="read file"];

Why bad: Can't copy-paste, hard to read

❌ Generic Labels

helper1, helper2, step3, pattern4 Why bad: Labels should have semantic meaning

STOP: Before Moving to Next Skill

After writing ANY skill, you MUST STOP and complete the deployment process.

Do NOT:

  • Create multiple skills in batch without testing each
  • Move to next skill before current one is verified
  • Skip testing because "batching is more efficient"

The deployment checklist below is MANDATORY for EACH skill.

Deploying untested skills = deploying untested code. It's a violation of quality standards.

Skill Creation Checklist (TDD Adapted)

IMPORTANT: Use TodoWrite to create todos for EACH checklist item below.

RED Phase - Write Failing Test:

  • Create pressure scenarios (3+ combined pressures for discipline skills)
  • Run scenarios WITHOUT skill - document baseline behavior verbatim
  • Identify patterns in rationalizations/failures

GREEN Phase - Write Minimal Skill:

  • Name uses only letters, numbers, hyphens (no parentheses/special chars)
  • YAML frontmatter with only name and description (max 1024 chars)
  • Description starts with "Use when..." and includes specific triggers/symptoms
  • Description written in third person
  • Keywords throughout for search (errors, symptoms, tools)
  • Clear overview with core principle
  • Address specific baseline failures identified in RED
  • Code inline OR link to separate file
  • One excellent example (not multi-language)
  • Run scenarios WITH skill - verify agents now comply

REFACTOR Phase - Close Loopholes:

  • Identify NEW rationalizations from testing
  • Add explicit counters (if discipline skill)
  • Build rationalization table from all test iterations
  • Create red flags list
  • Re-test until bulletproof

Quality Checks:

  • Small flowchart only if decision non-obvious
  • Quick reference table
  • Common mistakes section
  • No narrative storytelling
  • Supporting files only for tools or heavy reference

Deployment:

  • Commit skill to git and push to your fork (if configured)
  • Consider contributing back via PR (if broadly useful)

Discovery Workflow

How future Claude finds your skill:

  1. Encounters problem ("tests are flaky")
  2. Finds SKILL (description matches)
  3. Scans overview (is this relevant?)
  4. Reads patterns (quick reference table)
  5. Loads example (only when implementing)

Optimize for this flow - put searchable terms early and often.

The Bottom Line

Creating skills IS TDD for process documentation.

Same Iron Law: No skill without failing test first. Same cycle: RED (baseline) → GREEN (write skill) → REFACTOR (close loopholes). Same benefits: Better quality, fewer surprises, bulletproof results.

If you follow TDD for code, follow it for skills. It's the same discipline applied to documentation.

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

Discussion

Alternatives