How to Write a Claude Code Skill (SKILL.md)

· 5 min read

A robot pulls a SKILL.md file out of a magic hat: your workflow, tools and expertise go in, and a reusable Claude Code skill comes out

A skill is a procedure you write once and Claude Code follows whenever it is relevant. Instead of pasting the same long prompt every time you cut a release or review a change, you save it as a skill. This page covers the format, the fields that matter, where to put it and how to check that it works. It uses Claude Code’s skills documentation, read on the day this post was written. Fields and behaviour change between versions, so treat that page as the reference.

A tangle of loose prompts goes into a Claude Code skill folder and comes out as one reusable skill

The smallest useful skill

Claude Code’s documentation says every skill needs a SKILL.md file with two parts: YAML frontmatter between --- markers that tells Claude when to use the skill, and Markdown content with the instructions Claude follows when it runs. Its first example summarises uncommitted changes:

---
description: Summarizes uncommitted changes and flags anything risky. Use when the user asks what changed, wants a commit message, or asks to review their diff.
---
## Current changes
!`git diff HEAD`
## Instructions
Summarize the changes above in two or three bullet points, then list any risks you notice such as missing error handling, hardcoded values, or tests that need updating. If the diff is empty, say there are no uncommitted changes.

The !`git diff HEAD` line is dynamic context injection: Claude Code runs the command and replaces the line with its output before Claude sees the skill, so the instructions arrive with the live diff already inlined. You can invoke it two ways: ask something that matches the description, or type /summarize-changes.

Where to save it

Location Path Loads in
Personal ~/.claude/skills/<name>/SKILL.md All your projects on this machine
Project .claude/skills/<name>/SKILL.md Sessions in this repository. Commit it so your team gets it
Plugin the plugin’s skills/ folder Wherever the plugin is enabled

For a Flutter team, a project skill for “cut a release build” or “add a feature the way we do” belongs in the repo.

The frontmatter fields that matter

The documentation lists many fields. These are the ones to know first:

  • description: what the skill does and when to use it. Claude uses it to decide when to apply the skill. Put the key use case first: the combined description and when_to_use text is truncated at 1,536 characters in the skill listing.
  • name: the command name. It defaults to the directory name.
  • disable-model-invocation: set to true to stop Claude loading the skill automatically. Use it for workflows you want to trigger by hand with /name, such as a release.
  • user-invocable: set to false for background knowledge only Claude should invoke.
  • allowed-tools: tools Claude can use without asking permission while the skill runs, for example Bash(python3 *).
  • context: fork: run the skill in a forked subagent context.
  • paths: glob patterns for the files that activate the skill.

A field name must match the table exactly, hyphens included: Claude Code ignores a field it does not recognise without reporting an error. And the frontmatter is read only when the opening --- is the file’s first line.

Add supporting files

A skill folder can hold more than SKILL.md: templates, reference documents and scripts. The documentation’s visualiser example bundles a Python script and refers to it with ${CLAUDE_SKILL_DIR}, so the path resolves wherever the skill is installed. Keep SKILL.md focused on the steps, and put long reference material in separate files that the skill points to.

An open toolbox holding a SKILL.md file, with example and resource cards beside it

How a skill behaves

From the documentation, “when you or Claude invoke a skill, the rendered SKILL.md content enters the conversation as a single message and stays there across later turns.” Claude Code does not re-read the file on later turns, so write guidance as standing instructions that still make sense deep into a session, not as a one-time checklist for a single step.

Unlike CLAUDE.md, a skill’s body loads only when it is used, which is why long procedures belong in skills.

A structure that works

MobileKit’s standard for its own skills is a good template:

  1. Name the job, its inputs and its outputs. “Writes the store listing text from these files into this folder.”
  2. Write the steps in order, each with a test for done: “Done when the file exists and passes the length check.”
  3. Put templates and scripts beside it, so output has the same shape every time.
  4. Write a description that says when to use it.
  5. State the rules: what the skill must never do, for example submit anything without a person’s yes.
  6. Record what it learned, so the next run starts smarter.

Example: a Flutter release-check skill

---
name: release-check
description: Runs the pre-release checks for this Flutter app and reports results. Use before cutting a release build.
disable-model-invocation: true
---
Run, in order, and stop at the first failure:
1. `flutter analyze`
2. `dart format --set-exit-if-changed .`
3. `flutter test`
Then check that `pubspec.yaml` has a higher build number than the last tag. Report each step as pass or fail, with the failing output. Do not build or upload anything.

It is manual (disable-model-invocation), has a clear done condition and a boundary: it does not build or upload.

Test it against a baseline

Seeing a skill trigger does not tell you it works. The documentation’s method is a baseline comparison: collect a few realistic prompts, run each in a fresh session with the skill and again with it turned off, and compare. A fresh session matters because leftover context from writing the skill will hide gaps in the instructions. Check two things separately: does Claude invoke the skill on the prompts it should, and is the output right when it does. The documentation also describes a skill-creator plugin that automates this comparison, and notes that skills build on the open Agent Skills standard.

A clipboard for a Claude Code skill: SKILL.md, instructions, examples and resources are ticked, and the Test it line is still open

Common mistakes

  • A description that does not say when to use the skill, so Claude never picks it.
  • One enormous skill. Split it.
  • Steps with no done condition.
  • Letting Claude invoke a risky skill automatically.
  • Editing the skill and never re-testing.

Skills compared with other tools

Use CLAUDE.md for standing facts, a skill for a procedure, a subagent for delegated work and a hook for something that must always happen. See Claude Code skills for mobile app development, CLAUDE.md for Flutter, a subagent as a code reviewer and hooks for Flutter. The whole route is in Build a Flutter app with Claude Code.

Related: Claude Code hooks for Flutter and a subagent as a code reviewer.

Source read on the day this post was written: Claude Code: extend Claude with skills.

Questions

What does a skill need at minimum?

A directory containing a SKILL.md file with YAML frontmatter and instructions. Claude Code's documentation says all frontmatter fields are optional and only description is recommended, so Claude knows when to use the skill.

Where do I save a skill?

In a project, at .claude/skills/<name>/SKILL.md, which you can commit for your team. For all your projects on your machine, at ~/.claude/skills/<name>/SKILL.md.

How do I stop Claude running a skill by itself?

Set disable-model-invocation: true in the frontmatter. Claude will not load it automatically, and you run it with /skill-name.

Try it on your next idea

One payment, every update to this major version, and a refund window if it is not for you. Refund policy.