Writing Claude Skills, Advanced: Supporting Files, Scripts and Trigger Testing
3 November 2026 · Updated 28 November 2026 · 12 min read · by Yang Kai
Advanced Claude Code skill authoring: supporting files, bundled scripts, progressive disclosure done properly, and a repeatable way to test whether your skill triggers when it should.
Template inside: Advanced SKILL.md template with supporting-file layout
Contents
- The short version: three loading levels
- The anatomy of a grown-up skill
- Progressive disclosure, done properly
- Scripts inside skills: run, do not reinvent
- Frontmatter beyond the basics
- Arguments and live data
- An advanced SKILL.md template
- Workflow
- Rules
- Examples
- Testing whether it triggers
- Sharing and versioning
- How we researched this
- Verdict
A single-file skill works until it doesn’t. The trigger fires, the workflow runs — and the agent wades through a long checklist it only needs on review runs, a reference table for one variant, and instructions for steps it will not reach today. The skill is correct and still wasteful, because everything it knows was loaded to do one part of the job.
Advanced skill authoring is the fix: SKILL.md carries the workflow, supporting files carry depth the agent loads only when needed, and bundled scripts carry the steps that must run identically every time. This article covers that structure, the frontmatter controls beyond the basics, and a repeatable way to test whether a skill triggers when it should.
The format details are checked against the Agent Skills specification and Anthropic’s Claude Code documentation (November 2026). If you have not built a basic skill yet, start with the step-by-step first-skill walkthrough; the conceptual explainer covers when a rule should leave CLAUDE.md and become a skill at all.
The short version: three loading levels
Everything in advanced authoring follows from how a skill loads:
| Level | What loads | When | Size guide |
|---|---|---|---|
| 1 — Metadata | name and description |
Every session, for every installed skill | About 100 tokens per skill |
| 2 — Instructions | The SKILL.md body | When the skill triggers | Keep under 5,000 tokens and under 500 lines |
| 3 — Resources | Files in scripts/, references/, assets/ |
Only when a step points at them | No practical limit — scripts execute; only their output enters context |
The anatomy of a grown-up skill
A skill is a directory, not a file. SKILL.md sits at the root with the frontmatter and the core workflow. Around it, three kinds of supporting material earn their place:
- Reference files — detailed material the agent reads only when the task needs it: a long checklist, a style table, worked examples.
- Scripts — deterministic operations the agent should run, not improvise: validators, converters, scaffolding commands.
- Assets and templates — files the agent copies or fills in: boilerplate, starter configs, output formats.
The frontmatter rules are stricter than they look. Per the specification, name allows at most 64 characters — lowercase letters, numbers and hyphens, matching the parent directory name — and cannot contain the words “anthropic” or “claude”. description allows at most 1,024 characters and must state what the skill does and when to use it. In Claude Code’s skill listing, the description plus the optional when_to_use field is truncated at 1,536 characters, so the main use case belongs at the front.
That asymmetry is the whole economic argument, and it is the same one behind keeping always-loaded context lean in the context budget audit: a skill should cost almost nothing until the moment it is useful.
Progressive disclosure, done properly
Three levels, each with a job. Level one is the description: it decides triggering, so it must state what the skill does and when to use it, in the vocabulary a user would actually type. Level two is the SKILL.md body: the workflow itself, kept to the steps that run every time. Level three is the supporting files: depth on demand.
The failure mode is a level-two file that duplicates level three. When the body says “follow the checklist in references/review-checklist.md,” the agent reads the real, current checklist at the right moment. A compressed copy inside the body drifts apart from the original, and the agent follows whichever it read last. One source of truth, referenced — never copied.
Size is the other discipline: if a section only applies to one variant of the task, it is a reference file waiting to happen. Split when a section passes roughly a screenful, or when it is needed by fewer than half of the skill’s runs.
Scripts inside skills: run, do not reinvent
Any step where an agent produces three different shell one-liners for the same job is a script candidate. A bundled script gives you determinism: the same validation, the same flags, the same error messages, every run. It also changes the agent’s job from inventing a procedure to executing one and interpreting the result — a much more reliable division of labour, and the same reasoning that makes the mcp-builder skill in the skills directory useful for scaffolding servers consistently instead of from memory each time.
Rules to hold scripts to:
- Reference them portably. Use
${CLAUDE_SKILL_DIR}in the command path, so the skill works wherever it is installed — personal, project or plugin directory. - Pre-approve the exact command. A scoped
allowed-toolsentry such asBash(${CLAUDE_SKILL_DIR}/scripts/validate.py *)lets the script run without a permission prompt. The grant covers the turn that invoked the skill, and a scoped rule beats approving all of Bash. - Fail loudly. Scripts should print a readable message and exit non-zero on failure, because the agent can only recover from failures it can see.
- Never ask questions. A script that waits for interactive input stalls the run; take input as arguments instead.
- Say what the output means. “Exit 0 means the file is valid; any printed line is a problem to fix” turns raw output into an instruction the agent can act on.
Note what never enters context: the script’s code. It executes, and only its output is returned. A 400-line validator costs the tokens of its result, not its source.
Frontmatter beyond the basics
Two fields are required by the specification; the rest buy control. The optional fields that matter at this level:
| Field | What it does |
|---|---|
license |
Licence terms for a skill you share or sell |
compatibility |
Environment requirements — intended product, packages, network access (up to 500 characters) |
metadata |
Arbitrary key-values, such as version or author |
allowed-tools |
Tools pre-approved for the invoking turn, scoped as narrowly as you can write them |
argument-hint |
Hint shown in autocomplete, e.g. [issue-number] |
when_to_use |
Extra trigger phrases, appended to the description |
disable-model-invocation |
true means only you can start the skill — right for deploys and anything with side effects |
user-invocable |
false hides the skill from the / menu — right for background knowledge only Claude should load |
context: fork |
Runs the skill in a subagent with its own context; pair with agent to pick the subagent type |
One caution: an unrecognised or misspelled field name is ignored without an error, so copy field names from the documentation rather than from memory. A typo in disable-model-invocation silently hands triggering back to the model.
Arguments and live data
Two mechanisms turn a static skill into one that adapts per run.
Arguments. Whatever follows the skill name lands in $ARGUMENTS: type /fix-issue 42 and every $ARGUMENTS placeholder in the body becomes 42. If the body has no placeholder, the arguments are appended to the end of the prompt instead, so nothing typed is silently dropped. Positional placeholders exist for multi-argument skills.
Dynamic context injection. An exclamation mark before a backticked command — !`gh pr diff` — runs the command before the skill content reaches the model, and the output replaces the placeholder. The model receives the data, not an instruction to go and fetch it, which saves the turns a fetch would take. The trade-off is real: the output lands in context in full, so keep injected commands narrow. A multi-line command can use a fenced block opened with ```! instead of the inline form.
An advanced SKILL.md template
my-skill/
├── SKILL.md # workflow + pointers (loads on trigger)
├── references/
│ ├── review-checklist.md # loaded only for the review step
│ └── examples.md # loaded when the agent needs a model
├── scripts/
│ └── validate.py # run, never reinvented inline
└── assets/
└── output-template.md # copied and filled in, not rewritten
---
name: my-skill
description: >
Prepares a release note from merged changes and checks it against
the project checklist. Use when the user asks to draft, write, or
review a release note or changelog entry for this project.
---
# Release notes
## Workflow
1. Collect the changes since the last tag:
`git log <last-tag>..HEAD --oneline`
2. Group changes by audience impact, not by commit order.
3. Draft from `assets/output-template.md` — copy it, then fill it.
4. Validate the draft before presenting it:
`python3 "${CLAUDE_SKILL_DIR}/scripts/validate.py" <draft-file>`
Exit 0 means valid. Any printed line is a problem to fix,
not a warning to mention and ignore.
5. For the review pass only, read
`references/review-checklist.md` and apply every item.
Do not load it while drafting.
## Rules
- Never invent a change that is not in the log output.
- If validation fails twice on the same item, stop and show
the user the failing line instead of rewriting around it.
## Examples
Stuck on tone or grouping? Read `references/examples.md`.
Notice what the template refuses to do: the checklist and examples exist, are named precisely, and are fenced off with when not to load them. That negative instruction is what makes progressive disclosure real rather than theoretical. For a deeper treatment of splitting content out of the main file, see skills with scripts and reference files.
Testing whether it triggers
A skill that never fires is a document, not a tool. Trigger testing is unglamorous and essential, and it mirrors how the skill-creator skill approaches iterating on a skill rather than shipping the first draft.
Build a small test set before you need the skill in anger:
- Write five prompts that should trigger it, phrased the way you would actually ask — including one lazy, vague version.
- Write three that should not: adjacent tasks that belong to a different skill or to no skill.
- Run them in fresh sessions and record what happened.
A miss on a should-trigger prompt is almost always a description problem: the words you ask with are not the words the description listens for. Fix the description, not the body — triggering is decided before the body is ever read. A false trigger is usually an over-broad verb: “helps with documents” will swallow half a working day. Skill descriptions that trigger goes deeper on the wording, and debugging a skill that will not trigger works through the failure checklist.
Test the body separately. Force the skill on a realistic task and watch where the agent hesitates or skips a step. Those are body problems: unclear ordering, a missing command, a pointer without a condition. One fix per run, then re-run.
Record the trigger tests in a table kept with the skill — it takes a minute and makes regressions visible after every description edit:
| Prompt | Should trigger? | Did it? | Fix applied |
|---|---|---|---|
| “Draft the release note for this week’s merges” | Yes | Yes | — |
| “Write the changelog entry” (lazy version) | Yes | No | Added “changelog entry” to the description |
| “Review this pull request” | No — belongs to the review skill | Yes | Removed the bare verb “review” from the description |
| “Summarise this article” | No | No | — |
Two of the four rows needed a description change, which is typical: the first draft of a description is written in the author’s vocabulary, and the test set is where the users’ vocabulary corrects it.
Sharing and versioning
Skills that work tend to spread: into a shared team setup, into other projects, into a pack you hand to someone else. Treat the directory as the unit — it versions and reviews cleanly in git, and a reviewer can see exactly what changed: a script, a checklist, or the workflow itself. Location decides reach: ~/.claude/skills/ makes a skill personal across every project, .claude/skills/ scopes it to one repo where it can be committed and shared.
Portability is better than it was. Anthropic published Agent Skills as an open standard in December 2025, and other tools have adopted the same folder format, so a well-kept skill directory is no longer tied to one product. Before installing anyone else’s skill, run it through install and audit Claude skills safely — a skill is instructions plus scripts, and scripts execute. Sharing skills across projects and teams covers the distribution side in full.
How we researched this
The format facts — field limits, loading levels, invocation controls, substitution and injection syntax — are from the Agent Skills specification and Anthropic’s Claude Code skills documentation, checked November 2026. The structural advice (what to split, when to bundle a script, how to test triggers) is practice guidance built on those mechanics; no trigger rates or performance figures are claimed, because none were measured.
Verdict
Grow a skill like a codebase: structure first, depth behind pointers, scripts for anything deterministic, and tests for the behaviour everything depends on — that it shows up when called. If your skill is still one file and every run needs all of it, leave it alone; the advanced structure earns its keep only when some of the content is needed some of the time.
Learn more:
- Write your first Claude skill, step by step
- Claude Code skills, explained
- Turn repeated prompts into skills
- Skill descriptions that trigger
FAQ
When does a skill need supporting files instead of one SKILL.md? When part of the content is only needed for some runs — a long checklist, examples, a variant’s rules. Move that part behind a named pointer in SKILL.md so it loads on demand instead of taxing every trigger.
Why bundle scripts inside a skill? For steps that must be identical every time, like validation or conversion. A bundled script replaces an improvised shell command with one tested procedure, and its exit code tells the agent plainly whether the step passed. The code never enters context — only the output does.
How long can a skill description be?
The specification caps it at 1,024 characters, and it must say what the skill does and when to use it. In Claude Code’s listing, the description plus any when_to_use text is truncated at 1,536 characters, so put the main use case first.
How do I test whether my skill triggers correctly? Write prompts that should trigger it and near-miss prompts that should not, run them in fresh sessions, and fix the description for misses — triggering is decided by the description, not the body.
Can a skill run in its own context window?
Yes. Set context: fork in the frontmatter and the skill runs in a subagent, keeping its work out of your main session; the agent field picks which subagent type runs it. That suits skills that gather a lot of material to produce a short result.
Category: Claude Code & Context Engineering · Tags: #claude-code #skills #skill-md #ai-coding #content
Next step: this article is part of Claude Code guides, which covers the full topic from first setup to advanced use.