Writing skills

From seaworld008/Commonly-used-high-value-skills · View interactive version

Writing skills is an AI agent skill from the GitHub repository seaworld008/Commonly-used-high-value-skills. Use when creating new skills, editing existing skills, or verifying skills work before deployment

How to use this skill

Skill file

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

Use baseline and candidate scenarios when evaluating behavior changes. Minor editorial corrections need appropriate static checks, not a mandatory agent-evaluation loop.

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 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:

Don't create for:

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:

SKILL.md Structure

Read the detailed procedure and examples when working on this part of the task.

Skill Discovery Optimization (SDO)

Critical for discovery: Future agents need to FIND your skill

1. Rich Description Field

Read the detailed procedure and examples when working on this part of the task.

2. Keyword Coverage

Use words an agent would search for:

3. Descriptive Naming

Use active voice, verb-first:

4. Token Efficiency (Critical)

Read the detailed procedure and examples when working on this part of the task.

5. Cross-Referencing Other Skills

When writing documentation that references other skills:

Use skill name only, with explicit requirement markers:

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

Flowchart Usage

Read the detailed procedure and examples when working on this part of the task.

Code Examples

Read the detailed procedure and examples when working on this part of the task.

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

Match Verification to the Change

New behavior, changed trigger boundaries, and rules that can alter tool actions need

baseline-versus-candidate scenarios. Record an observable failure mode before

rewriting a behavioral rule; then test whether the revised rule resolves it under

similar pressure. Use a real model evaluation only when one is available, and label

static verification separately from behavior evidence.

Editorial corrections, date/URL fixes, and formatting-only changes need focused

link, lint, example, and repository-generator checks rather than a fabricated

"failing agent" scenario. A changed executable helper needs an executable

regression test. Missing model-evaluation access must be reported, not silently

described as a successful agent test.

Keep reproducible examples and the acceptance checks with the skill. Apply the

repository's source provenance, license and generated-output checks before release;

never replace its own quality gates with a generic slogan.

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:

Success criteria: Agent follows rule under maximum pressure

Technique Skills (how-to guides)

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

Test with:

Success criteria: Agent successfully applies technique to new scenario

Pattern Skills (mental models)

Examples: reducing-complexity, information-hiding concepts

Test with:

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

Reference Skills (documentation/APIs)

Examples: API documentation, command references, library guides

Test with:

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

For behavioral changes, validate the new behavior before deploying. For reference-only edits, use relevant deterministic checks and state the evaluation boundary.

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 Bulletproofing below) | 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:

Bulletproofing Skills Against Rationalization

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

Scope: this toolkit is for discipline failures — an agent that knows the rule and skips it under pressure. For wrong-shaped output or omitted elements, prohibition-based bulletproofing backfires; use the forms in Match the Form to the Failure instead.

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>

Write code before test? Delete it.

</Bad>

<Good>

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:

**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 SDO 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:

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 guidance lands, reps converge on the same shape. Five different interpretations across five reps means the wording isn't binding — tighten the form before adding words.

Micro-tests verify wording; they do not replace pressure scenarios for discipline skills.

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

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

Before shipping a skill, run the checks required by its changed behavior and repository policy. Batch related editorial edits before validation.

Do NOT:

Use the checklist for substantive behavior changes; share static checks across a batch and record the evaluation scope.

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

Skill Creation Checklist (TDD Adapted)

IMPORTANT: Create a todo for EACH checklist item below.

RED Phase - Write Failing Test:

GREEN Phase - Write Minimal Skill:

REFACTOR Phase - Close Loopholes:

Quality Checks:

Deployment:

Discovery Workflow

How future agents find your skill:

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

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

Node Helper Runtime

The bundled package.json marks this skill directory as an ES module scope.

Keep it beside the helper files when copying the skill into a CommonJS project.

This scope declaration does not install dependencies or change the parent project.

Invoke packaged helpers through their interpreters, for example

node render-graphs.js /path/to/skill or bash scripts/tool.sh.

Do not assume a client package preserves executable bits.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.