Course contents
SKILL.md explained: the anatomy of an agent skill
On this page
A skill is a folder
At minimum, a skill is a folder with one file, SKILL.md. The Agent Skills specification defines optional folders around it:
pr-review/
├── SKILL.md # required: frontmatter + instructions
├── scripts/ # optional: code the agent can run
├── references/ # optional: longer docs, loaded only when needed
└── assets/ # optional: templates, schemas, sample data
The folder sits inside a tool's skills directory, for example .claude/skills/pr-review/ or .agents/skills/pr-review/. The file name is always SKILL.md, in capitals.
The frontmatter
SKILL.md starts with YAML frontmatter. The spec defines six fields:
| Field | Required | Rules |
|---|---|---|
name | Yes | 1 to 64 characters: lowercase letters, numbers and hyphens. No leading, trailing or double hyphens. Must match the folder name. |
description | Yes | 1 to 1,024 characters. What the skill does and when to use it. |
license | No | License name or a bundled license file. |
compatibility | No | Up to 500 characters on environment needs, like "Requires git and jq". |
metadata | No | A map of string keys to string values, for your own tooling. |
allowed-tools | No | Experimental. A space-separated list of pre-approved tools. |
---
name: pr-review
description: "Review the current branch's diff for correctness, security and missing tests, and report findings by severity. Use when the user asks for a code review, a PR review, or a pre-merge check. Not for style-only feedback."
license: MIT
---
# PR review
## Steps
1. Get the diff: `git diff --merge-base origin/main`.
2. Read every changed file in full, not just the hunks.
3. Check each change against the project rules in `AGENTS.md`.
4. Look for missing tests for new behavior.
5. Report findings. Don't edit files unless the user asks.
## Output
- One line per finding: severity | file:line | problem | fix.
- If nothing is wrong, say "No findings" and list the files you read.
Progressive disclosure: why skills are cheap
Skills load in three stages, according to the spec:
- Metadata (about 100 tokens):
nameanddescriptionare loaded at startup for every installed skill. - Instructions (under 5,000 tokens recommended): the full
SKILL.mdbody loads when the skill is activated. - Resources (as needed): files in
scripts/,references/andassets/load only when the instructions call for them.
That's why you can install many skills without bloating every request. It's also why the description carries so much weight: until the skill is activated, it's the only part the agent sees.
Keep SKILL.md under 500 lines. Move long reference material into references/ and link it with a relative path, one level deep:
For the full severity rubric, read [references/severity.md](references/severity.md).
Writing the body
The body is free-form Markdown, but the skills that work best share a shape:
- When to run, and when not to. Repeat the trigger in plain words, and name a nearby request that should not use this skill.
- Numbered steps, one action each, in order.
- A stop condition. What to do when a step fails: stop and report the output.
- An output format. A fixed shape makes results easy to scan and compare.
- A short worked example. Input and expected output.
Write steps as standing instructions. In Claude Code, for example, the skill's content enters the conversation once and isn't re-read on later turns, so phrase guidance that should hold for the whole task as rules, not one-time steps (Claude Code skills).
Tool-specific extras
The six spec fields work everywhere. Tools add their own on top:
| Tool | Extra fields and features |
|---|---|
| Claude Code | when_to_use, disable-model-invocation, user-invocable, allowed-tools, disallowed-tools, model, effort, context: fork, agent, paths, hooks, argument-hint, arguments and more |
| Cursor | paths, disable-model-invocation, icon, color (Custom Mode badge) |
| GitHub Copilot (VS Code) | argument-hint, user-invocable, disable-model-invocation |
| Codex | An agents/openai.yaml file for display info, dependencies, and allow_implicit_invocation |
Unknown fields are usually ignored, but not always. claude.ai uploads and the Claude Skills API reject any field outside the six spec fields with a hard error. If a skill must travel everywhere, stick to the spec.
How each tool invokes a skill
| Tool | Explicit invocation | Automatic |
|---|---|---|
| Claude Code | /skill-name at the start of a message | Yes, by description |
| Cursor | Type / and pick it | Yes, by description (and paths) |
| GitHub Copilot | /skill-name in VS Code chat | Yes, by description |
| Devin Desktop | /skill-name | Yes, by description |
| Cline | Type / and pick it | Yes, by description |
| Codex | $skill-name, or /skills | Yes, unless allow_implicit_invocation: false |
| Antigravity CLI | /skill-name (created automatically) | Yes, by description |
Validate before you ship
- Run
skills-ref validate ./my-skillwith the skills-ref reference library to check frontmatter and naming. - In Claude Code,
claude plugin validate .claude/skillsfindsSKILL.mdfiles whose YAML doesn't parse. - Make sure
---is the very first line. If it isn't, Claude Code treats the whole file as content with no metadata.
Common mistakes
namedoesn't match the folder. Cursor, Cline and the spec require a match.- Uppercase or spaces in
name.PR-Reviewis invalid; usepr-review. - One skill that does five jobs. Split it. A focused skill is easier to trigger and to test.
- Scripts with hidden dependencies. Document what a script needs, or use
compatibility.
Recap
- A skill is a folder with
SKILL.md, plus optionalscripts/,references/andassets/. nameanddescriptionare required;namematches the folder.- Only metadata loads up front; the body loads on activation; resources load on demand.
- Use the six spec fields for portability; add tool-specific fields only where needed.
Next step
The part that decides whether your skill ever runs: Write skills that actually trigger.