How to Write a SKILL.md That Triggers

An agent loads your skill only if the description matches. The frontmatter rules, trigger clause and body limits, with the validator check for each.

· 4 min read · Skillland

AuthoringValidator

An agent does not read your skill before it decides to use it. At startup it reads only the name and description from each SKILL.md frontmatter, about 100 tokens per skill, and loads the body when a request matches (Agent Skills overview). Everything below the frontmatter only matters once the description has done its job.

This guide walks through the rules in order of how often they break a skill, and names the validator rule that checks each one.

Get the frontmatter past the spec

The Agent Skills specification has two required fields:

FieldLimit
name1 to 64 characters: lowercase a-z, 0-9 and hyphens, no leading, trailing or double hyphen, and equal to the folder name
description1 to 1024 characters, non-empty

The Claude API adds two more: neither field may contain XML tags, and the name may not contain anthropic or claude (Agent Skills overview). The validation scripts in Anthropic's and OpenAI's skill creators go further and reject any < or > in the description, so write "the skill name" instead of <name>.

A minimal valid file:

---
name: commit-message-writer
description: Writes a conventional commit message from the staged diff. Use when the user asks for a commit message or wants to commit staged changes.
---

# Commit message writer

Broken YAML is the quietest failure. Claude Code skips a skill whose frontmatter does not parse and writes the reason only to its debug log, so the skill just never appears. Quote any value that contains : or starts with a special character. The validator rules are frontmatter-invalid-yaml, name-format, name-matches-folder and description-too-long.

Say when to use the skill

A description that says what a skill is, but not when to use it, gives the agent nothing to match a request against. Anthropic's guidance is to state what the skill does and when to use it, in the third person, with the words users actually type (best practices).

Compare:

WeakStrong
Helps with PDFs.Extracts text and tables from PDF files, fills forms and merges documents. Use when the user mentions PDFs, forms or document extraction.
You are a commit message expert.Writes a conventional commit message from the staged diff. Use when the user asks for a commit message.

The first row fails description-vague and description-too-short. The second fails description-person: the description is injected into the system prompt, so "You are" reads as an instruction to the model. Both weak versions also fail description-no-trigger, the most common description problem in the skills scored on Skillland. Anthropic's own skills show both sides: the description of pdf opens with when to use it, while frontend-design and webapp-testing never say.

Front-load the use case. Claude Code shows description and when_to_use together in its skill listing and cuts the combined text at 1,536 characters (Claude Code skills docs).

Keep the body short and point to the rest

When a skill triggers, its whole body enters the context window and stays there. Anthropic recommends keeping SKILL.md under 500 lines and the loaded instructions under about 5,000 tokens (best practices). After compaction, Claude Code re-attaches only the first 5,000 tokens of each skill (Claude Code skills docs), so anything past that limit can drop out mid-session.

The fix is progressive disclosure:

  1. Keep the procedure in SKILL.md.
  2. Move long tables, API references and extra examples into references/<topic>.md.
  3. Link each file from the step that needs it, one level deep. A reference file that links to another reference file may only be partly read.
  4. Give any reference file over 100 lines a table of contents at the top.

The validator checks this with body-too-long, body-too-many-tokens, long-body-no-references and, when you upload the folder, broken-links and deep-references.

Write steps and an example

Agents follow numbered procedures more reliably than prose. A body that works well usually has:

  • numbered steps, with one checkpoint such as "check the output is not empty before you continue";
  • one worked example with real input and the expected output.

Both are on the spec's list of recommended sections (specification). The validator reports a missing one as a suggestion (no-steps, no-examples). Suggestions cost 2 points each, so they move a score without failing it.

Keep secrets and blind installs out

Skills get copied into other people's projects. Three patterns are worth catching before you publish:

  • Literal keys or passwords in examples: read them from environment variables instead (hardcoded-secret).
  • curl ... | sh installs, which run whatever the URL serves that day (remote-exec).
  • allowed-tools: Bash, which pre-approves every shell command while the skill is active. Scope it, for example Bash(git diff *) (broad-allowed-tools).

Run the validator on your skill

Paste your SKILL.md, or upload the folder, into the free validator. It runs in the browser, so nothing leaves your machine, and every finding links to the rule that explains it.

share