Agent skills: what they are and how to write a SKILL.md
Zihua Li · · 10 min read
Every coding agent eventually gets told the same things twice: how your team writes migrations, which script cuts a release, what a good pull request description looks like. Agent skills are the format for writing that down once, in a folder the agent reads only when the task calls for it, and the same folder now works in Claude, Codex, Cursor, GitHub Copilot and Gemini CLI.
Agent skills are folders that teach an AI agent a specific task. Each one holds a SKILL.md file with YAML frontmatter (a name and a description of when to use it) followed by Markdown instructions, plus optional scripts, reference documents and templates. Agents load only the name and description at startup and read the rest when a task matches. The format started at Anthropic and is now an open standard, documented at agentskills.io, that Claude, Codex, Cursor, GitHub Copilot and Gemini CLI all read.
What an agent skill is
A skill is a directory. The only required file is SKILL.md; everything else is optional and follows a convention from the Agent Skills specification:
db-migration-check/
├── SKILL.md # required: frontmatter + instructions
├── scripts/
│ └── lint_migration.py # code the agent runs; only its output enters context
├── references/
│ └── postgres-locks.md # read only when the instructions point to it
└── assets/
└── rollback-template.sqlscripts/ holds code the agent can run, references/ holds documents it reads when it needs them, and assets/ holds templates, schemas and other static files. The folder name matters: the spec requires the skill’s name to match it.
That makes a skill different from the other places you put instructions. A CLAUDE.md or AGENTS.md file is read at the start of every session, so it suits facts that are always true about the repository. A skill sits idle until a task needs it, so it can be long and specific without costing anything in the sessions that don’t use it. And unlike an MCP server, a skill isn’t a running program; it’s knowledge, plus whatever scripts that knowledge needs.
The tasks that make good skills share a shape: they recur, they have a right way to do them that the model wouldn’t guess, and they end in something checkable. In a codebase that means things like cutting a release with your versioning rules, writing a migration that won’t lock a hot table, adding an endpoint the way the rest of the API is built, triaging a flaky test, or preparing a branch for review. Anthropic’s public anthropics/skills repository shows the range beyond code, from document formats such as PDF and spreadsheets to brand guidelines and a skill for writing new skills. A one-line preference (“use pnpm”) is not a skill; it belongs in the project’s instructions file.
How agents load skills: progressive disclosure
The format is built around loading as little as possible. Anthropic’s documentation and the spec describe three levels:
- Metadata, always loaded. At startup the agent reads the
nameanddescriptionof every installed skill, roughly 100 tokens each, so it knows what exists. - Instructions, loaded when triggered. When a request matches a description, or you call the skill by name, the agent reads the body of
SKILL.md. The recommended size is under 5,000 tokens. - Resources, loaded as needed. Files in
references/enter context only when the agent opens them. Scripts run through the shell, and only their output enters context, never their source.
Two practical consequences follow. You can install dozens of skills and pay only for their descriptions, which is why the description is the most important line you write. And a script is cheaper and more reliable than prose: a 200-line linter in scripts/ costs the agent one line of output, where the same rules written as instructions would sit in context for the rest of the session.
Agents do cap the metadata budget. Claude Code truncates each skill’s description at 1,536 characters in its listing. Codex gives the initial skill list at most 2% of the model’s context window by default and starts shortening descriptions when many skills are installed. Put the trigger in the first sentence.
Which agents support agent skills, and where they look
The same SKILL.md works across agents; what differs is the folder each one scans and how you call a skill by hand. As of November 2026:
| Agent | Project skills | Personal skills | How a skill runs |
|---|---|---|---|
| Claude Code | .claude/skills/<name>/ (also in parent and nested directories) | ~/.claude/skills/<name>/ | /<name>, or automatically from the description |
| Claude.ai and the Claude API | Uploaded as a zip in settings, or through the Skills API | Per account (claude.ai) or per workspace (API) | Automatically when a request matches |
| OpenAI Codex | .agents/skills/ from the working directory up to the repository root | ~/.agents/skills/ (plus /etc/codex/skills for admins) | $<name> or /skills, or automatically |
| Cursor | .agents/skills/ or .cursor/skills/ (also reads .claude/skills/ and .codex/skills/) | ~/.agents/skills/ or ~/.cursor/skills/ | /<name> in Agent chat, or automatically |
| GitHub Copilot | .github/skills/, .claude/skills/ or .agents/skills/ | ~/.copilot/skills/ or ~/.agents/skills/ | Automatically, in the CLI, cloud agent, code review and IDE agent mode |
| Gemini CLI | .gemini/skills/ or .agents/skills/ | ~/.gemini/skills/ or ~/.agents/skills/ | The model calls activate_skill, and you confirm |
.agents/skills/ is the closest thing to a shared address: Codex, Cursor, Copilot and Gemini CLI all read it, and Cursor and Copilot also read .claude/skills/. Claude Code reads only its own folder, so a repository that wants one copy for everyone usually keeps skills in .agents/skills/ and symlinks .claude/skills/ to it. Codex follows symlinks, as its documentation notes.
Each agent has its own details beyond the common format, covered in the dedicated guides: Claude Code skills (including bundled skills such as /code-review), Codex skills (the $skill syntax and the built-in skill installer) and Cursor skills (how skills relate to rules and commands).
The Claude surfaces deserve one warning. Claude Code, Claude.ai and the Claude API all support skills, but they don’t share them: a skill in ~/.claude/skills/ is not available on Claude.ai, and one uploaded to Claude.ai is not available through the API. Upload it separately to each surface that needs it.
How to write an agent skill
Here is a complete skill for a task most teams repeat by hand: checking a database migration before it ships.
---
name: db-migration-check
description: Checks new database migrations for table locks, data loss and
missing rollbacks. Use when a change adds or edits files under
db/migrations, or when the user asks whether a migration is safe to deploy.
---
# Database migration check
1. List the migrations changed on this branch:
git diff --name-only origin/main -- db/migrations
2. For each file, run scripts/lint_migration.py <file> and read its output.
3. For any ALTER TABLE on a large table, check references/postgres-locks.md
for the lock it takes.
4. If a migration has no down step, draft one from assets/rollback-template.sql.
Report each problem as: file, line, what breaks, and the safer version.
## Example
Input: a migration that renames orders.total to orders.amount.
Output: "Renaming orders.total breaks the release that is still running.
Add orders.amount, backfill it, switch reads, then drop orders.total
in a later release."The pieces that make it work:
The name
Up to 64 characters of lowercase letters, numbers and single hyphens, matching the folder name. Claude’s surfaces also reject names containing the reserved words anthropic or claude. The name becomes the command you type to run the skill by hand, so make it something you’d type.
A description that triggers
The description, up to 1,024 characters, is what the agent matches requests against. It has to answer two questions: what the skill does, and when to use it. Name the files, directories and phrases that should pull it in:
# Too vague: the agent can't tell when this applies
description: Helps with migrations.
# Says what it does, and names the files and phrases that should trigger it
description: Checks new database migrations for table locks, data loss and
missing rollbacks. Use when a change adds or edits files under
db/migrations, or when the user asks whether a migration is safe to deploy.Anthropic’s authoring guide also recommends writing the description in the third person, because it is inserted into the system prompt alongside every other skill’s.
A short body with steps and an example
The body is read in full whenever the skill triggers, so keep it to the procedure: numbered steps, the exact commands, the shape of the output, and one worked example of input and output. The spec’s guidance is to stay under 500 lines and move detail into references/, linked one level deep from SKILL.md so the agent doesn’t chase a chain of files. Leave out what the model already knows; “a migration can lock a table” is wasted tokens, while “ALTER TABLE on orders takes an ACCESS EXCLUSIVE lock in our setup, see references/postgres-locks.md” is the knowledge only your team has.
Scripts for anything deterministic
Whenever a step has one right answer, such as parsing a file, running a linter or formatting a report, write a script and tell the agent to run it. Scripts should print useful errors, because their output is all the agent sees.
Optional fields
The spec adds license, compatibility (environment requirements, up to 500 characters), metadata (string key-value pairs) and an experimental allowed-tools list. Agents add their own extensions, such as Claude Code’s disable-model-invocation: true, which keeps a skill from running unless you type its name. Claude Code ignores fields it doesn’t recognize, but Claude.ai and the Skills API reject anything outside the spec’s fields at upload, so keep agent-specific extensions out of skills you plan to share across surfaces.
Test it
The spec’s reference library validates the frontmatter with skills-ref validate ./db-migration-check. Then test the trigger, not just the syntax: start a fresh session, ask for the task in the words a teammate would use (“is this migration safe?”) without naming the skill, and check that the agent picks it up. If it doesn’t, the description is missing the words people actually say.
How to install and share agent skills
Because a skill is just a folder, the simplest install is a copy, and the simplest way to share one with your team is to commit it in the project’s skills directory. Beyond that, three routes are common:
# Copy a folder into the agent's skills directory
cp -r db-migration-check .claude/skills/ # Claude Code (project)
cp -r db-migration-check .agents/skills/ # Codex, Cursor, Copilot, Gemini CLI
# Or install from a GitHub repository with the skills CLI
npx skills@latest add heydeer/skills --skill ci-audit
# Gemini CLI has its own installer
gemini skills install https://github.com/user/repo.git --scope workspace- The skills CLI.
npx skills addinstalls skills from any GitHub repository into Claude Code, Codex, Cursor and dozens of other agents at once, and keeps track of them for updates. The npx skills guide covers its flags and where it writes files. - Plugins. Claude Code and Codex both package skills in plugins, which install from marketplaces, update automatically and keep skill names namespaced. See Claude Code plugins for how marketplaces work.
- Agent-specific installers. Codex ships a built-in
skill-installerskill, and Gemini CLI hasgemini skills install.
To find skills worth installing, start with the public repositories that publish them in this format, such as anthropics/skills and openai/skills, and the agent skills GitHub topic. The best Claude Code skills list has specific picks. For review work in particular, the Claude Code review skill guide covers what ships with Claude Code.
Treat third-party skills like software you install
A skill can tell the agent to run commands, and it can ship scripts that run with your permissions. Anthropic’s own guidance is to use skills only from trusted sources and to audit anything else as you would any software dependency. Before installing a skill from GitHub:
- Read
SKILL.mdin full, including instructions buried in long reference files. Instructions that don’t match the stated purpose, such as uploading files or reading credentials, are the red flag. - Read every script, and look for network calls. Skills that fetch content from external URLs are riskier, because the fetched text can carry instructions of its own and can change after you reviewed it.
- Pin a version or commit, and review the diff when you update.
- Be stricter about
allowed-tools: a skill that pre-approves shell commands lets them run without asking.
The same care applies to code a skill helps produce. Agent-written changes still need review before they merge; vibe coding security covers the patterns that slip through most often.
Agent skills from HeyDeer
HeyDeer, an AI code review service for GitHub pull requests, publishes free, MIT-licensed agent skills for Claude Code, Codex and Cursor at heydeer.ai/skills, with the source at github.com/heydeer/skills. The first is ci-audit, which reads your last two weeks of GitHub Actions runs, reports what you could save each month, and turns the fixes you pick into small pull requests. Install it with npx skills@latest add heydeer/skills --skill ci-audit and run /ci-audit, or $ci-audit in Codex.
For review, HeyDeer also has a command-line tool that coding agents can call directly. heydeer review --json reviews a branch and its uncommitted changes before a pull request exists and returns the findings as one JSON object, so an agent can fix what it agrees with and run it again.
Sources
- Agent Skills: Overview
- Agent Skills: Specification
- Claude Docs: Agent Skills overview
- Claude Docs: Skill authoring best practices
- Claude Code Docs: Skills
- OpenAI Codex docs: Build skills
- Cursor Docs: Skills
- GitHub Docs: About agent skills
- Gemini CLI Docs: Agent Skills
- anthropics/skills on GitHub
- vercel-labs/skills (npx skills)
- heydeer/skills on GitHub
Frequently asked questions
What are agent skills?
Agent skills are folders of instructions and resources that an AI agent loads on demand to do a specific task. Each skill has a SKILL.md file with a name and a description in YAML frontmatter, followed by Markdown instructions, and can bundle scripts, references and templates. The format is an open standard that Claude, Codex, Cursor, GitHub Copilot and Gemini CLI support.
What do agent skills look like?
An agent skill looks like a folder named after the skill, such as db-migration-check/, with a SKILL.md file inside. SKILL.md starts with YAML frontmatter holding name and description, then Markdown steps and examples. Optional scripts/, references/ and assets/ folders hold code the agent runs, documents it reads when needed, and templates.
How do I write an agent skill?
To write an agent skill, create a folder named after the task, add a SKILL.md whose frontmatter has a lowercase hyphenated name matching the folder and a description that says what the skill does and when to use it, then write short numbered instructions and one input-output example. Move long reference material into separate files and keep SKILL.md under 500 lines.
What is the difference between agent skills and MCP?
Agent skills and MCP solve different problems. A skill is instructions and files that teach an agent how to do a task, loaded into context when relevant. An MCP server is a running program that gives the agent new tools, such as access to a database or an API. Skills often tell the agent when and how to use tools that MCP servers provide.
Where are agent skills stored?
Agent skills are stored in a skills folder the agent scans. Claude Code reads .claude/skills/ in the project and ~/.claude/skills/ for personal skills. Codex, Cursor, GitHub Copilot and Gemini CLI all read .agents/skills/ in the project and ~/.agents/skills/ in your home directory, alongside their own folders such as .cursor/skills/ or .github/skills/.
Are agent skills on GitHub safe to install?
Agent skills on GitHub are as safe as the code and instructions inside them, because a skill can tell the agent to run commands and can ship scripts that run with your permissions. Read SKILL.md and every script before installing, prefer skills from authors you know, and pin the version you reviewed.
Do agent skills work in Claude.ai as well as Claude Code?
Agent skills work in Claude.ai, the Claude API and Claude Code, but each surface keeps its own copy. Claude Code reads skills from folders on disk, Claude.ai takes custom skills uploaded as zip files on paid plans with code execution enabled, and the API takes skills uploaded through the Skills API. A skill added to one surface does not sync to the others.



