Short answer: a skill is a folder with a SKILL.md file that teaches a coding agent one procedure, loaded only when it is needed. CLAUDE.md and AGENTS.md are plain Markdown files of standing project instructions (build commands, conventions, rules) that the agent reads at the start of every session. Claude Code reads CLAUDE.md, and since v2.1.277 it can also read AGENTS.md; OpenAI Codex and many other agents read AGENTS.md.

Below: all three explained from the official docs, then a small working skill built and validated in a throwaway folder.

What you need

  • Claude Code to use the skill. Reading AGENTS.md directly needs v2.1.277 or later and claude plugin validate on a skills folder needs v2.1.233 or later, according to the docs. We tested with 2.1.325. If you have not installed it yet, see what is Claude Code and how to install it.
  • git, because the example skill reads your staged changes.
  • Optional: Python 3 with PyYAML in a virtual environment, for the stricter validation script in Step 4.

Skills, CLAUDE.md and AGENTS.md at a glance

Skill (SKILL.md)CLAUDE.mdAGENTS.md
What it holdsOne procedure or body of reference knowledgeFacts and rules for every sessionFacts and rules for every session
When it loadsName and description always; body only when usedStart of every sessionStart of every session
FormatYAML frontmatter plus MarkdownMarkdown, with @path importsPlain Markdown, no required fields
Read byClaude Code and other tools that follow the Agent Skills standardClaude CodeCodex, Cursor, Gemini CLI and others listed on agents.md; Claude Code from v2.1.277
Where it lives~/.claude/skills/ or .claude/skills/Repo root, .claude/, or ~/.claude/Repo root and subfolders

What a Claude Code skill is

Anthropic's skills page puts it simply: "Create a SKILL.md file with instructions, and Claude adds it to its toolkit. Claude uses skills when relevant, or you can invoke one directly with /skill-name."

The difference from CLAUDE.md is cost. The docs say "a skill's body loads only when it's used, so long reference material costs almost nothing until you need it." Only each skill's name and description sit in context all the time, so Claude knows the skill exists.

Claude Code skills "follow the Agent Skills open standard", published at agentskills.io. Claude Code adds extra fields on top of that standard, which matters if you also upload skills to claude.ai.

Folder layout

A skill is a folder. Only SKILL.md is required; everything else is optional and loads on demand. This is the layout the docs show:

my-skill/
├── SKILL.md (required - overview and navigation)
├── reference.md (detailed API docs - loaded when needed)
├── examples.md (usage examples - loaded when needed)
└── scripts/
    └── helper.py (utility script - executed, not loaded)

The docs advise keeping SKILL.md under 500 lines and moving detail into supporting files.

Frontmatter fields

Frontmatter is the YAML block between two --- lines at the very top of the file. The docs say: "All fields are optional. Only description is recommended so Claude knows when to use the skill." The most-used fields:

FieldWhat it doesIn the open standard?
nameThe /command name. Defaults to the folder name.Yes (required there)
descriptionWhat it does and when to use it. Claude matches requests against this.Yes (required there)
when_to_useExtra trigger phrases, appended to the descriptionNo
disable-model-invocationtrue = only you can run it with /nameNo
user-invocablefalse = hide it from the / menu, only Claude uses itNo
allowed-toolsTools Claude may use without asking during the turn that invokes the skillYes (experimental)
argument-hint, argumentsAutocomplete hint and named arguments like $issueNo
context, agentcontext: fork runs the skill in a subagentNo
pathsOnly auto-load when working on matching filesNo
license, compatibility, metadataAccepted by Claude Code, but it does not act on themYes

The skills page documents 20 fields in all, including model, effort and hooks. Two rules cause most mistakes. First, "Claude Code ignores a field it doesn't recognize without reporting an error", so a typo silently does nothing. Second, claude.ai uploads, the Skills API and Anthropic's packaging script accept only six fields (name, description, license, compatibility, metadata, allowed-tools) and fail with a hard error on anything else.

The open standard is also stricter about name: 1 to 64 characters, lowercase letters, numbers and single hyphens, not starting or ending with a hyphen, and matching the folder name. The description is capped at 1,024 characters there; Claude Code truncates description plus when_to_use at 1,536 characters in its skill listing.

What CLAUDE.md is

The memory docs define CLAUDE.md files as "markdown files that give Claude persistent instructions for a project, your personal workflow, or your entire organization." Claude reads them at the start of every session. You can put one in several places:

  • User: ~/.claude/CLAUDE.md, your preferences across all projects.
  • Project: ./CLAUDE.md or ./.claude/CLAUDE.md, committed so the team shares it.
  • Local: ./CLAUDE.local.md, personal notes for one project; add it to .gitignore.

The docs recommend a target of "under 200 lines per CLAUDE.md file", concrete rules ("Use 2-space indentation" rather than "Format code properly"), and running /init to generate a first draft. A line such as @AGENTS.md imports another file. If something is a multi-step procedure rather than a fact, the docs suggest moving it into a skill.

What AGENTS.md is

The agents.md site describes it as "A simple, open format for guiding coding agents, used by over 60k open-source projects", and as "a README for agents". There are no required fields: "AGENTS.md is just standard Markdown. Use any headings you like". The format came from work across OpenAI Codex, Amp, Jules from Google, Cursor and Factory, and the site says it "is now stewarded by the Agentic AI Foundation under the Linux Foundation". Its GitHub repository is MIT licensed with 25,483 stars on 14 November 2026.

How tools read it differs, so check your agent's docs:

  • OpenAI Codex "reads AGENTS.md files before doing any work". It reads a global file in ~/.codex, then walks from the project root down to your current folder, taking at most one file per folder, with AGENTS.override.md beating AGENTS.md. Files closer to your folder come later and win. It stops adding files at 32 KiB by default (project_doc_max_bytes).
  • Claude Code reads AGENTS.md only when there is no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in your working folder or above it. It does not read AGENTS.local.md or AGENTS.override.md. You can change this with the Project instructions setting in /config.

If your team uses several agents, keep one shared AGENTS.md. Claude Code 2.1.277 and later reads it on its own when there is no CLAUDE.md; if you also want Claude-specific rules, the docs show a CLAUDE.md that imports it with @AGENTS.md and adds them below. Step 5 does that, which also covers older versions.

Build a working skill, step by step

The example skill drafts a Conventional Commits message from your staged changes. It never commits on its own, and it shows a good description, live context and a supporting file.

Step 1: Create a practice repository

Working in a throwaway repo means nothing touches your real projects or settings.

mkdir demo-repo && cd demo-repo
git init -b main
mkdir -p .claude/skills/commit-message

On Windows PowerShell, run mkdir demo-repo and cd demo-repo as separate commands (&& needs PowerShell 7 or later), and replace the last line with New-Item -ItemType Directory -Force .claude\skills\commit-message.

Step 2: Write SKILL.md

The description is what Claude matches against, so it says both what the skill does and when to use it.

Save as .claude/skills/commit-message/SKILL.md:

---
name: commit-message
description: Drafts a Conventional Commits message from the staged git diff. Use when the user asks for a commit message, says "write my commit", or wants to commit staged changes.
license: MIT
---

## Staged changes

!`git diff --cached --stat`

!`git diff --cached`

## Instructions

1. If the diff above is empty, say "Nothing is staged" and stop.
2. Pick one type from [reference.md](reference.md) that best fits the change.
3. Write a subject line under 72 characters: `type(scope): summary` in the imperative mood.
4. Add a body only if the change needs a "why". Wrap it at 72 characters.
5. Show the message in a code block. Do not run `git commit` unless the user asks.

The !`git diff --cached` lines use what the docs call dynamic context injection: Claude Code runs the command and pastes its output into the skill before Claude reads it. That feature works only in Claude Code, not in claude.ai chat or the API. The frontmatter uses only fields from the open standard, so the same file would also pass a claude.ai upload.

Step 3: Add the supporting file

Reference material lives in its own file so it loads only when the skill needs it.

Save as .claude/skills/commit-message/reference.md:

# Conventional Commit types

- feat: a new feature
- fix: a bug fix
- docs: documentation only
- refactor: code change that neither fixes a bug nor adds a feature
- test: adding or fixing tests
- chore: tooling, build or dependency changes

Step 4: Validate the frontmatter

Claude Code has a built-in check for frontmatter that does not parse. Run it on the skills folder:

claude plugin validate .claude/skills

We ran it with HOME pointed at a scratch folder, because in our test it wrote a .claude.json into the home folder; you do not need to.

That check does not catch misspelled field names. We added disable-model-invokation: true (note the typo) and it still printed "Validation passed", even with --strict. So we also wrote a short script that compares the frontmatter with the 20 documented Claude Code fields and the six open-standard fields, and checks the standard's name format. Run it inside a virtual environment so nothing installs globally:

# macOS / Linux
python3 -m venv .venv
.venv/bin/pip install pyyaml
.venv/bin/python validate_skill.py .claude/skills/commit-message

# Windows PowerShell
py -m venv .venv
.venv\Scripts\pip install pyyaml
.venv\Scripts\python validate_skill.py .claude\skills\commit-message

Save this as validate_skill.py in the repo root:

import re, sys
from pathlib import Path
import yaml

CLAUDE_CODE_FIELDS = {
    "name", "description", "when_to_use", "argument-hint", "arguments",
    "disable-model-invocation", "user-invocable", "allowed-tools",
    "disallowed-tools", "model", "effort", "context", "agent", "background",
    "hooks", "paths", "shell", "metadata", "license", "compatibility",
}
SPEC_FIELDS = {"name", "description", "license", "compatibility", "metadata", "allowed-tools"}

skill_dir = Path(sys.argv[1]).resolve()
text = (skill_dir / "SKILL.md").read_text(encoding="utf-8")
end = text.find("\n---", 4)
if not text.startswith("---\n") or end == -1:
    sys.exit("ERROR frontmatter must start and end with a --- line")
try:
    meta = yaml.safe_load(text[4:end]) or {}
except yaml.YAMLError as exc:
    sys.exit(f"ERROR YAML does not parse: {exc}")

errors, warnings = [], []
not_portable = sorted(set(meta) - SPEC_FIELDS)
if not_portable:
    warnings.append(f"not in the Agent Skills spec (claude.ai upload would fail): {not_portable}")
unknown = sorted(set(meta) - CLAUDE_CODE_FIELDS)
if unknown:
    errors.append(f"unknown field(s), Claude Code ignores them: {unknown}")
name = str(meta.get("name", skill_dir.name))
if not re.fullmatch(r"[a-z0-9]+(-[a-z0-9]+)*", name) or len(name) > 64:
    errors.append(f"name '{name}' breaks the Agent Skills spec: 1-64 chars of a-z, 0-9 and single hyphens")

for w in warnings:
    print("WARN ", w)
for e in errors:
    print("ERROR", e)
print("OK" if not errors else "FAILED")
sys.exit(1 if errors else 0)

Step 5: Add AGENTS.md and a CLAUDE.md that imports it

One shared file keeps every agent on the same rules; the CLAUDE.md adds anything Claude-specific.

AGENTS.md at the repo root:

# AGENTS.md

## Setup commands
- Install deps: `npm install`
- Run tests: `npm test`

## Code style
- 2-space indentation
- Prefer named exports

CLAUDE.md next to it:

@AGENTS.md

## Claude Code

Use the commit-message skill for every commit.

A symlink (ln -s AGENTS.md CLAUDE.md) also works, but the docs prefer the import if anyone uses Windows.

Step 6: Choose where the skill lives

Where you save the folder decides which sessions load it. From the docs:

  • Project scope: .claude/skills/commit-message/SKILL.md inside the repo. Loads in sessions in that repository; commit it and your team gets it. This is where Steps 1 to 3 put it.
  • User (personal) scope: ~/.claude/skills/commit-message/SKILL.md. Loads in all your projects on that machine. On Windows, ~ is your user profile folder.

To move the skill to user scope on your own machine (we did not run this, to avoid writing to a real home folder):

# macOS / Linux
mkdir -p ~/.claude/skills
cp -R .claude/skills/commit-message ~/.claude/skills/

# Windows PowerShell
New-Item -ItemType Directory -Force "$HOME\.claude\skills"
Copy-Item -Recurse .claude\skills\commit-message "$HOME\.claude\skills\"

Check it worked

From the practice repo, both checks should pass. This is what we saw:

$ claude plugin validate .claude/skills
Validating components in: .../demo-repo/.claude/skills

✔ Validation passed

$ .venv/bin/python validate_skill.py .claude/skills/commit-message
OK

And the deliberately broken copy (name Commit_Message, plus argument-hint and the misspelled field) fails the script:

WARN  not in the Agent Skills spec (claude.ai upload would fail): ['argument-hint', 'disable-model-invokation']
ERROR unknown field(s), Claude Code ignores them: ['disable-model-invokation']
ERROR name 'Commit_Message' breaks the Agent Skills spec: 1-64 chars of a-z, 0-9 and single hyphens
FAILED

Inside a Claude Code session (described from the docs; we did not start one), stage a change, then ask "What skills are available?" or type /commit-message. Run /context all and look under Memory files to confirm CLAUDE.md loaded.

Troubleshooting

  • YAML frontmatter failed to parse: YAML Parse error: Unexpected EOF (hit in our test with an unclosed quote). Claude Code adds: "At runtime this skill loads with empty metadata (all frontmatter fields silently dropped)." Fix the quote or bracket; /skill-name still works meanwhile, but Claude cannot auto-match the description.
  • A field seems to do nothing. Usually a typo. The docs: "Claude Code ignores a field it doesn't recognize without reporting an error", and in our test claude plugin validate --strict did not flag it either. Compare names with the frontmatter table, hyphens included.
  • mapping values are not allowed here (PyYAML, our test). An unquoted colon inside the description, such as description: Commit helper: drafts.... claude plugin validate accepted it, but stricter YAML parsers in other tools do not. Wrap the description in quotes.
  • Unexpected key(s) in SKILL.md frontmatter: argument-hint. Allowed properties are: allowed-tools, compatibility, description, license, metadata, name (from the docs). Shown when uploading to claude.ai or the Skills API. Remove Claude Code-only fields from skills you upload.
  • Skill not triggering (docs). Put the words users actually say into the description, check the skill appears when you ask "What skills are available?", or call it directly with /skill-name.
  • AGENTS.md is ignored by Claude Code (docs). Look for a CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md on the path; any of them stops Claude reading AGENTS.md. Also confirm claude --version is 2.1.277 or later. The import in Step 5 avoids the problem.

What to do next

FAQ

Should something go in CLAUDE.md or in a skill?

Facts that apply to every task (build commands, layout, "always do X") go in CLAUDE.md. Multi-step procedures, or reference material only one kind of task needs, go in a skill. The docs suggest creating a skill when "a section of CLAUDE.md has grown into a procedure rather than a fact."

Are skills the same as slash commands?

They have been merged. Old .claude/commands/name.md files still work and create the same /name command, but skills add a folder for supporting files and let Claude load them automatically.

Does Codex read CLAUDE.md?

Not by default. Codex looks for AGENTS.override.md and AGENTS.md, plus any names you list in project_doc_fallback_filenames in ~/.codex/config.toml. Keeping one AGENTS.md and importing it from CLAUDE.md serves both tools.

Do skills work outside Claude Code?

The format does: skills using only the open-standard fields can go to claude.ai and the Skills API, and Google's ADK docs list Agent Skills support. !`command` injection runs only in Claude Code.

How this guide was tested

Docs read on 14 November 2026: code.claude.com skills and memory pages (Markdown versions), agentskills.io/specification, agents.md and the agentsmd/agents.md GitHub repository (stars and licence via gh api), and OpenAI's Codex AGENTS.md guide. Executed on macOS 26.5 (Apple M4) with Claude Code 2.1.325, git 2.50.1 and Python 3.14.3 (PyYAML 6.0.3 in a venv): creating the practice repo and every file shown, both validators on the good skill, the broken-name and misspelled-field copy, the unquoted-colon copy and the unclosed-quote copy, all inside a scratch folder with HOME redirected for the claude command. Docs-only, not executed: starting a Claude Code session, invoking the skill, /context, copying to a real ~/.claude/skills, every Windows command, and Codex behaviour. We did not run the spec's skills-ref validator, because its PyPI release did not match the GitHub source. We re-test these steps monthly and record any change in this page's changelog.