SKILL.md frontmatter in Claude Code, tested
On 24 November 2026 Google suggested an error message for "skill.md frontmatter": skill.md frontmatter must be a yaml mapping. Another suggestion asked which fields exist. The error means the text between the two --- lines at the top of the file is not a set of key: value lines.
Claude Code's own check, claude plugin validate, prints its version of the same message, and we show it below next to a run of a working skill.
A skill, in Claude Code, is a folder holding a SKILL.md file. The file starts with frontmatter: a few lines of YAML settings between two --- lines. After that come instructions in Markdown. Claude sees each skill's name and description from the start. It loads the full instructions only when a skill fits the request.
The skills page in the Claude Code docs puts it plainly: the description "helps Claude decide when to load the skill automatically".
I wanted a run, not a list, so we wrote a tiny skill. Its description says what it does and when to use it. Then we asked Claude a normal question that fits the description, without naming the skill. Everything below comes from that session on Claude Code 2.1.330, macOS 27.2.1, on 24 November 2026.
Note Prerequisites: Claude Code installed and signed in (claude --version printed 2.1.330 for us). A terminal with wc (macOS and Linux both have it). About 10 minutes.
The SKILL.md frontmatter fields Claude Code reads
Claude Code's skills documentation says "All fields are optional. Only description is recommended". The ones you'll use first:
name- The command shown in the/menu. If you leave it out: The folder name is used.description- What the skill does and when to use it; Claude uses it to decide when to load the skill. If you leave it out: Claude Code uses the first non-empty line of the skill body instead.allowed-tools- Tools Claude may use without asking during the turn that runs the skill; the grant ends when you send your next message. If you leave it out: Normal permission prompts.disable-model-invocation-truestops Claude from loading the skill on its own; you call it with/name. If you leave it out: Claude may load it whenever it fits.when_to_use- Extra trigger text added to the description. If you leave it out: Nothing extra.
The page lists more (argument-hint, model, context, hooks, paths and others). It also caps what Claude sees of description plus when_to_use in the skill listing at 1,536 characters, so put the main use case first.
The open Agent Skills specification, the format other agent tools share, is stricter. It requires name and description. The name may be up to 64 characters long, using only lowercase letters, digits and hyphens. No hyphen at either end, no two in a row, and it must match the skill's folder name. Easy to miss. The description is capped at 1,024 characters, which I think is plenty. If you share skills between tools, I'd set both fields within those limits.
Build and run a skill
- Create the project - an empty folder with one short text file. Result:
wc -w notes.mdprints 12. - Write
.claude/skills/word-count/SKILL.md- frontmatter plus two numbered instructions. Result:head -5shows the frontmatter between two---lines. - Validate the frontmatter - run
claude plugin validate .claude/skills. Result:Validation passed. - Ask a question that matches the description - start
claude, then ask how many words notes.md has. Result: the answer arrives in the skill's exact format. - Check the transcript - run the grep over the session files. Result: one Skill tool call with
"skill":"word-count". - Call the skill by hand - type
/word-count notes.md. Result: the same answer, withARGUMENTS: notes.mdpassed to the skill.
Step 1: Create the project
In a terminal, run:
mkdir skills-demo && cd skills-demo
printf 'Hooks run before a tool call.\nSkills load when their description matches.\n' > notes.md
wc -w notes.md
You should see:
12 notes.md
Step 2: Write the SKILL.md file
Make the skill's folder:
mkdir -p .claude/skills/word-count
Save this as .claude/skills/word-count/SKILL.md:
---
name: word-count
description: Count the words in a text file. Use when the user asks how many words a file, note or document has.
allowed-tools: Bash(wc *)
---
# Word count
1. Run `wc -w <file>` on the file the user named.
2. Answer in one line, in this exact form: `<file> has <N> words (counted by wc -w).`
Check it: head -5 .claude/skills/word-count/SKILL.md should show the three settings lines between two --- lines.
I'd write the description in two halves: first what the skill does, then the kind of request that should trigger it. Bash(wc *) means the Bash tool, only for commands starting with wc. Per the docs, allowed-tools lets Claude run those commands without asking during that turn. Our session ran in auto permission mode (the mode where Claude runs commands without asking each time; Shift+Tab cycles the modes), so it never had to ask and the run didn't test that field.
A skill under .claude/skills/ belongs to this project. Only this one. Put the folder in ~/.claude/skills/ instead and it follows you into all your projects on this machine.
Step 3: Validate the frontmatter
From the skills-demo folder, run:
claude plugin validate .claude/skills
You should see ✔ Validation passed on the last line. I'd run this check every time I edit a skill's frontmatter.
If you see "must be a YAML mapping"
This is what the frontmatter error looks like. We wrote a second skill whose frontmatter lines start with -, which YAML reads as a list, not as key: value pairs:
---
- name: badlist
- description: Count words.
---
# Bad list
claude plugin validate .claude/skills on Claude Code 2.1.330 printed:
✘ Found 1 error:
❯ frontmatter: Frontmatter must be a YAML mapping (key: value pairs), got an array.
✘ Validation failed
Exit code 1. With the dashes removed (name: badlist, description: Count words.) the same command printed ✔ Validation passed.
The lowercase wording SKILL.md frontmatter must be a yaml mapping comes from skills-ref, the reference validator of the open Agent Skills format, which you meet when a tool or a CI check runs it on your skill. Both point at the same fix.
A session does not stop on such a file. Claude Code's changelog for 2.1.186 says a skill with malformed frontmatter now loads "with empty metadata", and the docs add that "/skill-name still works but Claude can't match against your description. Run with --debug to see the parse error."
Step 4: Ask a question that matches the description
Start Claude Code in the folder:
claude
If Claude Code asks whether you trust the folder, accept. If it asks to approve the wc command, approve it.
Ask, without naming the skill:
How many words are in notes.md?
You should see a reply in the skill's format. Claude's reply in our run:
notes.md has 12 words (counted by wc -w).
That "(counted by wc -w)" is the exact format from the skill's instructions. Word for word. The transcript shows how Claude got there.
Step 5: Check the transcript for the skill call
Claude Code writes each session to a JSON Lines file under ~/.claude/projects/, in a folder named after the project path. These are the lines from our session, simplified to the fields that matter (this is not the raw file format):
- tool_use Skill
{"skill": "word-count", "args": "notes.md"} - tool_result Launching skill: word-count
- tool_use Bash
{"command": "wc -w notes.md", "description": "Count words in notes.md"} - tool_result 12 notes.md
The Skill tool is how Claude loads a skill on its own. Its call came first: Claude loaded the instructions, and only then ran wc.
Exit Claude (/exit), then run this grep to find the call yourself:
grep -ho '"name":"Skill","input":{[^}]*}' ~/.claude/projects/*skills-demo*/*.jsonl
You should see one line:
"name":"Skill","input":{"skill":"word-count","args":"notes.md"}
Step 6: Call the skill by hand
In the same project, start a new session with claude and type the skill's name as a command:
/word-count notes.md
You should see the same answer. Claude ran wc -w notes.md and answered notes.md has 12 words (counted by wc -w). again. No Skill tool call this time: after this session the grep from Step 5 still finds only the one from Step 4.
The skill's body arrived as the message, with the text after the name appended:
ARGUMENTS: notes.md
If you set disable-model-invocation: true in the frontmatter, Claude won't load the skill on its own and this slash command is how you run it. I'd use that for a skill with side effects, a deploy for example, where I want to pick the moment myself.
When a Claude Code skill is not triggering
I'd start with the description. Is it about the request, in the words a person would type? "Count the words in a text file" matched "how many words are in notes.md". I think a vaguer one, "text utilities" say, probably would not.
Then the place: the file must be .claude/skills/<name>/SKILL.md, named exactly SKILL.md.
Then the frontmatter: run claude plugin validate .claude/skills from Step 3, which should print Validation passed.
Edits under .claude/skills/ are picked up in the running session. If a new skill is still missing from the / menu after you've saved it, run /reload-skills.
A hook and a skill do different jobs. A PreToolUse hook runs a script before a tool call and can block it; a skill adds instructions Claude chooses to load.
If you're preparing for a Claude Certified exam (Associate, Developer or Architect), our free practice exams are here.
Clean up
cd .. && rm -r skills-demo
Check it: ls skills-demo should print No such file or directory.
You have a project skill in .claude/skills/word-count/SKILL.md that Claude picked by its description and that you can also run as /word-count <file>.
claude plugin validate .claude/skills catches frontmatter that is not a YAML mapping before a session loads it with empty metadata.
Write the description as "what it does, then when to use it": until a skill loads, its name and description are all Claude sees of it.
Not covered here: skills with supporting files and scripts, skills in plugins, and the context and agent fields that run a skill in a subagent.
Originally published on leanzero.net. More Atlassian, Forge and local-AI write-ups at leanzero.net/blog, and if you're planning a migration or a Forge app, that's what we do: leanzero.net/services.
Comments
No comments yet. Start the discussion.