Course contents

SKILL.md explained: the anatomy of an agent skill

intermediate4 min readUpdated
  • Cursor
  • GitHub Copilot
  • Claude Code
  • Windsurf / Devin
  • Cline
  • Codex
  • Antigravity CLI
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:

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

FieldRequiredRules
nameYes1 to 64 characters: lowercase letters, numbers and hyphens. No leading, trailing or double hyphens. Must match the folder name.
descriptionYes1 to 1,024 characters. What the skill does and when to use it.
licenseNoLicense name or a bundled license file.
compatibilityNoUp to 500 characters on environment needs, like "Requires git and jq".
metadataNoA map of string keys to string values, for your own tooling.
allowed-toolsNoExperimental. A space-separated list of pre-approved tools.
.agents/skills/pr-review/SKILL.md
---
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:

  1. Metadata (about 100 tokens): name and description are loaded at startup for every installed skill.
  2. Instructions (under 5,000 tokens recommended): the full SKILL.md body loads when the skill is activated.
  3. Resources (as needed): files in scripts/, references/ and assets/ 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:

ToolExtra fields and features
Claude Codewhen_to_use, disable-model-invocation, user-invocable, allowed-tools, disallowed-tools, model, effort, context: fork, agent, paths, hooks, argument-hint, arguments and more
Cursorpaths, disable-model-invocation, icon, color (Custom Mode badge)
GitHub Copilot (VS Code)argument-hint, user-invocable, disable-model-invocation
CodexAn 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

ToolExplicit invocationAutomatic
Claude Code/skill-name at the start of a messageYes, by description
CursorType / and pick itYes, by description (and paths)
GitHub Copilot/skill-name in VS Code chatYes, by description
Devin Desktop/skill-nameYes, by description
ClineType / and pick itYes, by description
Codex$skill-name, or /skillsYes, unless allow_implicit_invocation: false
Antigravity CLI/skill-name (created automatically)Yes, by description

Validate before you ship

  • Run skills-ref validate ./my-skill with the skills-ref reference library to check frontmatter and naming.
  • In Claude Code, claude plugin validate .claude/skills finds SKILL.md files 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

  • name doesn't match the folder. Cursor, Cline and the spec require a match.
  • Uppercase or spaces in name. PR-Review is invalid; use pr-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 optional scripts/, references/ and assets/.
  • name and description are required; name matches 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.