What this unit solvesSkills package repeating workflows into procedures the model can invoke automatically via the
description field. A skill is more than a single SKILL.md: depending on the required rigor and scope, it may include a references/ directory for few-shot templates and specs, and a scripts/ directory for executable tool scripts. This unit walks through building a practical skill from scratch, explains how to write the description, uses progressive disclosure to manage token costs, and compares equivalent mechanisms across tools.Learning objectives
- Write a correctly structured
SKILL.mdwith adescriptionand the necessary frontmatter fields. - Decide when to create a
references/subdirectory (few-shot templates, spec documents) and ascripts/subdirectory (executable scripts). - Use progressive disclosure to control token consumption so a complex skill does not dump all its content into context on every invocation.
- Decide whether a given requirement belongs in a Skill, Rules, or Subagent, and articulate the criteria.
- Compare equivalent skill-packaging mechanisms across tools and identify the key differences.
1. What a skill is
A skill is a directory placed at~/.claude/skills/<name>/ or .claude/skills/<name>/, containing a required SKILL.md and optional references/ and scripts/. Claude invokes it automatically based on description semantics during conversation; users can also trigger it explicitly with /<name> [1].
The fundamental difference from CLAUDE.md:
| Dimension | CLAUDE.md | Skill |
|---|---|---|
| Load time | Injected in full at every session start | Fully loaded only when the model judges it relevant, or the user types /<name> |
| Content cost | Paid every session, across the entire conversation | Only injected in the triggering turn; zero cost if never triggered |
| Appropriate content | General conventions, mandatory rules | Procedures, workflows, domain knowledge invoked by context |
Skills and Commands now share the same underlying mechanismAs of 2026-06,
.claude/commands/<name>.md and .claude/skills/<name>/SKILL.md in Claude Code are backed by the same mechanism: both produce a /<name> command. The difference is that the latter has a directory where you can place references/ and scripts/, while the former is a single file [1]. This unit covers the latter (Skills); the design side of explicit triggering is in 04-3.2. Directory structure
my-skill
SKILL.md · required: main instructions and frontmatter
reference.md · optional: detailed API docs, loaded only when needed
examples
scripts
SKILL.md is the entry point; everything else is supporting material. When SKILL.md references reference.md or similar files via relative paths, Claude reads them on demand (see Section 6, progressive disclosure). Scripts in scripts/ are invoked by Claude through the Bash tool, not read into context.
3. Complete SKILL.md frontmatter reference
| Field | Required | Purpose |
|---|---|---|
name | Optional | Display name; defaults to the directory name. Only the root SKILL.md of a plugin uses this to determine the command name |
description | Recommended | The basis on which the model decides whether to invoke the skill. description + when_to_use combined are truncated to 1,536 characters to save context |
when_to_use | Optional | Additional trigger context and example prompts; can fill in edge cases description does not cover |
argument-hint | Optional | Parameter hint shown during autocomplete, e.g. [issue-number] or [filename] [format] |
arguments | Optional | Named positional parameters; can be a string or a list. Names map to positions in order |
disable-model-invocation | Optional | Set true to prevent Claude from invoking automatically. Default false |
user-invocable | Optional | Set false to hide from the / menu; Claude-only invocation. Default true |
allowed-tools | Optional | Tools that do not require confirmation when this skill is active (does not restrict other tools from being used) |
disallowed-tools | Optional | Tools removed from the available pool while this skill is active |
model | Optional | Model to use when this skill is active; overrides the session model and reverts on the next turn |
effort | Optional | Effort level (low / medium / high / xhigh / max); overrides session effort |
context: fork | Optional | Set fork to execute in an isolated subagent context |
agent | Optional | Subagent type to use when context: fork is set (Explore, Plan, custom) |
hooks | Optional | Hooks scoped to this skill’s lifecycle |
paths | Optional | Glob patterns restricting when this skill is considered for automatic invocation |
shell | Optional | Shell for dynamic injection (bash by default; powershell requires CLAUDE_CODE_USE_POWERSHELL_TOOL=1) |
4. Trigger control: description, when_to_use, and paths
How you write the description determines whether the model will invoke your skill. A poor description leads to false triggers or missed triggers.
Description writing comparedToo broad — will trigger on unrelated requests:Too narrow — will miss legitimate triggers:About right:Key observation: including trigger keywords (colloquial phrases, English synonyms) in
description makes it easier for the model to match.paths further narrows the trigger condition so the skill is only considered when working on a certain class of files:
src/api/.
5. Rigor levels: Level 1 to Level 3
Level 1: Single-file skill
Only aSKILL.md, 50 lines or fewer, no external dependencies. Good for quickly packaging a personal recurring workflow.
Level 2: Skill with few-shot examples
SKILL.md plus format examples or spec documents in references/. Good for scenarios requiring strict output format (academic abstracts, standard reports, contract clauses).
abstract-writer
SKILL.md
references
example-1.md · complete abstract example
example-2.md · edge case
style-guide.md · style rules
SKILL.md references them:
Level 3: Skill with executable scripts
SKILL.md plus scripts in scripts/ (Python, Bash, Node.js, etc.). Good for tasks requiring real computation, external APIs, or batch processing; requires careful allowed-tools security configuration.
codebase-visualizer
SKILL.md
scripts
visualize.py
${CLAUDE_SKILL_DIR} so path resolution is independent of where the skill is installed [1]:
6. Progressive disclosure
The core token management strategy for skills. WhenSKILL.md loads it enters context and persists for the remainder of the session [1], but subsidiary files (references/, scripts/) are loaded on demand. This means:
- Simple skill: all of
SKILL.mdgoes into context. - Complex skill: detailed specs, API docs, and few-shot examples live in
references/;SKILL.mdonly describes “when to read whichreferences/file,” using Markdown links.
references/ content actually needed that turn, not with the overall size of the skill.
Token savings from progressive disclosureAn “academic abstract” skill:
SKILL.md is 30 lines with 5 Markdown links pointing to 5 format templates in references/, each 80 lines.Without progressive disclosure: all 5 templates stuffed into SKILL.md; every invocation = 30 + 5 x 80 = 430 lines.With progressive disclosure: SKILL.md is 30 lines plus 5 links; Claude reads a references/ file only when it actually needs that example. Average per invocation = 30 + 80 = 110 lines — 75% savings.Under a 200k context window, 110 and 430 both look small. Multiplied across invocations and team size, the gap is hundreds of dollars per month.7. Skill content lifecycle
When a skill is triggered, the rendered content ofSKILL.md (with $ARGUMENTS substituted and !`cmd` executed) enters the session conversation history as a single message and persists across subsequent turns [1].
When /compact summarizes the conversation to reclaim context, Claude Code reattaches the content of recently invoked skills, retaining up to 5,000 tokens per skill with a shared budget of 25,000 tokens filled from the most recently invoked. This means: if too many skills are invoked in one session, older ones will be dropped entirely [1].
8. Dynamic context injection: !`command`
Inside SKILL.md, !`<command>` executes a shell command before the content is sent to Claude, embedding the output inline [1]:
- Executes in the current shell (
bashby default on macOS/Linux; setshell: powershellon Windows). - Output is inserted as plain text and will not be re-parsed as
!`placeholders. - The inline form only triggers
!at line start or immediately after whitespace;KEY=!`cmd`does not trigger. - Multi-line forms use a
```!fence. - Organizations can set
"disableSkillShellExecution": truein settings to disable this globally (bundled and managed skills are not affected) [1].
9. Tool comparison
| Concept | Anthropic Claude (primary) | OpenAI Codex | Google Antigravity | GitHub Copilot | Cursor |
|---|---|---|---|---|---|
| Skill packaging unit | ~/.claude/skills/<name>/SKILL.md or .claude/skills/<name>/SKILL.md | [[skills.config]] enable control + searches $HOME/.agents/skills/ up to repo root (path is .agents/skills/, not .codex/skills/) | IDE global ~/.gemini/config/skills/; workspace always .agents/skills/ | Personal ~/.copilot/skills/<name>/SKILL.md, project .github/skills/<name>/SKILL.md (same name overrides personal) | Rules for AI (.cursorrules and .cursor/rules/; closer in nature to rules than skills) [3] |
| Automatic invocation | description semantic match + paths glob | Config-driven, integrated with commands / hooks | description semantic match; agent loads automatically based on task | Config-driven | Rule-based (via frontmatter globs) |
| Few-shot attachment directory | references/; other subdirectories named as needed | references/ subdirectory | references/, assets/ subdirectories | Configuration-based | Via sections within .mdc files themselves |
| Executable script directory | scripts/ | scripts/ | scripts/ | Not part of the main flow | Not applicable |
| Tool permission scoping | allowed-tools / disallowed-tools | Configuration-based | Not applicable | Not applicable | Not applicable |
| Per-invocation model | model frontmatter field | Configuration-based | Not applicable | Not applicable | Not applicable |
| Explicit trigger | /<name> command | Integrated with slash commands | Agent auto-detection + / menu | Via / menu | Via / menu |
| Cross-tool standard | Follows the Agent Skills open standard | Partial | Partial (SKILL.md / skills.md) | Partial | Does not follow |
Naming clarifications and important facts
- Claude Code Skills follow the Agent Skills open standard (agentskills.io) [1]. Because this standard is shared across multiple AI tools, skills you write should be directly installable in any compliant editor or CLI.
- OpenAI Codex skill mechanism: configured in the
[skills]section ofconfig.toml; personal skills at~/.agents/skills/<name>/SKILL.md, project skills at<repo>/.agents/skills/<name>/SKILL.md(trusted repos only; enabled per[[skills.config]]inconfig.toml). The path is.agents/skills/, not.codex/skills/(per developers.openai.com/codex/skills, as of 2026-06). - GitHub Copilot “Skills” and “Copilot Extensions” are two separate things: the former is the local CLI’s
SKILL.mdmechanism; the latter is a third-party extension marketplace on GitHub. This table covers only the former. - Cursor has no native “Skill” mechanism;
.cursor/rules/*.mdcis functionally closer to Claude’s rules, and.cursorrulesis a single-file rules variant [3].
10. Pairing with Subagents
Skills provide procedure (steps, criteria, format); Subagents provide isolated context (a clean execution environment). Combining them (see 04-5):context: fork, the skill content becomes the task prompt for a subagent. The subagent executes in a clean context and returns a summary to the main conversation [1].
When to use context: fork:
- The skill needs to perform extensive reads or computation without polluting the main conversation context.
- The task is parallelizable and each sub-task is independent.
- The main conversation context is near its limit and isolation is needed.
Hands-on exercises
Start at Level 1
Pick a workflow you repeat at least three times a week and write a
SKILL.md of 30 lines or fewer, with a description and 2-3 Markdown steps. Place it at ~/.claude/skills/<name>/SKILL.md and start a session to test both automatic triggering and explicit /<name> invocation.Upgrade to Level 2
Extend the skill from Step 1 by adding
references/example.md with a complete few-shot example, and reference it via a Markdown link in SKILL.md. Compare Claude’s output quality with and without the example.Observe token cost
Invoke the skill multiple times within the same session, then run
/context to see how much context the skill content occupies. Cross-check against the SKILL.md line count to verify that skill content enters context in its entirety, as designed.Common pitfalls
Self-check
The bar for passing this unit
- Can you write a
SKILL.mdwith complete frontmatter and adescriptionwith precise trigger conditions? - Can you decide whether a requirement belongs in a Skill, Rules, a Command, or a Subagent, and articulate the decision criteria?
- Can you use progressive disclosure to break a 400-line procedure into a 30-line
SKILL.mdplus areferences/subdirectory? - Do you understand the lifecycle of skill content once it enters context (the
/compactbehavior, the 25k token budget)?
Sources and further reading
Factual claims are grounded in official documentation; fast-changing items are annotated as of 2026-05.-
[1] Anthropic, “Extend Claude with skills,” code.claude.com, 2026. [Online]. Available: https://code.claude.com/docs/en/skills (as of 2026-06; includes complete frontmatter reference,
references/andscripts/, dynamic injection,context: fork, lifecycle) - [2] Anthropic, “Commands,” code.claude.com, 2026. [Online]. Available: https://code.claude.com/docs/en/commands (as of 2026-06; command and skill merged mechanism)
-
[3] Cursor, “Rules,” cursor.com, 2026. [Online]. Available: https://cursor.com/docs/context/rules (as of 2026-06;
.mdcfrontmatter and globs mechanism) - [4] Agent Skills Open Standard, “Agent Skills,” 2026. [Online]. Available: https://agentskills.io (as of 2026-06; open standard for skill packaging shared by Claude Code and other AI tools)
- [5] Agentic AI Foundation (Linux Foundation), “AGENTS.md,” 2026. [Online]. Available: https://agents.md/ (as of 2026-06; cross-tool standard for project rules files)
CLAUDE.mdand auto-memory: 04-1 CLAUDE.md and memory files.- Path-scoped rules mechanism: 04-2 Rules.
- Explicit-trigger command design: 04-3 Commands.
- Combining skills with subagents: 04-5 Subagents.
- Context engineering and token budgets: 01-4 Context engineering.