Part 2 · Lesson 8 of 16
Build a Custom Claude Code Skill with SKILL.md
Auto-loaded knowledge packets. Use one. Write your own.
10 min
Step 1 of 6 · What are skills?
A skill is a reusable packet of instructions (and optionally scripts) that extends what Claude Code can do. You write the instructions once in a file called SKILL.md, and Claude adds it to its toolkit.
Think of it as a custom cheat sheet. Whenever the task matches, Claude can load the skill on demand and follow your instructions exactly. This lets you automate repetitive work like formatting code, running a release checklist, or generating a database schema, without re-typing the steps every time.
Unlike putting everything in CLAUDE.md, a skill's body only loads when it is actually used, so even long reference material costs almost no context until you need it.
Step 2 of 6 · Where a skill lives and how it's structured
Each skill is a folder containing a SKILL.md file. Where you put that folder decides who can use it:
- Personal (all your projects):
~/.claude/skills/<skill-name>/SKILL.md - Project (this repo only, commit it to share):
.claude/skills/<skill-name>/SKILL.md
The folder name becomes the command you type. A skill at .claude/skills/deploy-staging/SKILL.md is invoked as /deploy-staging.
A SKILL.md has two parts:
- YAML frontmatter between
---markers. The most important field isdescription— Claude reads it to decide when to use the skill automatically. (nameis optional and just sets the display label.) - Markdown instructions below the frontmatter — the steps Claude follows when the skill runs.
---
description: Format and clean up Markdown files. Use when asked to tidy or format a .md document.
---
When formatting a Markdown file:
- Put a blank line before every heading
- Remove trailing spaces at the end of lines
- Wrap paragraphs at 80 characters
A skill folder can also hold supporting files — templates, example outputs, or helper scripts (bash or Python) that Claude runs — but only SKILL.md is required.
Step 3 of 6 · Auto-invoke vs. running it as /name
There are two ways a skill runs, and understanding the difference is the whole point of skills:
- Claude auto-invokes it. Claude always sees each skill's
description. When your request matches, it loads the skill on its own. Ask "tidy up README.md" and a well-described formatter skill kicks in without you naming it. - You invoke it directly by typing
/<skill-name>(the folder name), e.g./format-md. Use this when you want to trigger the skill yourself.
You control this with frontmatter. Add disable-model-invocation: true to make a skill manual only — handy for actions with side effects like /deploy or /commit, where you don't want Claude deciding to run it. By default both you and Claude can invoke a skill.
Step 4 of 6 · Create a Markdown formatter skill
Let's build a real project skill that tells Claude how to tidy up Markdown files. From your playground, create the skill folder:
mkdir -p .claude/skills/format-mdNow create .claude/skills/format-md/SKILL.md. Open it in your editor and paste:
---
description: Format and clean up Markdown files. Use when asked to tidy, clean, or format a .md document.
---
When formatting a Markdown file:
- Put a blank line before every heading
- Remove trailing spaces at the end of lines
- Wrap paragraphs at 80 charactersBecause this folder is named format-md, the skill is available both automatically (from its description) and directly as /format-md.
Step 5 of 6 · Verify your skill
Launch Claude Code in your playground:
claudeFirst, confirm Claude can see the skill. Ask:
What skills are available?
You should see format-md listed. Now test both invocation styles.
Direct — type the command and a target file:
/format-md clean up intro.md
Automatic — describe the task without naming the skill, and let Claude pick it up:
Tidy up the formatting in intro.md
Either way, Claude reads your skill's rules, adds blank lines before headings, strips trailing whitespace, rewraps paragraphs, and saves the result.
Type /exit to close the session.
Step 6 of 6 · Checkpoint & Recap
Recap
- Skills are reusable instruction packets in
SKILL.md, loaded only when used. - Location decides scope:
~/.claude/skills/is personal,.claude/skills/is per-project; the folder name becomes the/command. - Two ways to run: Claude auto-invokes from the
description, or you type/<name>. Usedisable-model-invocation: truefor manual-only skills. - Custom commands are skills too:
.claude/commands/*.mdfiles still work and create/commandsthe same way.
Frequently asked questions
Where do Claude Code skills live?
A skill is a folder containing a SKILL.md file. Put it in ~/.claude/skills/<name>/SKILL.md to use it across all your projects, or in .claude/skills/<name>/SKILL.md to scope it to one repository (commit that folder to share it with your team). The folder name becomes the command you type, so .claude/skills/format-md/SKILL.md is invoked as /format-md.
How does Claude decide when to use a skill automatically?
Claude always sees each skill's description field. When your request matches that description, it loads the skill and follows the instructions on its own — you don't have to name it. That's why a clear, specific description with words you'd naturally say matters most. To stop Claude from auto-running a skill, add disable-model-invocation: true to the frontmatter so only you can invoke it with /name.
What's the difference between a skill and a custom slash command?
They're the same system. A file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create /deploy and work the same way. Skills add optional features — a folder for supporting files like helper scripts, frontmatter to control who invokes them, and automatic loading when relevant. Existing .claude/commands/ files keep working; if a skill and a command share a name, the skill takes precedence.
How do I list or reload my skills?
Inside a session, ask "What skills are available?" or run /skills to see the list. If you add or edit a skill on disk mid-session, Claude Code usually picks it up automatically; if it doesn't, run /reload-skills to re-scan the skill and command directories.
Can a skill run scripts?
Yes. A skill folder can bundle helper scripts in any language (for example a scripts/ subfolder), and your SKILL.md instructions tell Claude when to run them. This lets a skill do heavy lifting — like generating an HTML report — that a plain prompt can't.