Skip to content

Writing skills

How to write a skill for this marketplace, and why the rules are what they are. The rules themselves—short, with stable IDs—are in .claude/rules/writing-skills.md (.claude/rules/writing-skills.md), which Claude loads when it works on a skill. The skill-audit skill checks skills against them.

Sources, in order of precedence: Anthropic's skill authoring best practices, the Claude Code skills and plugin documentation (for what only Claude Code has), then the conventions of this repository. A convention of ours may add to the first two, never contradict them.

Contents

  1. What a skill is, and when to write one
  2. Core principles
  3. Frontmatter
  4. Structure and progressive disclosure
  5. Writing the content
  6. Scripts
  7. Testing
  8. Review checklist
  9. Tools that help

1. What a skill is, and when to write one

A skill is a folder with a SKILL.md: YAML frontmatter (name, description) and Markdown instructions, optionally with reference files and scripts. Claude decides from the description alone whether to load it. Skills load in three levels:

Level What When it costs context
1—metadata name and description in every request, for every installed skill
2—body SKILL.md once the skill is invoked; it then stays in the conversation
3—files reference files, scripts a reference when Claude reads it; a script only with its output

A skill is the right tool for procedural knowledge that is needed sometimes. For other needs there is a better one:

Need Use Why
A fact true for every task in a repository (build command, layout) CLAUDE.md always loaded—so keep it short, every token is paid on every request
A procedure needed for some tasks (review, release, migration) skill costs only its description until used
Something that must happen every time, without exception hook deterministic; prose in a skill can be forgotten or compacted away
A large search or review whose raw output should not fill the context subagent, or a skill with context: fork own context window, returns a summary
Access to an external system (GitHub, Notion) MCP server or CLI a skill can then describe how to use it

2. Core principles

Concise is key. The context window is shared. Assume Claude is already very capable and add only what it cannot know: our conventions, our systems, our pitfalls. Ask of every paragraph whether Claude needs it and whether it earns its tokens. "Use pdfplumber for text extraction:" and three lines of code beat a paragraph explaining what a PDF is.

Capabilities, not storage. A skill says how to do something, not everything that might be relevant. What Claude can read or fetch itself—a file in the repository, git log, ./gradlew dependencies, a Notion page through the connector—the skill points to instead of pasting. Copied knowledge goes stale and competes with the task. This is also why the workflow skills read a repository's names from its CLAUDE.md instead of carrying them.

Strictness matches fragility, per step. Ask what happens if Claude does a step differently.

Freedom Form When
High heuristics in prose, with the reason behind them several approaches are valid, context decides—judging a review finding
Medium template or pseudocode with parameters a preferred pattern exists—a commit message format
Low an exact command or a script, "do not modify" fragile, consequential or order-dependent—anything with money, deleting, sending, merging or other irreversible effects

Decide it per step, not once per skill: in babysit-pr, merging is low freedom (exact conditions, gh pr merge --squash), while judging a finding is high freedom.

Write for the models in use, and test with them. Smaller models (Haiku) need explicit guidance and skip steps that are only implied; current large models (Opus) get worse when over-prescribed. Instructions written for older models—capitals for emphasis, MUST on every line, explaining the obvious—cost tokens and make the skill rigid. We use Opus and Sonnet in sessions and Haiku for background work: test with all three (section 7).

3. Frontmatter

Field Rule
name ≤ 64 characters; lowercase letters, digits, hyphens; no XML; must not contain "anthropic" or "claude". Gerund form (processing-pdfs) is preferred, noun or action names (pdf-processing, babysit-pr) are fine. One style per plugin; never rename an existing skill—it breaks the /command.
description Non-empty, ≤ 1,024 characters, no XML. Says what the skill does and when to use it, with the words users actually type. Third person ("Watches…", not "Watch…", "I can…", "You can…"): it is injected into the system prompt. The "when" part may be an instruction ("Use when…"). Describe the user's goal, not the skill's mechanics, and be a little pushy: name the contexts where the user does not say the domain word ("…even if they do not mention a PR").

The description is the most important line: Claude picks from over a hundred skills with it, and it is paid for in every request.

Bad Good
Helps with documents Extracts text and tables from PDF files, fills forms, merges documents. Use when working with PDF files or when the user mentions PDFs, forms or document extraction.
Watch a PR until it is green Watches an open GitHub pull request until it is green and mergeable … Use when the user asks to babysit, watch or shepherd a PR, or right after a pull request has been opened.

Claude Code fields worth knowing:

Field Use it for
argument-hint Autocomplete hint. Always quote it: an unquoted value starting with [ is a YAML list, and a strict parser rejects the whole frontmatter.
when_to_use Extra trigger phrases, appended to the description in Claude Code only. Other platforms ignore it, so the description must already carry the essential "when".
disable-model-invocation: true Skills whose purpose is the side effect itself (release, deploy, publish): Claude never starts them on its own. Skills that only write along the way stay invocable—they are meant to work autonomously—and leave every write out of allowed-tools, so each one is confirmed (SK-5).
user-invocable: false Building blocks that only Claude or other skills call.
allowed-tools Pre-approve the commands the skill runs, for example Bash(pr-watch snapshot:*).
context: fork with agent Run in an isolated subagent, for broad, read-heavy work.
model, effort Override for this skill, for example a cheaper model for a mechanical task.
paths Activate only for matching files.
${CLAUDE_SKILL_DIR}, ${CLAUDE_PLUGIN_ROOT} Reach bundled files without absolute paths.
!`command` Dynamic context: the command runs before Claude reads the skill, and its output replaces the placeholder.

4. Structure and progressive disclosure

  • SKILL.md under 500 lines and about 5,000 tokens. Treat it as the table of contents; move detail into files and link them.
  • References one level deep. SKILL.md links every file Claude needs directly. When a file sends Claude on to a third one, Claude may only preview it and miss content.
  • Say when to read each file. "Read reference/api-errors.md when the API returns a non-200 status" loads it on demand; "see reference/ for details" leaves Claude guessing.
  • The 100-line problem. Claude often previews the first ~100 lines of a file to judge whether it is relevant. Every file over 100 lines starts with a contents list matching its headings, and the rules that must never be missed sit in those first 100 lines—not at the end.
  • Descriptive names by area: reference/verdicts.md, not docs/file1.md. Forward slashes, also on Windows.
  • Bundle generously, load selectively. Large references cost nothing until read. Prefer a script for deterministic work.

Layout of a skill in this marketplace:

plugins/<plugin>/
├── bin/                   # executables Claude Code puts on the Bash PATH (e.g. pr-watch)
├── evals/<skill>-<case>/  # at least three cases per skill (section 7); results/ is git-ignored
├── reference/             # files used by two or more skills of this plugin
├── tests/                 # tests for bin/ and hooks/, run by scripts/ci/check-plugins.sh
└── skills/<skill>/
    ├── SKILL.md           # overview and workflow; links every file below directly
    ├── reference/<area>.md
    └── scripts/           # deterministic helpers, executed rather than read; test_*.py or *.Tests.ps1 next to them

The evals sit at the plugin level because claude plugin eval refuses an eval directory inside skills/, a directory it loads components from. A case name starts with its skill's name, so --case '<skill>-*' runs one skill's cases.

A skill that needs another plugin's rules names that skill instead of copying them, as workflow:ready reads the section "Fix, reject or escalate" of git-flow:babysit-pr.

5. Writing the content

Checklists for ordered work. Where order matters, give Claude numbered steps and a checklist to copy and tick off, with the way back when a step fails:

- [ ] 1. Analyse the form (run scripts/analyze_form.py)
- [ ] 2. Create the field mapping (edit fields.json)
- [ ] 3. Validate the mapping (run scripts/validate_fields.py) — on failure go back to step 2
- [ ] 4. Fill the form
- [ ] 5. Verify the output — on failure go back to step 2

Gotchas. Often the most valuable part of a skill: facts about our environment that defy a reasonable assumption, each a correction Claude would otherwise need—"the /health endpoint returns 200 even when the database is down; check /ready". Not general advice. Keep them in a "Gotchas" section of SKILL.md, where Claude reads them before it meets the situation; in a reference file it may not recognise when to look. Each time you correct Claude while it uses the skill, add the correction there.

Feedback loops where quality matters. Check the output against something concrete—a script, a rule catalogue, a style guide—fix it, check again, and only then go on.

Templates and examples. A template says how strict it is: "always this exact structure" for output a machine reads, "a sensible default, adapt as needed" for a report. Input/output pairs show style and detail better than a description. Split a conditional workflow early ("Creating? → … Editing? → …") and move big branches into their own files.

Language.

  • One term per concept, throughout the skill and the files it uses.
  • One default plus an escape hatch—"use pdfplumber; for scanned PDFs use pdf2image"—not a menu of five libraries.
  • Nothing time-sensitive ("before August 2025 use …"). Legacy behaviour goes into a collapsed "Old patterns" section.
  • MCP tools by their full name, for example mcp__plugin_github_github__create_pull_request.

Report first, change on approval. A skill that reviews or audits reports by default and changes files only for findings the user approved after seeing them, or behind a --fix flag it defines; each finding carries the exact change. "Audit this and fix everything" is not an approval of findings nobody has seen yet.

Hard limits are hooks, not prose. A rule that must hold every time—formatting before a commit, a path that must never be written—is enforced by a hook, like backend's Spotless hook.

6. Scripts

  • Solve, don't defer: handle the error in the script (missing file, no permission) instead of failing and leaving it to Claude.
  • No unexplained constants: every timeout or retry count says why, as pr_watch.py does.
  • Execute or read? Say which: "run pr-watch snapshot" vs. "see pr_watch.py for the decision logic".
  • Dependencies next to the step that needs them, never in a separate setup chapter:

    Step 3 — extract the tables. Needs pdfplumber; check and install if missing:
        python -c "import pdfplumber" || pip install pdfplumber
    Then run: python scripts/extract_tables.py input.pdf > tables.json
    
  • Missing prerequisites fail the tests. A test that skips when its package is missing makes the run green while testing nothing—check-plugins.sh once passed with 8 of measure_skill.py's 9 tests skipped, because the first Python it found had no PyYAML. Fail instead, and name the interpreter and the install line; CI installs what the tests need.

  • Plan → validate → execute for batch or destructive work: Claude writes a plan file, a script validates it with specific error messages, then it is applied.
  • Cross-platform. A script runs on Linux and in Git Bash on Windows. Pick a Python that actually runs (the Windows Store python3 stub does not) and use builtins over external tools where a test may restrict PATH. Scripts are committed LF and executable (100755).

7. Testing

A skill is code for a model. Test it in layers, cheapest first.

  1. Static checks (seconds). claude plugin validate <dir> --strict for frontmatter and structure; bash scripts/ci/check-plugins.sh for project names and the script tests. Claude Code's loader is lenient, so frontmatter that a strict parser rejects can go unnoticed while other tools drop the description—and validate --strict does not check skill frontmatter keys, so a misspelled field silently does nothing. skill-audit's measure_skill.py checks both. Limits: name ≤ 64, description ≤ 1,024, body < 500 lines and about 5,000 tokens. Every script and hook has its tests next to it (tests/*-test.sh, scripts/test_*.py, scripts/*.Tests.ps1). PowerShell tests use Pester at the version pinned in scripts/ci/run-pester.ps1; it prints the install line when that version is missing. A script with a main block dot-sources cleanly when it stops before that block on $MyInvocation.InvocationName -eq '.', as dev-doctor.ps1 does.
  2. Triggering. The skill shows up in /skills; invoking it by name separates "does not trigger" from "does not work". Write prompts the way users phrase them, including near misses that must not trigger it: prompts that share the skill's words but need something else ("write a Fibonacci function" tests nothing). A one-step task Claude can do with its own tools may not trigger even a perfect description, so make the positive prompts tasks the skill would help with. When a description keeps misfiring, tune it systematically—about 20 labelled queries, several runs each, a fixed train/validation split—as described in Optimizing skill descriptions; skill-creator automates that loop.
  3. Behaviour evaluations (minutes). Evaluation-driven: run Claude on representative tasks without the skill, write down where it fails, build three cases from those failures, measure the baseline, then write just enough skill to pass. claude plugin eval runs cases against a plugin with a no-plugin baseline (--ablation with-without), three runs per case by default; claude plugin eval init drafts a suite. Keep the expected result in the case definition, never in the fixture—a comment saying "keep this" hands the skill its answer. Grade the artifacts a run produced, not what the run claims it did, and let a pass cite its evidence: a section titled "Summary" with one vague sentence is not a summary. One isolated run per arm. When changing a skill that exists, the baseline is its previous version, not "no skill". Drop an expected result that passes in both arms—it measures the model, not the skill—and compare the tokens and time of both arms too: a small gain for double the cost may not pay.

    How to run them here—a plugin with dependencies, and a case whose run cannot execute the skill's helper: evals.md.

  4. Clean environment. A skill that works on its author's machine may depend on it: a CLI that happens to be installed, an environment variable, an MCP login, a personal CLAUDE.md or memory entry. Run it once on the other machine—the owner's workstation and the Linux host differ in exactly these ways—before it is shared, and again when it starts using a new tool. Every failure is a missing prerequisite: document it next to the step, add it to dev-env:dev-doctor, or make the skill degrade gracefully.

  5. Real use (ongoing). One Claude helps write the skill, a fresh one with the skill installed does real tasks; bring the second one's mistakes back to the first. Watch which files Claude reads and which it never opens—an unread file is unnecessary or badly signposted. When Claude writes the same helper on every run, bundle it as a tested script. Try every model in use: Haiku (enough guidance?), Sonnet (clear and efficient?), Opus (over-explained?). /skill-doctor shows invocations and context cost per skill: retire what nobody uses.

8. Review checklist

Copy into the description of every pull request that adds or changes a skill. The IDs are those of .claude/rules/writing-skills.md (.claude/rules/writing-skills.md).

Discovery
- [ ] name valid and consistent with the plugin (SK-1)
- [ ] description: what + when, users' words and goal, third person, ≤ 1,024 chars (SK-2, SK-3)
- [ ] frontmatter parses strictly; argument-hint quoted (SK-4)
Structure
- [ ] body < 500 lines, ~5,000 tokens; every file linked directly, with when (SK-6, SK-7)
- [ ] files > 100 lines: contents list, key rules in the first 100 (SK-8)
Content
- [ ] only what Claude does not know; points instead of copying (SK-11, SK-12)
- [ ] strictness chosen per step (SK-13); checklist and feedback loop where needed (SK-14)
- [ ] one term per concept, no dates or "new/old" wording (SK-16, SK-17)
- [ ] surprising facts in a Gotchas section of SKILL.md (SK-33)
- [ ] scripts: errors handled, constants explained, install line next to the step (SK-22)
- [ ] tests fail, never skip, when a prerequisite is missing (SK-22)
This repository
- [ ] no fixed paths, no project names, English, no secrets (SK-24 … SK-26)
- [ ] plugin version bumped (SK-27)
Testing
- [ ] validate --strict and check-plugins.sh green (SK-28)
- [ ] ≥ 3 evals incl. a near miss that must not trigger; baseline run (SK-29, SK-30)
- [ ] tested with Opus, Sonnet and Haiku; models recorded (SK-31)
- [ ] run on the other machine without personal setup (SK-32)

9. Tools that help

  • skill-audit (this repository, .claude/skills/): audits skills against the rules, reports per skill, and changes only what you approve.
  • Ask Claude. It knows the skill format: "create a skill from the procedure we just went through"—then cut what Claude already knows.
  • skill-creator (Anthropic plugin): creates and improves skills, runs evals and benchmarks, tunes descriptions for triggering.
  • superpowers:writing-skills: a test-driven process for skills.
  • docs/references.md: outside guides and example collections worth starting from, such as the Claude Code Ultimate Guide.