writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
By obra · 188,140 installs
npx skills add obra/superpowers --skill writing-skills
Source repository · Upstream listing
Writing Skills
Overview
Writing skills IS Test Driven Development applied to process documentation.
Personal skills live in your runtime's skills directory ( ~/.claude/skills/ on Claude Code) — see [codex tools.md](../using superpowers/references/codex tools.md) or [gemini tools.md](../using superpowers/references/gemini tools.md) for the path on those runtimes. Codex, Copilot CLI, and Gemini CLI all also recognize ~/.agents/skills/ as a cross runtime alias.
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 references/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 agents 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 your instructions file)
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
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
Writing SKILL.md
A skill's description says only when to use it: triggering conditions and
symptoms, starting with "Use when...". It never summarizes the skill's
workflow, because an agent that reads a workflow summary follows it instead
of reading the skill.
When you write or change a skill's frontmatter, name or description, or
need to cut its size, read [references/discovery.md](references/discovery.md):
the SKILL.md template, description and keyword guidance, naming, token
budgets, and cross referencing other skills.
Flowcharts
When you add or change a flowchart in a skill, read
[references/flowcharts.md](references/flowcharts.md) first: when a flowchart
earns its place, the graphviz conventions, and how to render one.
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
When: All content fits, no heavy reference needed
Skill with Reusable Tool
When: Tool is reusable code, not just narrative
Skill with Heavy Reference
When: Reference material too large for inline
Invoke bundled scripts through their interpreter in the prose ( bash scripts/tool.sh , node scripts/tool.js ), never by bare path: some harness plugin packagers strip executable bits, and a bare scripts/tool.sh fails there with Permission denied .
The Iron Law (Same as TDD)
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.
Match the Form to the Failure
Before writing guidance, classify the baseline failure. The form that bulletproofs one failure type measurably backfires on another.
Baseline failure Right form Wrong form
Skips/violates a rule under pressure (knows better, does it anyway) Prohibition + rationalization table + red flags (see references/bulletproofing.md) Soft guidance ("prefer...", "consider...")
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")
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
Behavior should depend on a condition Conditional keyed to an observable predicate ("if the brief exists, reference it") Unconditional rule + exemption clauses
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.
Rules for whichever form you pick:
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.
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.
Bulletproofing Against Rationalization
When the baseline failure is a discipline failure, read
[references/bulletproofing.md](references/bulletproofing.md) before you write
the guidance: closing loopholes, the spirit vs letter line, the
rationalization table, and the red flags list.
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.
Micro Test Wording Before Full Scenarios
Full pressure scenario runs are the final gate, but they are slow and expensive per iteration. Verify the wording itself first with micro tests:
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.
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.
3. 5+ reps per variant. Single samples lie.
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.
5. Variance is a metric. When g