Agent Skills guide
How to create a Claude skill (Agent Skill) from scratch
Create a Claude skill in ~/.claude/skills: write a SKILL.md with a description that triggers, add a script, test it, then make it work in other agents too.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
To create a Claude skill, make a folder at ~/.claude/skills/<name>/ (or .claude/skills/<name>/ inside a project) and put a SKILL.md file in it. The file needs YAML frontmatter with a name that matches the folder and a description that says what the skill does and when to use it, followed by Markdown instructions. Claude Code picks it up without a restart.
~/.claude/skills/pr-description/
├── SKILL.md # frontmatter + instructions (required)
└── scripts/
└── branch_summary.sh # optional helper the skill runs
The fastest way to understand skills is to write one, so this guide builds that folder: pr-description, a skill that drafts a pull request description from the changes on your branch, in your team’s format. It is small enough to finish in half an hour and useful enough to keep. If you are not sure what a skill is yet, read what Agent Skills are first.
You need Git, a repository with a branch that has some commits on it, and an agent that supports skills. The steps use Claude Code paths; the last section shows how to make the same folder work in Codex, Cursor and Copilot. If you do not write code and use Claude on claude.ai, follow the Claude skill recipe for a recurring office task instead.
1. Pick one job
Good first skills share three traits: the task comes up often, you keep explaining the same preferences, and there is a right way to do it that the model does not know. A PR description fits. The model can summarise a diff on its own, but it does not know your template, that you link tickets in a particular way, or that reviewers want a testing section.
Write down what you would tell a new colleague. That is the raw material for the skill.
2. Create the skill folder
mkdir -p ~/.claude/skills/pr-description/scripts
cd ~/.claude/skills/pr-description
The folder name becomes the skill’s name, and the spec requires them to match. Use lowercase letters, digits and hyphens.
3. Write the description first
The description is the only part the agent sees until it decides to use the skill, so it carries most of the weight. It needs to say what the skill does and when to use it, using the words people actually type.
---
name: pr-description
description: Drafts a pull request description from the commits and diff on the current branch, using the team template with summary, changes, testing and linked tickets. Use when the user asks for a PR description, PR body, pull request summary, or is about to open a pull request.
---
Compare that with “Helps with pull requests”. The vague version gives the agent nothing to match against and nothing that separates it from other Git skills. Write in the third person, put the main use first (some clients truncate long descriptions), and list a few trigger phrases. Skill description best practices goes deeper, with before and after examples.
If you would rather fill in a form, the SKILL.md generator and validator writes the frontmatter for you and flags names and descriptions that break the spec.
4. Write the instructions
Below the frontmatter, write what the agent should do. Keep it to what the model would not know or would not do reliably. You do not need to explain what a diff is.
# PR description
Write the description in the team format below. Do not open the pull request
yourself; return the text so the user can paste or edit it.
## Steps
1. Run `scripts/branch_summary.sh` with the base branch (default `main`) to get
the commit list and changed files. Read the full diff only for files whose
purpose is unclear from the summary.
2. Find ticket ids in the branch name or commit messages. They look like
`PLAT-123`.
3. Fill in the template. Keep the summary to two sentences a reviewer could
read without opening the code.
4. If you cannot tell how the change was tested, say so under Testing rather
than guessing.
## Template
```
## Summary
<two sentences: what changed and why>
## Changes
- <one bullet per meaningful change, grouped by area>
## Testing
- <commands run, manual checks, or "Not tested yet">
## Tickets
<PLAT-123, PLAT-456, or "None">
```
Notice the specifics: a ticket pattern, a length limit, what to do when information is missing. Those are the parts that change the output.
5. Add a script for the mechanical part
Collecting commits and file stats is the same every time, so a script is cheaper and more predictable than letting the agent improvise Git commands. Save this as scripts/branch_summary.sh:
#!/usr/bin/env bash
# Usage: branch_summary.sh [base-branch]
# Prints the commits and changed files on HEAD since it diverged from the base.
set -euo pipefail
base="${1:-main}"
if ! git rev-parse --verify --quiet "$base" >/dev/null; then
echo "error: base branch '$base' not found" >&2
exit 2
fi
echo "## Commits"
git log --oneline "$base"..HEAD
echo
echo "## Files changed"
git diff --stat "$base"...HEAD
Then make it executable:
chmod +x scripts/branch_summary.sh
The script takes its input as an argument, never prompts, writes errors to stderr and exits with a non-zero code on failure. Those habits matter because the agent cannot answer an interactive prompt and relies on the exit code to know something went wrong.
6. Try it in Claude Code
Claude Code picks up new skills in ~/.claude/skills/ without a restart. Open a repository with a feature branch and try both ways in:
/pr-description
I'm about to open a PR for this branch, can you write the description?
The first calls the skill directly. The second tests whether the description triggers it. If the second does not load the skill, the description is the thing to fix, not the instructions.
7. Improve it with real failures
Run it on three or four real branches and note what went wrong. Typical first-round problems:
- It reads the whole diff on a large branch and runs out of room. Tighten step 1.
- It invents test steps. Strengthen the rule in step 4.
- It triggers when someone asks for a commit message. Add “not for commit messages” to the description, or narrow the trigger phrases.
Change one thing at a time and rerun the same branches so you can tell what helped. Testing and evaluating skills turns this into a repeatable process, and Anthropic’s skill-creator can automate much of it.
8. Make it work in other agents
Your folder uses only name and description, so it is already portable. Other agents just look in different places:
# Codex, Cursor, Copilot, Gemini CLI and others read .agents/skills
mkdir -p ~/.agents/skills
cp -R ~/.claude/skills/pr-description ~/.agents/skills/
To share it with your team, commit it to the repository under .claude/skills/pr-description/ (for Claude Code) and .agents/skills/pr-description/ (for most others). To upload it to claude.ai, zip the folder. That works here because the name contains no reserved words and there are no extra fields, although the script only helps where the agent can run Git against your repository.
For every agent’s folders and install commands, see how to install Agent Skills. When the skill is ready for more people than your own team’s repository, packaging and sharing skills covers plugins and marketplaces.
If you later add Claude Code-only fields, such as disable-model-invocation: true to make it user-invoked, remember that claude.ai will refuse the upload until you remove them. The format reference lists which fields belong to which client.
Check your understanding
First Agent Skill quiz
Choosing a first job, folder and name rules, writing a description that triggers, instructions with specifics, scripts an agent can run, testing triggers and porting a skill.
8 questions · pass mark 70%
Review
Related
- Ship a team Agent Skill end to end: build, test, share
An Agent Skill example project from idea to install: write SKILL.md, validate it against the spec, test when it fires and share it with one install command.
- Agent Skills authoring
Writing, testing and sharing SKILL.md packages that agents load on demand.
- SKILL.md format reference
Every SKILL.md frontmatter field in the Agent Skills spec, the extra fields each agent adds, size budgets, folder layout and the mistakes that stop loading.