Skills With Scripts and Reference Files: Progressive Disclosure Done Right
24 October 2026 · Updated 28 November 2026 · 12 min read · by Yang Kai
A SKILL.md is the entry point, not the whole skill: how to structure bundled scripts, templates and reference files so the agent loads detail only when the job needs it — the folder layout, what goes where, and the failure modes of dumping everything into one file.
Template inside: Skill folder layout template with a worked example: a deploy skill split into SKILL.md, a script, and two reference files
Contents
- The short version: three levels, three prices
- The folder layout
- What goes where — the test
- Scripts: executed, not loaded — and held to a standard
- Reference files: pointers, not copies
- The worked example: one deploy check, two very different bills
- Failure modes of the one giant file
- When a skill is too small for folders
- Sizing rules of thumb
- The verdict
- How we researched this
A skill that needs more than a page of instructions should not be a longer page — it should be a folder. Every line you add to SKILL.md rides into context on every run that triggers the skill, including the runs that never touch the edge case the line describes. The rollback procedure you documented once gets paid for, in tokens and in attention, on the nineteen runs that pass cleanly.
The fix is the format’s own design: progressive disclosure. SKILL.md stays short — the trigger, the procedure, pointers to bundled files — while the script that does the mechanical work, the template that defines the output, and the reference material consulted only for edge cases live beside it and load on demand.
This guide walks the three loading levels and what each one costs, the folder layout that follows from them, the test for deciding what goes where, and the sizing rules that tell you when a skill is too small — or too big — for folders. It is based on Anthropic’s official Agent Skills documentation and the open specification, checked in November 2026.
The short version: three levels, three prices
| Level | What loads | When | Cost |
|---|---|---|---|
| 1. Metadata | The skill’s name and description |
At startup, for every installed skill | ~100 tokens per skill |
| 2. Instructions | The SKILL.md body | When a task matches the description | Recommended under 5,000 tokens |
| 3. Resources | Files in scripts/, references/, assets/ |
Only when the body directs the agent to them | Nothing until used |
Everything in this article is a consequence of that table. Level 1 is why descriptions carry the routing decision, covered in the description guide. Level 2 is why SKILL.md holds decisions, not documentation. Level 3 is where documentation, templates and code belong — present in the folder, absent from context until the run actually needs them.
One level-3 detail matters more than the rest: scripts are executed, not read. When the agent runs a bundled script, the script’s code never enters context — only its output does. A 200-line verification script costs a few lines of output tokens. The same logic written as instructions costs the full text, every run, plus the drift that comes from an agent re-interpreting prose instead of running code.
The folder layout
deploy-check/
├── SKILL.md # trigger + procedure + pointers (keep under ~500 lines)
├── scripts/
│ └── verify.sh # the mechanical check, run not read
├── assets/
│ └── report.md # the output shape, copied not paraphrased
└── references/
├── rollback.md # read only when verification fails
└── env-matrix.md # read only for the environment in question
Each layer has a rule. SKILL.md holds decisions: when to run what, in what order, what to do with results. Scripts hold mechanics that must be identical every run — a script is read once by its author and executed forever; instructions re-interpreted by an agent each time will drift, a script cannot. Assets hold output shapes and files the skill produces work from, because “format it like the example” beats three paragraphs describing a format. References hold the long tail: the provider-specific quirk, the rollback procedure, the table consulted twice a year. Reference files are where detail goes to be available without being loaded.
Keep references one level deep: SKILL.md links directly to each bundled file. Do not chain — a reference that points to a second reference that points to the actual answer is a structure the agent may only partially follow. The specification’s guidance is flat for a reason.
What goes where — the test
For each piece of content in a growing skill, ask: is this needed on every run, or only on some?
- Every run, and it is a decision → SKILL.md.
- Every run, and it is mechanics → a script, called from SKILL.md with its expected output described.
- Some runs → a reference file, with SKILL.md naming the condition that triggers reading it (“if verification fails, read references/rollback.md before acting”).
- Never actually used in three months → delete it. Bundled files are not free just because they load late; they are maintained, audited and shipped with every copy of the skill.
The trigger condition is the part people skip. A reference file that SKILL.md merely lists (“see also rollback.md”) gets read speculatively or not at all. A reference tied to a condition (“read this when the verify script exits 2”) is loaded exactly when it earns its tokens.
Scripts: executed, not loaded — and held to a standard
Because a script’s code stays out of context, the temptation is to let scripts grow sloppy. Resist it, for three reasons.
First, a bundled script runs with your permissions when the agent executes it, so the install audit applies to your own scripts too. Keep them small enough to read at a glance, deterministic (same input, same output, no network calls unless the job is a network job), and free of anything you would not want surfaced in a transcript.
Second, the output is the contract. SKILL.md should state what the script prints and what each exit code means, so the agent interprets results instead of guessing. A script that exits non-zero with a readable message is worth three that print a stack trace — the message is the only part of the script the agent reliably sees.
Third, paths must survive relocation. Reference bundled files relative to the skill’s own directory — Claude Code exposes this as ${CLAUDE_SKILL_DIR} — rather than assuming the session started in a particular folder. A skill that breaks when invoked from a subdirectory is a skill that only works in the session where you wrote it.
Reference files: pointers, not copies
Reference files have one structural job: hold detail the agent needs conditionally. Two habits keep them honest.
Name the file for the question it answers. rollback.md, env-matrix.md, pricing-exceptions.md — the agent chooses files by name from SKILL.md’s pointers, so the name is part of the routing. A file called misc.md will be read at the wrong times or never.
Link out instead of copying in, when the source lives elsewhere. If the detail already exists in project documentation, SKILL.md can point at that document’s path instead of bundling a copy. Copies drift; links do not. Bundle a copy only when the skill must travel — shared across projects or machines where the source document does not exist. That portability question is the same one the sharing guide answers for whole skills.
The worked example: one deploy check, two very different bills
The folder above runs a deployment verification. On a passing run, the agent loads the SKILL.md body, runs verify.sh, and formats the result from the report template. The rollback reference — say 400 lines — is never opened.
On the one run in twenty that fails, the agent reads the exit code, follows the pointer, and loads rollback.md in full. The detail is completely present on the only run that needs it.
Now compare the single-file version, where those 400 lines sit inside SKILL.md. Every run pays for them: in raw tokens, and in the subtler currency the context budget audit tracks — attention. Long instruction files get skimmed, and the sections skipped are random. The happy path and the disaster path should not cost the same; progressive disclosure is how you arrange that they don’t.
Failure modes of the one giant file
Dumping everything into SKILL.md fails in three recognisable ways.
The skim. Past a few hundred lines, neither agents nor humans read linearly. The paragraph that mattered — the one exception to the procedure — sits in the middle of the file and gets weighted like the filler around it. Splitting by condition is how you guarantee the exception is read on the runs where it applies: it arrives as its own file, at the moment it becomes relevant.
The stale layer. A single file mixes facts with different shelf lives: the procedure (stable), the provider quirks (change quarterly), the price table (changes whenever it wants). Every edit touches the whole document, so small updates get postponed, and the file quietly mixes current instructions with last year’s. Separate files let each layer be updated — and dated — at its own rate.
The speculative read. Agents sometimes open bundled files “just in case” when pointers are vague. In a one-file skill the equivalent failure is worse: everything is already loaded, so every run reasons over material meant for other runs, and occasionally applies it. Conditional files with named triggers are a stronger boundary than a heading that says “only if needed” inside a document the agent has already read in full.
When a skill is too small for folders
Most skills are. A 40-line procedure with no scripts and no references is complete as a single SKILL.md — the folder structure is a response to size and branching, not a ritual. Split when one of three signals appears:
- The body passes roughly 500 lines, the specification’s recommended ceiling.
- A section is read “only when…” — that condition is a reference file asking to exist.
- You catch yourself describing a format in prose instead of showing one — that is a template asking to exist.
The advanced patterns article covers the complementary techniques — examples, checklists and escalation paths — and the first-skill walkthrough builds the single-file version most skills should start as. If you are converting an existing pasted prompt rather than growing a skill, the conversion method is the right entry point. Structure serves the job; the job is a procedure an agent can run the same way twice.
Sizing rules of thumb
Numbers help when you are deciding whether to split:
- Metadata: name within 64 characters, description within 1,024 characters, per the specification. The description is ~100 tokens of your context budget, spent every session, for every installed skill.
- SKILL.md body: keep it under 5,000 tokens (and under ~500 lines). Past that, the material is telling you it belongs a level down.
- A script longer than ~200 lines is a program, not a skill accessory: it belongs in a repo with its own tests, called by the skill as an external tool.
- A reference file earns its place if it is consulted on at least one run in ten. Below that, it is documentation — put it in the project docs and point from SKILL.md instead of bundling a copy.
- The whole folder should survive the audit test: a stranger reading it top to bottom in ten minutes should be able to say what the skill does, what it runs, and what it reads. Past a ten-minute read, it is a small application, and it should be managed like one.
When in doubt, err toward the single file and let the job argue for structure. A skill that splits too early gains ceremony; a skill that splits too late gains a week of bloated sessions. The signals above — length, conditional sections, described-instead-of-shown formats — are the argument, made by the work itself.
The verdict
Build every skill as one file first. When the body nears its token ceiling, when a section turns conditional, or when you describe a format instead of showing it, move exactly that piece down a level — mechanics into a script, output shapes into assets, the long tail into references with named trigger conditions. The folder, in the end, is a courtesy to the next reader, who is usually your own agent at the start of a session, deciding how much of your procedure it can afford to load. Make that decision easy, and the skill stays cheap on the easy runs and complete on the hard ones. The full picture of how skills load and route is in skills explained; browse the patterns in the skills directory when you want examples.
How we researched this
The loading levels, token figures and frontmatter limits in this article come from Anthropic’s official Agent Skills documentation, its engineering write-up on equipping agents with skills, and the open Agent Skills specification — all checked in November 2026. The folder conventions and sizing rules beyond the documented limits (the 200-line script rule, the one-run-in-ten reference rule) are this site’s editorial guidance, labelled as rules of thumb rather than specification. No hands-on benchmarks are claimed; the deploy-check example is illustrative, not a transcript from a real deployment.
FAQ
Do bundled scripts count against my context window? Not while they sit in the folder, and not when they run — the agent executes the script and only its output enters context. The code itself enters context only if the agent opens the file to read it, which is why SKILL.md should describe the output contract well enough that reading the code is unnecessary.
How big can a skill folder get? Effectively unbounded in total size, because levels 2 and 3 load on demand. The binding limits are the ones that load unconditionally: ~100 tokens of metadata per installed skill at startup, and the SKILL.md body — recommended under 5,000 tokens — on each triggered run. A 5 MB reference archive costs nothing until the run that reads it.
Can reference files point to further files? Technically yes, but keep references one level deep from SKILL.md, as the specification advises. Chained pointers get followed inconsistently, and a file the agent never reaches is worse than a slightly longer SKILL.md. If a reference grows its own long tail, split it into two named files and point to both.
What languages can bundled scripts use? Anything the machine can run — Bash, Python, JavaScript are the common choices. The constraints are practical, not formal: the interpreter must exist where the skill runs, the script must be deterministic, and its output must be small and readable, because the output is all the agent sees.
When should I split a single-file skill? At the signals, not at a schedule: the body approaching 5,000 tokens, a section that applies only on some runs, a format described in prose, or a mechanical sequence you keep watching the agent improvise. Any one of those is the job asking for a folder.
Category: AI Agent Skills · Tags: #skills #skill-md #context-engineering
Next step: this article is part of AI Skills, which covers the full topic from first setup to advanced use.