Claude Code Skills: How to Write Your First SKILL.md (With a WordPress Example)

Cover “Teach it once”: a skill folder holding a SKILL.md file whose description line is drawn in gold and linked by a dotted line to the /wp-template-review command

Quick Summary

  • A Claude Code skill is a folder with a SKILL.md file: YAML frontmatter that says what it does and when to use it, then Markdown instructions. Claude sees only the name and description until a task matches.
  • Personal skills live in ~/.claude/skills/, project skills in the repo's .claude/skills/, and plugin skills run as /plugin-name:skill-name. When names clash, enterprise beats personal and personal beats project.
  • The description decides whether Claude uses a skill on its own: say what it does and when to use it, in the third person, with the words people actually type.

Claude Code skills let you teach Claude a procedure once, save it as a folder with a SKILL.md file, and reuse it whenever it’s relevant. This tutorial covers what a skill is, how Claude Code finds and loads one, and the frontmatter fields worth knowing. Then you’ll build a WordPress skill step by step that reviews PHP templates for unescaped output, missing nonce and capability checks, and missing text domains.

The short version: Claude Code skills are folders, each with a SKILL.md file: YAML frontmatter that says what the skill does and when to use it, then Markdown instructions. Claude sees only each skill’s name and description until a task matches, and then it loads the full instructions. Save skills in ~/.claude/skills/ for yourself or in a repo’s .claude/skills/ for your team, and run any of them with /skill-name.

What Claude Code skills are

A skill is a directory with a SKILL.md file in it. The file has two parts: YAML frontmatter between --- markers, and Markdown instructions that Claude follows when the skill runs. The folder can also hold reference documents, templates and scripts.

Claude Code skills follow the Agent Skills open standard. Anthropic developed the format and released it as an open standard, so a skill written to the spec also works in other tools that support it. Claude Code then adds extras, such as invocation control and running a skill in a subagent.

Skills scale because of progressive disclosure. Claude loads each one in three stages:

  1. Discovery: at startup, only each skill’s name and description go into context, about 100 tokens per skill according to Anthropic’s overview.
  2. Activation: when a task matches the description, the full SKILL.md body loads.
  3. Resources: extra files load only when Claude needs them. Scripts run, and only their output enters the context.

So a long checklist can sit in a skill and cost almost nothing until it’s useful. If you’ve read my post on Ponytail for Claude Code, you’ve already seen how much one well-scoped skill can change. If you’re still choosing a tool, my comparison of Claude Code vs Cursor vs ChatGPT covers which one fits which job.

Frontmatter fields in Claude Code skills

For Claude Code skills, every frontmatter field is optional, and the docs recommend only one: description. Without it, Claude Code uses the first non-empty line of the body instead. The Agent Skills standard is stricter: it requires name and description, and the name must use lowercase letters, numbers and hyphens and match the folder name. Set both if you might use the skill outside Claude Code.

These are the fields you’ll use most, as the Claude Code docs list them:

FieldWhat it does
nameThe command name in the / menu. Defaults to the folder name.
descriptionWhat the skill does and when to use it. Claude decides from this.
when_to_useExtra trigger phrases, added to the description.
argument-hintAn autocomplete hint, such as [file-or-folder].
disable-model-invocationtrue means only you can run it.
user-invocablefalse means only Claude can run it.
allowed-toolsTools Claude may use without asking, during the turn that invokes the skill.
context, agentcontext: fork runs the skill in a subagent; agent picks its type.
model, effortOverride the model or effort level for the rest of the turn.
pathsGlob patterns for the files that activate the skill.

The docs also list arguments, disallowed-tools, background, hooks, shell, metadata, license and compatibility, which most skills never need.

Two details catch people out. First, the opening --- must be the very first line of the file, or Claude Code treats the whole file as plain content. Second, Claude Code ignores an unrecognized field without reporting an error, so a typo in a field name simply does nothing.

Where Claude Code skills live

Where you save a skill decides which sessions load it:

LocationPathLoads in
Personal~/.claude/skills/my-skill/SKILL.mdAll your projects on this machine
Project.claude/skills/my-skill/SKILL.mdSessions in this repository
Pluginmy-plugin/skills/my-skill/SKILL.mdWherever the plugin is enabled
EnterpriseThe managed settings directoryEvery user on machines your organization manages

Project skills also load from parent directories up to the repository root, so a session started in a monorepo subfolder still finds them.

When two skills share a name:

  • Enterprise, personal and project: enterprise beats personal, and personal beats project.
  • Plugin skills: both load, because plugin skills run under a namespace, as /plugin-name:skill-name.
  • Old command files: custom commands have been merged into skills, and .claude/commands/ files still work. A skill beats a command file with the same name.
  • Bundled skills: yours replaces the bundled one. A project skill called code-review replaces the bundled /code-review, so pick a distinct name.

How Claude picks skills, and how you call one

Claude Code skills run in two ways. Claude can choose one: it matches your request against each description in the skill listing and loads the skill that fits. Alternatively, you type /wp-template-review at the start of a message. Anything after the name becomes arguments, which the skill receives through the $ARGUMENTS placeholder.

By default, both routes are open. Two fields close one of them:

  • disable-model-invocation: true means only you can run the skill. Use it for anything with side effects, like a deploy. The description also leaves Claude’s context.
  • user-invocable: false means only Claude can run it, and it disappears from the / menu. It suits background knowledge that makes no sense as a command.

You can also restrict skills without editing them. A permission deny rule like Skill(deploy *) blocks one skill, and denying Skill blocks them all. For a shared skill you’d rather not touch, the skillOverrides setting can turn it "off", and the /skills menu writes that setting for you.

One behavior shapes how you write the body. Once a skill loads, its content stays in the conversation, and Claude Code doesn’t re-read the file. So write rules that should hold for a whole task as standing instructions (“check every echo”), not as one-off steps.

Supporting files and scripts

Claude Code skills can hold more than one file, but nothing beyond SKILL.md loads by itself. The standard suggests three optional folders: scripts/, references/ and assets/. Link each file from SKILL.md and say when to open it.

A few rules keep this efficient:

  • Keep SKILL.md under 500 lines. Both the docs and the spec recommend it.
  • Link one level deep. Anthropic’s authoring guide warns that Claude may only preview a file linked from another linked file.
  • Use scripts for deterministic work. Only a script’s output enters the context.
  • Point to bundled files with ${CLAUDE_SKILL_DIR}. It expands to the skill’s own folder, so paths work from any working directory.

Claude Code also supports dynamic context injection. A line such as !`git diff HEAD` runs before Claude sees the skill, and the command’s output replaces it. There’s one sharp edge: if the command fails, the whole skill invocation aborts. With the default bash shell, append || true to commands that can legitimately exit with an error.

Worked example: a WordPress template review skill

Here’s a skill worth keeping. It reviews WordPress PHP for three problems that are easy to miss: output that isn’t escaped, form or AJAX handlers without a nonce and capability check, and translation calls with a missing or wrong text domain. It only reads and reports.

Step 1: create the folder

Put it in the project if your team should get it, or under ~/.claude/skills/ for every WordPress project you open:

Shell
mkdir -p .claude/skills/wp-template-review/references

Step 2: write SKILL.md

Save this as .claude/skills/wp-template-review/SKILL.md:

PHP
---
name: wp-template-review
description: Reviews WordPress PHP templates and plugin files for unescaped output, missing nonce and capability checks, and missing or wrong text domains. Use when the user asks to review, audit or security-check theme templates, template parts, shortcodes, form or AJAX handlers, or WordPress PHP before a commit.
argument-hint: [file-or-folder]
allowed-tools: Bash(git diff *) Bash(git status *)
---

# WordPress template review

Files to review: $ARGUMENTS

If no files are named above, review the PHP files changed in git. Get them
from `git diff --name-only HEAD` plus untracked files from `git status --short`.

Find the project's text domain in the `Text Domain:` header of the theme's
style.css or the main plugin file. If there is none, ask before continuing.

Read each file in full. Report only problems you can point to by line.
For the right function in each context, see
[references/wp-security-functions.md](references/wp-security-functions.md).

## 1. Output escaping

- Flag every echo, print or `<?=` of a variable, function result, option,
  post meta, query var or request value that is not escaped at output.
- Check that the escaping function fits the context: text, attribute,
  URL, textarea or HTML.
- Flag `_e()` and `echo __()`: they print translated text unescaped.

## 2. Nonces and capabilities

- Code that changes data based on `$_POST`, `$_GET` or `$_REQUEST` must
  verify a nonce AND call `current_user_can()` with a specific capability.
  A nonce alone is not an authorization check.
- The form or link that sends the request must output the matching nonce.

## 3. Text domains

- Every translation call needs a text domain argument: a string literal
  that matches the project's text domain.
- Flag missing domains, wrong domains, and variables or constants.
- Flag user-facing strings in templates that are not translatable.

## Optional: coding standards

If `vendor/bin/phpcs` exists, also run `vendor/bin/phpcs --standard=WordPress`
on the same files and add its escaping, nonce and i18n findings, labeled "phpcs".

## Output

Group findings by file. For each one, give the line number, the problem
and a one-line fix. List security findings first, then i18n. End with a
count per category. Do not edit files unless the user asks.

A few choices in there are deliberate:

  • The description says what the skill does, then lists words a developer would type: review, audit, template parts, before a commit.
  • Claude can invoke it on its own, because it’s read-only. A skill with side effects would get disable-model-invocation.
  • allowed-tools pre-approves two git commands for this turn only. It doesn’t block other tools.
  • The nonce rule pairs every nonce with current_user_can(), because the WordPress handbook says nonces “should never be relied on for authentication, authorization, or access control.”
  • The text domain rule matters because _e(), for example, falls back to the 'default' domain, so the string can’t use your theme’s translations.

Escaping is the output half of the job. For a fourth check on the input half, my guide on how to sanitize PHP form input covers the pattern it would enforce.

Step 3: add a small reference file

Save this as references/wp-security-functions.md inside the skill folder. It loads only when Claude needs to pick a function:

PHP
# WordPress security functions

## Escape at output, by context
- Text inside an HTML element: esc_html()
- HTML attribute value: esc_attr()
- URL in href or src: esc_url()
- Inside a textarea: esc_textarea()
- Inline JavaScript: esc_js()
- HTML you want to keep, such as post content: wp_kses_post()
- Translated text: esc_html__(), esc_html_e(), esc_attr__(), esc_attr_e()

## Nonces
- Form: wp_nonce_field( 'action' )
- Link: wp_nonce_url( $url, 'action' )
- Verify an admin form or link: check_admin_referer( 'action' )
- Verify an AJAX request: check_ajax_referer( 'action' )
- Anywhere else: wp_verify_nonce() returns false on failure; stop there.

## Capabilities
- Always pair a nonce check with current_user_can( 'capability' ).

Step 4: test it

You don’t need to restart: Claude Code picks up new or edited skills during a session, and /reload-skills forces a re-scan. Start with a file that has every problem on purpose:

PHP
<?php
// test-review.php: deliberately insecure, for testing the skill only.
$subtitle = get_post_meta( get_the_ID(), 'subtitle', true );
?>
<div class="post-subtitle"><?php echo $subtitle; ?></div>
<a href="<?php echo get_permalink(); ?>"><?php _e( 'Read more' ); ?></a>
<?php
if ( isset( $_POST['site_notice'] ) ) {
	update_option( 'site_notice', sanitize_text_field( wp_unslash( $_POST['site_notice'] ) ) );
}

Then work through these checks:

  1. Check that it’s listed. Run /skills, or ask “What skills are available?”
  2. Trigger it by description. In a fresh session, ask: “Can you check test-review.php for security problems before I commit it?” Claude loads skills through its Skill tool, so you’ll see that call with the skill’s name.
  3. Check the findings. A good run flags the unescaped meta value, the unescaped permalink, the _e() call with no text domain, and the option update with no nonce or capability check.
  4. Run it directly with /wp-template-review test-review.php.
  5. Try a prompt that shouldn’t trigger it, such as “write a CSS rule for the footer”. If the skill loads, the description is too broad.

A trigger only proves that Claude found the skill. For a real test, the docs suggest a baseline: run the same prompts in fresh sessions with the skill on, then off (via skillOverrides), and compare. Anthropic’s skill-creator plugin automates that comparison. For where a review step fits in a full build, see my AI-powered WordPress workflow.

Descriptions that trigger, and mistakes to avoid

When Claude Code skills don’t trigger, check the description first. It’s the only part Claude reads before deciding.

Write the description for matching

  • Say what and when. Name the task, then the situations that should trigger it. “Helps with WordPress” matches everything and nothing.
  • Write in the third person. Anthropic’s authoring guide notes that the description goes into the system prompt, and “I can help you” phrasing can cause discovery problems.
  • Use the words people type, like file types, function names and “before I commit”.
  • Put the key use case first. The listing cuts the description and when_to_use text at 1,536 characters combined, and with many skills installed, Claude Code drops the descriptions of the skills you use least.

Common mistakes

  • Wrong folder depth. The documented layout is one folder per skill: .claude/skills/wp-template-review/SKILL.md. A loose or extra-nested SKILL.md sits outside it.
  • Broken frontmatter. If the YAML doesn’t parse, the skill loads with no fields and never triggers on its own. claude plugin validate .claude/skills finds the error.
  • Long bodies. After compaction, Claude Code keeps only the first 5,000 tokens of each re-attached skill, so put critical rules at the top.
  • Secrets in the skill. Skill content enters the conversation, and you commit project skills to git. Keep keys and passwords in environment variables.
  • Unread skills. Use skills only from trusted sources. Claude Code applies a repository skill’s allowed-tools even in a -p run in an untrusted folder, so read it first.

Sharing Claude Code skills with a team

The simplest route is the repository. Commit .claude/skills/, and everyone who opens the project in Claude Code gets the same skills. That’s also how a skill reaches cloud sessions, which don’t read ~/.claude/skills/ on your machine.

For skills you want across many repositories, package them as a plugin: a folder with a manifest at .claude-plugin/plugin.json and a skills/ directory. You list it in a marketplace, which is a catalog of plugins, and teammates install it with /plugin install plugin-name@marketplace-name. Organizations can also deploy skills through managed settings.

Claude Code skills or CLAUDE.md?

CLAUDE.md loads in every session, so it suits short facts about a project. A skill’s body loads only when it’s used, and the docs suggest creating one when a section of CLAUDE.md “has grown into a procedure rather than a fact.”

The takeaway

Pick one procedure you keep repeating, write it as a skill with a specific description, and test it in a fresh session before you rely on it. Keep the body short, move detail into linked files, and keep secrets out. Because Claude Code skills are plain folders, you can review, version and share them like the rest of your code. If you’d like a developer to build or review your WordPress theme or plugin, that’s part of my WordPress development work.

Sources

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See all articles