A step-by-step guide to writing SKILL.md for Claude Code: required frontmatter, instructions, scripts, testing, and the spec vs Claude Code differences.
Vamsi Tallapudi
Manager, Architect Technology at Cognizant
A Claude Code skill is a folder with one required file, SKILL.md, that teaches Claude a procedure it should follow the same way every time instead of guessing fresh each session. You write the steps once, Claude reads the file's description to know when to load it, and after that it just runs the playbook. I've built four or five of these for my own repo over the past couple months, and the ones that stuck were the boring ones: a commit-message formatter, a PR summary skill, a "run our weird test matrix" skill. None of them are impressive. They just stopped me from retyping the same correction five times a week.
This guide walks through the actual steps, with the frontmatter fields that matter and the ones that don't, because the docs for Claude Code and the docs for claude.ai skills disagree on a few details and that trips people up.
A skill is a directory containing SKILL.md: YAML frontmatter on top, markdown instructions below. Claude Code scans your ~/.claude/skills/ folder (personal, loads everywhere) and your project's .claude/skills/ folder (loads only in that repo) at session start. When your prompt matches a skill's description, Claude loads the instructions into context and follows them.
Anthropic shipped Skills on October 16, 2025, originally for document work in claude.ai (Excel, PDF, PowerPoint templates), then opened it up to Claude Code and the API. In December 2025 it became an open standard at agentskills.io, the Agent Skills specification. That part matters more than it sounds: a SKILL.md you write for Claude Code should also work, mostly unchanged, in Cursor, GitHub Copilot, or Codex, because they all read the same spec now. As of this October, Anthropic donated the whole project to the Agentic AI Foundation under the Linux Foundation. More than 70 platforms have integrated it, and there are over a million published skills with something like 280 million installs between them.
Skip this if you're impatient, but it saves rework. A skill earns its place when you're correcting Claude on the same thing repeatedly: a report format, a review checklist, a deploy sequence, "always check the test matrix before touching that feature." If it's a one-off, just type it in chat. If you need live data from an API, that's an MCP connector's job, not a skill's: a skill can tell Claude how to use a connector, but it can't reach the service itself.
Write the task as one sentence first. That sentence becomes your description. Everything else is instructions.
mkdir -p ~/.claude/skills/my-skill
Use ~/.claude/skills/ for anything you want available in every project on your machine. Use .claude/skills/ inside a repo if the skill is specific to that codebase. That's where I keep mine, since most of my skills reference this repo's test setup directly.
This is where the two docs disagree, so pin down which rules you're following.
The Agent Skills specification (the portable one, same across tools) requires exactly two fields:
| Field | Required | Rule |
|---|---|---|
name | Yes | Lowercase letters, numbers, hyphens only. Max 64 characters. Must match the directory name. |
description | Yes | What it does and when to use it. Max 1,024 characters. |
Claude Code's own implementation is looser and has a lot more knobs: name is technically optional (it falls back to the directory name), and its description field tolerates up to 1,536 characters before truncating in the skill listing. It also adds options the spec doesn't define: disable-model-invocation (stop Claude from auto-loading it, useful for anything destructive like a deploy skill), allowed-tools (pre-approve specific commands for that turn), context: fork (run the skill in an isolated subagent), model, effort, argument-hint for /slash-command autocomplete, and a few others.
My rule of thumb: write to the stricter spec (both fields, name matching the folder, under 1,024 characters) unless you're building something Claude-Code-only like a deploy gate. That way the skill still works if you ever run it through Codex or share it with a teammate on Cursor.
---
name: pr-summary
description: Summarize an open pull request's diff, comments, and changed files into a short review brief. Use when asked to review a PR, summarize a diff, or prep for a code review.
---
Notice the description does two jobs: says what it does, and lists the phrases someone would actually type. Claude matches against this text, nothing else, to decide whether to load the skill. If people keep having to ask twice, the description is probably too vague, not the instructions.
Below the frontmatter, write plain markdown. Steps, examples, the exact output format you want. Don't write "produce a good summary": write the fields, the order, the length limit. Claude follows what's on the page, not what you meant.
## PR Context
!`gh pr diff`
!`gh pr view --comments`
## Instructions
Summarize the diff above in 3 bullet points covering what changed and why.
Then list risks: missing tests, hardcoded values, breaking API changes.
If there are no comments, say so instead of inventing discussion.
That !command`` syntax runs shell commands before Claude ever sees the skill: the output gets inserted into the markdown first. It's genuinely useful and also the part people forget: if the command exits non-zero, the whole skill aborts, so don't put anything flaky in there.
Keep SKILL.md itself under 500 lines. If you've got a 40-line style guide or a lookup table, put it in a separate file and reference it by path, since Claude only opens it when a step calls for it, which keeps the base skill cheap to load every time.
my-skill/
├── SKILL.md
├── references/
│ └── style-guide.md
├── assets/
│ └── template.md
└── scripts/
└── check.py
references/: background Claude reads only when a step points at itassets/: templates or files to copy and fill in, not read for guidancescripts/: actual code, referenced in SKILL.md as ${CLAUDE_SKILL_DIR}/scripts/check.py so the path resolves no matter where the skill livesOne thing worth repeating because people get burned by it: never put API keys or passwords in a script. Everyone you share the skill with gets the whole folder, scripts included. If a step needs to call an outside service, point it at a connector instead.
Drop the folder in ~/.claude/skills/ and start a normal Claude Code session. Type a prompt the description should cover and watch whether it actually loads. Claude Code highlights skill invocations in its output. If it doesn't trigger, the description is the first thing to fix, not the instructions. You can also force it directly with /my-skill to check the instructions work before worrying about auto-invocation at all.
For anything going into a plugin or shared with other people, Anthropic's skills-ref validate ./my-skill command checks the frontmatter against the spec and tells you exactly what's wrong: missing field, name that doesn't match the directory, whatever.
name. The spec requires it; some tools silently ignore the skill if it's off./write-tests /fix-issue 123 and both load.For anything you do more than twice a week with a specific format, yes. I wouldn't bother for something I'll only do once. The honest tradeoff is that a skill only pays off once you've written the description well enough to trigger reliably. The first version of mine undertriggered for about a week before I tightened the wording, and that iteration is the actual work here, not the YAML.
If you want more on where Claude Code skills are heading, theo-tstack-claude-code-skills covers a real-world take on building a skills stack, convex-skill-telemetry-security-audit is a good example of a skill built for a specific internal workflow, and jane-street-socratic-tutor-skill shows a skill built for teaching rather than automation.
New AI tools, automation workflows, and course drops — straight to your inbox. Join 2,400+ builders.
A Convex Claude Code skill POSTed app ideas to a remote host and dodged safety checks. Here's what happened and how to audit any skill before you install it.
Claude Code now installs natively on Windows via PowerShell, no WSL or Node.js needed. Here's the native vs WSL install, step by step, with real fixes for PATH and Defender errors.
Google's Gmail and Drive MCP servers went GA on Nov 24, 2026. Here's how to wire Gmail MCP into Claude Code before the Feb 1, 2027 REST API throttling deadline.
Comments