/hyperpowers:writing-skillsfrom hyperpowers
Creates and edits skills using a TDD cycle: write a failing test (pressure scenario), write the skill, verify it passes, then refactor to close loopholes.
Ships in hyperpowers. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
<skill_overview> Writing skills IS test-driven development applied to process documentation; write test (pressure scenario), watch fail (baseline), write skill, watch pass, refactor (close loopholes). </skill_overview>
<rigidity_level> LOW FREEDOM - Follow the RED-GREEN-REFACTOR cycle exactly when creating skills. No skill without failing test first. Same Iron Law as TDD. </rigidity_level>
<quick_reference>
| Phase | Action | Verify |
|---|---|---|
| RED | Create pressure scenarios | Document baseline failures |
| RED | Run WITHOUT skill | Agent violates rule |
| GREEN | Write minimal skill | Addresses baseline failures |
| GREEN | Run WITH skill | Agent now complies |
| REFACTOR | Find new rationalizations | Agent still complies |
| REFACTOR | Add explicit counters | Bulletproof against excuses |
| DEPLOY | Commit and optionally PR | Skill ready for use |
Iron Law: NO SKILL WITHOUT FAILING TEST FIRST (applies to new skills AND edits) </quick_reference>
<when_to_use> Create skill when:
Never create for:
Edit existing skill when:
ALWAYS test before writing or editing. No exceptions. </when_to_use>
<tdd_mapping> Skills use the exact same TDD cycle as code:
| TDD Concept | Skill Creation |
|---|---|
| Test case | Pressure scenario with subagent |
| Production code | Skill document (SKILL.md) |
| Test fails (RED) | Agent violates rule without skill |
| 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 |
REQUIRED BACKGROUND: You MUST understand hyperpowers:test-driven-development before using this skill. </tdd_mapping>
<the_process>
Create pressure scenarios for subagent:
Task tool with general-purpose agent:
"You are implementing a payment processing feature. User requirements:
- Process credit card payments
- Handle retries on failure
- Log all transactions
[PRESSURE 1: Time] You have 10 minutes before deployment.
[PRESSURE 2: Sunk Cost] You've already written 200 lines of code.
[PRESSURE 3: Authority] Senior engineer said 'just make it work, tests can wait.'
Implement this feature."
Run WITHOUT skill present.
Document baseline behavior:
Example baseline result:
Agent response:
"I'll implement the payment processing quickly since time is tight..."
[Skips TDD]
[Skips verification-before-completion]
[Claims done without evidence]
This is your failing test. Agent doesn't follow the workflow without guidance.
Write skill that addresses the SPECIFIC failures from baseline:
Structure:
---
name: skill-name-with-hyphens
description: Use when [specific triggers] - [what skill does]
---
<skill_overview>
One sentence core principle
</skill_overview>
<rigidity_level>
LOW | MEDIUM | HIGH FREEDOM - [What this means]
</rigidity_level>
[Rest of standard XML structure]
Frontmatter rules:
name and description fields (max 1024 chars total)Description format:
# ❌ BAD: Too abstract, first person
description: I can help with async tests when they're flaky
# ✅ GOOD: Starts with "Use when", describes problem
description: Use when tests have race conditions or pass/fail inconsistently - replaces arbitrary timeouts with condition polling for reliable async tests
Write skill addressing baseline failures:
Run WITH skill present.
Verify agent now complies:
This is your passing test.
Find NEW rationalizations:
Run skill with DIFFERENT pressures:
Document new failures:
Add counters to skill:
<critical_rules>
## Common Excuses
All of these mean: [Action to take]
- "Test can wait" (NO, test first always)
- "Simple feature" (Simple breaks too, test first)
- "Time pressure" (Broken code wastes more time)
[Add ALL rationalizations found during testing]
</critical_rules>
Re-test until bulletproof:
Before deployment, verify:
<quick_reference> section (scannable table)<rigidity_level> explicit<example> tags showing failure modesToken efficiency:
Commit to git:
git add skills/skill-name/
git commit -m "feat: add [skill-name] skill
Tested with subagents under [pressures used].
Addresses [baseline failures found].
Closes rationalizations:
- [Rationalization 1]
- [Rationalization 2]"
Personal skills: Write to ~/.claude/skills/ for cross-project use
Plugin skills: PR to plugin repository if broadly useful
STOP: Before moving to next skill, complete this entire process. No batching untested skills. </the_process>
Developer writes skill without testing first
# Developer writes skill:
"---
name: always-use-tdd
description: Always write tests first
---
Write tests first. No exceptions."
Then tries to deploy it
<why_it_fails>
RED Phase:
GREEN Phase:
REFACTOR Phase:
What you gain:
# Existing skill works well
# Developer thinks: "I'll just add this section about edge cases"
[Adds 50 lines to skill]
Commits without testing
<why_it_fails>
RED Phase (for edit):
GREEN Phase (edit):
REFACTOR Phase:
What you gain:
---
name: async-testing
description: For testing async code
---
Skill content...
<why_it_fails>
---
name: condition-based-waiting
description: Use when tests have race conditions, timing dependencies, or pass/fail inconsistently - replaces arbitrary timeouts with condition polling for reliable async tests
---
Why this works:
What you gain:
<skill_types>
Concrete method with steps to follow.
Examples: condition-based-waiting, hyperpowers:root-cause-tracing
Test approach: Pressure scenarios with combined pressures
Way of thinking about problems.
Examples: flatten-with-flags, test-invariants
Test approach: Present problems the pattern solves, verify agent applies pattern
API docs, syntax guides, tool documentation.
Examples: Office document manipulation, API reference guides
Test approach: Give task requiring reference, verify agent uses it correctly
For detailed testing methodology by skill type: See resources/testing-methodology.md </skill_types>
<file_organization>
defense-in-depth/
SKILL.md # Everything inline
When: All content fits, no heavy reference needed
condition-based-waiting/
SKILL.md # Overview + patterns
example.ts # Working helpers to adapt
When: Tool is reusable code, not just narrative
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 (>100 lines)
Keep inline:
<search_optimization>
Future Claude needs to FIND your skill. Optimize for search.
Format: Start with "Use when..." + triggers + what it does
# ❌ BAD: Too abstract
description: For async testing
# ❌ BAD: First person
description: I can help you with async tests
# ✅ GOOD: Triggers + problem + solution
description: Use when tests have race conditions or pass/fail inconsistently - replaces arbitrary timeouts with condition polling
Use words Claude would search for:
Problem: Frequently-referenced skills load into EVERY conversation.
Target word counts:
Techniques:
Verification:
wc -w skills/skill-name/SKILL.md
Use skill name only, with explicit markers:
**REQUIRED BACKGROUND:** You MUST understand hyperpowers:test-driven-development
**REQUIRED SUB-SKILL:** Use hyperpowers:debugging-with-tools first
Don't use @ links: Force-loads files immediately, burns context unnecessarily. </search_optimization>
<critical_rules>
All of these mean: STOP. Run baseline test first.
Same as TDD:
NO SKILL WITHOUT FAILING TEST FIRST
No exceptions for:
Write skill before testing? Delete it. Start over. </critical_rules>
<verification_checklist> Before deploying ANY skill:
RED Phase:
GREEN Phase:
<quick_reference> section<rigidity_level> explicit<example> tagsREFACTOR Phase:
Quality:
Deploy:
Can't check all boxes? Return to process and fix. </verification_checklist>
**This skill requires:** - hyperpowers:test-driven-development (understand TDD before applying to docs) - Task tool (for running subagent tests)This skill is called by:
Agents used:
When stuck:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
skill-development, tdd, test-driven-development, skill-testing
npx claudepluginhub withzombies/hyperpowers --plugin hyperpowers22 skills in this plugin
/analyzing-test-effectivenessUse to audit test quality with SRE scrutiny - identifies weak tests, missing cases, and creates task docs for improvements/brainstormingUse when shaping a feature before implementation - turns rough ideas into an approved markdown spec and local task directory/building-hooksUse when creating Claude Code hooks - covers hook patterns, composition, testing, progressive enhancement from simple to advanced/debugging-with-toolsUse when encountering bugs or test failures - systematic debugging using debuggers, internet research, and agents to find root cause before fixing/dispatching-parallel-agentsUse when facing 3+ independent failures that can be investigated without shared state or dependencies - dispatches multiple Claude agents to investigate and fix independent problems concurrently/executing-plansUse to execute an approved local markdown task directory iteratively - work the current Now slice, update docs, then stopOther plugins' skills for the same job