Chapter 4 — The Skill File
Write skill metadata, bounded instructions and explicit behavior for missing or invalid inputs.
Felix Reyes · The Skills Pack · First edition, 2026 · CC BY 4.0 · Router
Step 4 of the method, Write the skill, turns the sort sheet of Chapter 3 into files. This chapter writes the one file every skill must have, SKILL.md, and Chapter 5 the folders beside it. The judgment rows of the sort sheet become the skill file’s instructions, and most of them end up in its output contract. The compute rows become a script that a step runs.
The chapter works on a first draft of the budget-vs-actual skill, a stage that contains only a skill file, and compares each part of it with the leaf that ships in the Variance and Bridge pack.
Anatomy
A skill is a folder containing a file named SKILL.md. Any other file or folder in it is optional. The file has two parts. It opens with frontmatter, a block of YAML between two lines of three hyphens. The rest is the instructions, written in Markdown. The specification calls this part the body. Appendix F is a primer on both.
A host does not read every skill file in full. The specification describes three levels. At startup the host loads the name and description of every installed skill, about 100 tokens each. When a skill triggers, the host loads all of its instructions. Files in the skill’s folder are loaded only when required, and references should sit one level deep from SKILL.md. This is progressive disclosure, and Figure 4.1 draws its three levels.
Figure — text equivalent.
A SKILL.md begins with YAML name and description between --- delimiters. This metadata is read at startup (about 100 tokens in the figure). The body contains the skill heading, numbered steps and output contract; it is read when the skill triggers and should stay under 500 lines. scripts/, references/ and assets/ are read or run on demand, one level deep.
A skill: the two parts of its skill file, the folders beside it, and when a host reads each.
The name and description cost tokens at every startup for every installed skill, used or not, so they contain only what a host needs to choose a skill. The instructions contain what the model needs to act, and a table it needs once in a while goes in a reference (Chapter 5).
The first draft of the budget-vs-actual skill:
File: examples/ch04/budget-vs-actual-1/SKILL.md (lines 1–33).
---
name: budget-vs-actual-1
description: Compares actual to budget by P&L line for a month and year to date, with favourable and unfavourable variances, and writes the variance commentary. Use when asked for budget vs actual, BvA, actual versus plan, a P&L variance analysis, why we missed or beat budget, or commentary on the month or the year to date. Needs a P&L CSV with period, line item, category, actual and budget.
---
# Budget vs actual
Produces two files in an `output/` folder in the current working
directory: the script's figures (`output/bva.json`) and a variance
commentary note (`output/bva-note.md`).
## Steps
1. Find the P&L CSV the user named. Open only its header row.
2. Check that the header has the columns `period`, `line_item`,
`category`, `actual` and `budget`. If any are missing, ask the user
for a file that has them, and wait for the answer.
3. Take the period from the request, written YYYY-MM. If the request
names none, use the last period in the file.
4. Run the script. `<skill root>` is the folder that holds this file:
python3 <skill root>/scripts/bva.py \
--input <the CSV> --output output/bva.json [--period YYYY-MM]
5. If the script fails, show its error and stop. Never compute a figure
yourself.
6. Read `output/bva.json`. Use only the strings under `display`.
7. Write `output/bva-note.md` in five parts:
- A headline on year-to-date revenue and operating income against budget.
- A table of the year-to-date results.
- A sentence on the month.
- The lines that drove the variance.
- Data notes that name the input file.Its name ends in the stage number. The leaf in the pack is named budget-vs-actual. The draft already follows the sort: steps 4 and 6 send every figure to a script, step 5 stops when the script fails, and step 7 leaves the writing to the model. Step 7 is loose: it lists five parts of the note and fixes none of their headings, rows or counts.
The script in step 4 does not exist yet, and the draft validates anyway:
File: examples/ch04/outputs/validate-stage.txt (lines 1–2).
$ python3 tools/validate_pack.py --auto examples/ch04/budget-vs-actual-1
examples/ch04/budget-vs-actual-1: ok (split, 0/20 files, 0 bytes below the root)
The validator checked the frontmatter’s form, the name, the description’s length and every backticked path. 0/20 files is its count against one host’s documented limit (Section 7.6). It skipped the script’s path because the path begins with a placeholder, <skill root> (Appendix A, 3.4.3). Had the draft written it after <pack root>/, the validator would have resolved the path and failed it, since the file does not exist (3.4.4). It cannot tell whether a model follows the steps or whether the note is right. Those take a host and a test case (Chapter 9).
The name
The specification fixes the form of the name field: 1 to 64 characters; lowercase letters, digits and hyphens; no hyphen at the start or the end and never two in a row; and equal to the name of the folder that contains the file. Six candidates for the budget-vs-actual skill, checked against those rules:
budget-vs-actual valid
bva valid
Budget-vs-Actual invalid: capital letters
budget--vs--actual invalid: two hyphens in a row
budget_vs_actual invalid: an underscore
-bva invalid: starts with a hyphen
The second is valid and a poor choice: name a leaf for the deliverable it produces, in words a stranger can read (Appendix A, 3.2.2).
The folder rule is the easiest to break. Here is the stage copied into a folder named with capital letters:
File: examples/ch04/outputs/validate-bad-name.txt (lines 1–6).
$ cp -r examples/ch04/budget-vs-actual-1 /tmp/Budget-vs-Actual-1
$ python3 tools/validate_pack.py --auto /tmp/Budget-vs-Actual-1
/tmp/Budget-vs-Actual-1: FAIL (split, 0/20 files, 0 bytes below the root)
error: SKILL.md: spec 2.3: name 'budget-vs-actual-1' does not match folder 'Budget-vs-Actual-1'
error: spec 2: reference validator, Budget-vs-Actual-1: Validation failed for /tmp/Budget-vs-Actual-1:
- Directory name 'Budget-vs-Actual-1' must match skill name 'budget-vs-actual-1'
The book’s validator, tools/validate_pack.py, labels each rule it checks with its number in the pack standard, here 2.3 (Appendix A). The two lines after it come from the specification’s reference validator, which the book’s validator also runs when it is installed. When the name and the folder differ, rename the folder and keep the name, because the router’s paths and the pack’s test cases use the name.
Exercise 4-1. Copy the stage into six scratch folders, one named for each candidate above, and set name on line 2 to the folder’s name. Run the validator on each. Which pass? For each one that fails, copy the error line and name the rule of the specification it checks.
The description is a routing contract
The description field says what the skill does and when to use it, in 1 to 1,024 characters. When a request arrives, the name and the description are all a host has read of a skill (Section 4.1), so a description that does not fit the request leaves the steps unread.
The book calls the description a routing contract. It tells the host which requests the skill accepts, and a good one says four things:
the deliverable, so a reader knows what comes back;
the requests that should trigger it, in the words people use;
what it is not for, where a neighbouring skill could be taken for it;
the input it needs.
A description that says none of the four looks like this:
---
name: budget-vs-actual
description: Helps with variance analysis.
---It passes the validator and, read as a contract, accepts every request that mentions a variance, including the trial-balance flux at month-end.
The draft’s description is identical to the shipping leaf’s. Its first sentence says what comes back, its second lists the requests in the words a finance team uses, including the abbreviation BvA, and its third says what input it needs. It has no exclusion, because in the bundle shape the exclusions live in the router.
The router’s description, lines 1 to 3 of the pack’s root SKILL.md:
File: packs/variance-bridge/SKILL.md (lines 1–3).
---
name: variance-bridge
description: Builds revenue bridges, budget-vs-actual commentary, price-volume-mix analyses and forecast-accuracy reviews for finance reviews. Use when asked for a revenue bridge or PY-to-CY walk, why revenue changed, budget vs actual or variance commentary, price versus volume versus mix, or how accurate the forecasts were. Not for monthly reporting packs, account reconciliations or forward forecasts.Its third sentence says what the pack is not for, the jobs of the other three packs (Chapter 11), so a host with all four installed can tell which requests belong elsewhere.
A leaf’s description has to work without the router, because the split shape of Chapter 7 installs each leaf alone and the leaf’s description is then the one a request has to fit (Appendix A, 4.5). Exercise 4-3 gives the budget-vs-actual leaf an exclusion.
The house voice is a house skill (Chapter 8), and its description does the opposite job. Nobody asks a host for it. The routing table lists it, and the leaves read it from there:
File: packs/variance-bridge/_shared/executive-voice/SKILL.md (lines 1–4).
---
name: executive-voice
description: House voice for every written deliverable. Read by pack skills when writing a note, memo, summary or commentary; not triggered on its own.
---It accepts no request. The person who approves a pack reads its scope in these descriptions.
Exercise 4-2. Copy the stage to a scratch folder, replace its description with one word, and validate the copy. It passes. List what the validator cannot tell you about a description, and for each item say what would test it: a host run, a test case, or a reviewer.
Exercise 4-3. One team asks for “the flux” and means the P&L against budget for the month. The close team asks for “the flux” and means balance movements in the trial balance. Rewrite the budget-vs-actual description so that “flux” brings in the first request, and so that the trial-balance flux is named as not for this skill. Keep it under 1,024 characters. Compare your version with the shipping leaf’s description and the router’s, and say which file the exclusion belongs in for each shape.
Optional fields
Besides the two required fields, the specification defines four optional ones: license, compatibility, metadata and allowed-tools. The book’s packs use the first three, and in the Variance and Bridge pack only the router has them.
Here is the rest of the router’s frontmatter:
File: packs/variance-bridge/SKILL.md (lines 4–10).
license: MIT
compatibility: Requires Python 3.9 or later (standard library only) and permission to run scripts. If scripts cannot run, the pack stops and says so; it never computes figures itself.
metadata:
pack-version: "2.0.0"
pack-standard: "skills-pack/1.0"
house: "interstationary/2.0.0"
---license states the terms of distribution. The router’s is MIT.
compatibility says what the environment must provide, in 1 to 500 characters. The pack standard fixes what a router’s must say (Appendix A, 3.3.6). The router’s value ends “If scripts cannot run, the pack stops and says so; it never computes figures itself.” That is a promise about failure, placed where the person who installs the pack will read it. A package outside the standard library is named with the command that installs it, as in the deck leaf of Chapter 11: “the python-pptx package (pip install python-pptx)”.
metadata is a map from string keys to string values. The router has three keys (Appendix A, 7.1). pack-version is the pack’s version, MAJOR.MINOR.PATCH, the number that change control works from (Chapter 10). pack-standard gives the version of the pack standard the pack follows, and house the release of the house skills it copies (Chapter 8).
All three values are in quotation marks. YAML reads an unquoted 0.1 or 1.0 as a number, and a number is not a string. Here is the stage with an unquoted version added to its frontmatter:
File: examples/ch04/outputs/validate-unquoted-metadata.txt (lines 1–8).
$ cp -r examples/ch04/budget-vs-actual-1 /tmp/budget-vs-actual-1
$ perl -pi -e 'print "metadata:\n pack-version: 0.1\n" if $. == 4' /tmp/budget-vs-actual-1/SKILL.md
$ grep -A1 '^metadata:' /tmp/budget-vs-actual-1/SKILL.md
metadata:
pack-version: 0.1
$ python3 tools/validate_pack.py --auto /tmp/budget-vs-actual-1
/tmp/budget-vs-actual-1: FAIL (split, 0/20 files, 0 bytes below the root)
error: SKILL.md: spec 2.6: metadata must map strings to strings (quote numbers)
The book’s validator rejects the file under rule 2.6. The specification’s reference validator, run on the same copy, accepts it. The specification says string values, and the book’s validator follows the specification. Quote every value.
The fourth field, allowed-tools, lists tools approved in advance. The specification marks it experimental. The book’s packs leave it out, because which tools a model may call is the host’s decision (Chapter 12).
Exercise 4-4. Write a compatibility value for a skill whose script needs a spreadsheet package that is not in the standard library, naming the package and how to install it, and check that it is under 500 characters.
Instructions as steps
The book writes the body of a skill file as numbered steps. A step has a verb, an object, and a way to tell that it is done: “Run the script, skills/budget-vs-actual/scripts/bva.py” points to a file a reader can find, and the script’s exit code says when the step is done. Write the steps for a reader who has never seen the process, because the model is that reader every time the skill triggers.
Section 2.4 read the revenue-bridge leaf’s Steps as a work map. The budget-vs-actual leaf has six steps too, and its first three and its last do the same work in the same order:
File: packs/variance-bridge/skills/budget-vs-actual/SKILL.md (lines 12–26).
## Steps
1. Find the P&L CSV the user named. Open only its header row. It needs
`period` (YYYY-MM), `line_item`, `category` (Revenue, COGS or Opex),
`actual` and `budget`. If any are missing, ask.
2. Run the script, `skills/budget-vs-actual/scripts/bva.py`. As in every
file in this pack, paths are relative to the pack root, the top folder of
the pack, which holds its main SKILL.md:
python3 <pack root>/skills/budget-vs-actual/scripts/bva.py \
--input <the CSV> --output output/bva.json
The month defaults to the last period in the file; the year to date runs
from the first month of that year to the month. If the user names another
month, add `--period YYYY-MM`.File: packs/variance-bridge/skills/budget-vs-actual/SKILL.md (lines 27–35).
3. If the script exits with an error, here or in step 4, show it and stop.
Exit code 3 means the variances do not reconcile; never report its figures.
4. Run it with `--note`; it writes the note, Drivers left as a marked line:
python3 <pack root>/skills/budget-vs-actual/scripts/bva.py --note \
--input output/bva.json --output output/bva-note.md
5. Replace the marked line with the Drivers bullets, to the contract below,
using only `display` in `output/bva.json`. Never edit another section.File: packs/variance-bridge/skills/budget-vs-actual/SKILL.md (lines 36–40).
6. Check the note before you finish. Every figure must be a display string,
character for character, with parentheses exactly where `display` has
them: a negative keeps them in prose too ("a variance of (0.9) pts") and
a positive figure never gets them. Join a percentage to its amount with
"or": "favourable by $38K, or 28.5%".Steps 1 and 3 are gates, the subject of the next section. Step 2 is the compute boundary of Chapter 3 written as an instruction: the script makes every figure. Step 4 runs the same script with --note. From the display strings it writes every section the contract fixes, and it leaves Drivers as one marked line (Section 5.2). Step 5 is where the judgment goes: the model replaces that line with the Drivers bullets, and the output contract bounds them (Chapter 6).
A check step is a loop: check, fix what fails, and finish only when every check passes. Step 6 has the model check its own note against the display block. Keep the step, but the control is elsewhere: the pack’s checks repeat the comparison with a program after the run, and Chapter 10 says what checks a note before it goes out. In the terms of Figure 3.2, steps 2 and 4 leave the model low freedom, step 5 medium freedom at the contract and high freedom in the choices the contract leaves open, and step 6 low freedom again.
The draft had the model find the last month in the file, which is reading data and so compute. In the leaf the script finds it, and the model passes --period only when the user names a month. The draft’s step 7, five loose parts, became a script that writes four of them and a step that writes the fifth to the contract. The placeholder path became a path from the pack root (Chapter 7). The leaf’s output/bva.json is a user-side path, which the validator does not check (Appendix A, 3.4.3).
A step can be hopeful or checkable: a hopeful step states an outcome and hopes the model gets there, and a checkable step states an action whose result a person or a program can see. Here is a hopeful step, which the leaf’s steps 3, 5 and 6 replace:
4. Make sure the variances are correct and explain the big ones.“Make sure the variances are correct” gives the model nothing to do: the script makes them correct and checks that they are before it exits 0. “Explain the big ones” hides two decisions: which lines are big is compute, ranked by the script in display.movers, and what to say about them is judgment, bounded by the contract’s Drivers section.
Exercise 4-5. Rewrite the instructions of Chapter 1’s first stage, examples/ch01/revenue-bridge-1/SKILL.md, as numbered steps in the form of this section, without adding a script. Which step can no program check, and why?
Ask, stop or go on
Steps run in order until something is wrong. What the model does then is the skill file’s control flow, written in plain sentences at the step it guards. Each such point is a gate, and a gate has three outcomes.
The model asks when an input the skill needs is missing and the user can supply it, and waits. It stops when the script failed, an identity did not hold, or a check cannot be made. It then reports what happened and writes no deliverable, because a note with half its sections looks finished and may be sent. Otherwise it goes on.
Some skills need a fourth outcome, go back. In the four packs only the deck leaf has one: the model corrects a rejected slide map and runs the script once more, and a second failure stops the work (Section 11.2). Give every such loop a limit: a loop without one tells a model to keep trying until it gets the answer it wants.
The router’s last section states the gates every leaf shares, three rules the pack standard requires in every router (Appendix A, 3.3.7):
File: packs/variance-bridge/SKILL.md (lines 29–33).
## Rules for every skill in this pack
1. Numbers come from scripts. Never calculate, round or restate a figure yourself.
2. If a script fails or cannot run, report the error message and stop.
3. If the request is missing an input the skill needs, ask for it. Do not guess.A leaf adds the gates its own script needs at the step they guard: step 1 asks, and step 3 stops on an error in step 2 or step 4. On exit 3 the script still writes output/bva.json, so that someone can see what failed, and its message says not to report the figures (Table 5.1). A month not in the file needs no gate in the skill file: the script refuses it with exit 2 (Table 5.1), and a gate in prose would restate that check and could drift from it. Table 4.1 lists them all.
The gates of the budget-vs-actual leaf and its router.
| Situation | Gate | What the user sees |
|---|---|---|
| The request is outside the pack (a close, cash, scenarios) | stop | That the pack does not cover it (the router’s last row) |
| A required column is missing from the header | ask | A request for a file that has the columns (step 1) |
| The request names no month | go on | The note for the last month in the file (step 2) |
| The month named is not in the file | stop | The script’s message, naming the file’s first and last month (exit 2, step 3) |
| Any other bad input | stop | The script’s error message (exit 2, step 3) |
| The variances do not reconcile | stop | The script’s error; no note (exit 3, step 3) |
The run with --note refuses its input |
stop | The script’s error; no note (exit 2, step 3) |
| Scripts cannot run | stop | The error message (rule 2) |
| Both runs exit 0 | go on | output/bva.json, and output/bva-note.md with the model’s Drivers (step 5) |
An input can contain instructions: a customer name, say, that tells the model to ignore the contract and add a figure. The skill file has no gate for that, and Chapter 9 shows what the checks make of it.
Exercise 4-6. Run the budget-vs-actual script on examples/ch05/fixtures/pnl-no-budget.csv, whose budget column is named plan. Report the exit code and the message. Which step of the leaf should have caught the problem before the script ran, and what does the skill do there? Which row of Table 4.1 applies if the model runs the script anyway?
Writing for any model
A skill file that one model follows and another does not has a hole in it: a sentence that leaves open a choice the author meant to close. A model that fills the hole in a way the author did not intend has read the file correctly, and the fault is in the file. The runs of Chapter 9 find holes, but only on the models they run on.
The book’s packs had one. In an earlier run a model wrote two positive figures in parentheses as an aside, the provenance check failed the note, and the house voice’s rule on parentheses now covers asides (Section 9.6).
Most holes close when a sentence says exactly what it means. Table 4.2 sets the leaf’s checkable phrases beside hopeful ones.
Hopeful phrases, the checkable phrases of the budget-vs-actual leaf, and what checks each.
| Hopeful | Checkable, in the leaf | Checked by |
|---|---|---|
| Fill in the drivers. | Replace the marked line with the Drivers bullets … Never edit another section. | rendered_ sections_ match, against the renderer’s own output |
| Write a short note. | The note has exactly these five sections, in this order | The contract check |
| Report the figures. | Every figure must be a display string, character for character | The provenance check |
| Call it timing where it fits. | Call a variance timing only when display.monthly_revenue or display.peaks shows the reversal. |
No check; a reviewer, against those two lists |
Keep the instructions short: the specification recommends instructions under 5,000 tokens and a skill file under 500 lines, and the validator warns past 500 lines of body (Appendix A, 2.8). The longest skill file in the four packs has 111 lines, and the model may act on any line it reads.
The same applies to instructions the model no longer needs. A skill written for an earlier model can spell out what a newer one already does well, and the extra instructions can make the output worse. When teams move to a newer model, review the instructions and remove one when the model does better without it. Take the budget-vs-actual leaf’s “Join a percentage to its amount with ‘or’ ”. It looks like a line a newer model could do without. No check looks for the word, but a note that writes “$38K (28.5%)” instead puts a positive figure in parentheses, which the provenance check fails. The test cases decide: remove the line in a copy, and it goes when the cases pass without it on every model the teams use. The checks stay when an instruction goes. An instruction asks the model to keep a rule, and a check, where one exists, shows whether the model kept it. Where none exists, the reviewer looks for the rule in the note.
Exercise 4-7. Find three phrases in the revenue-bridge leaf that make a step checkable. For each, name the check in the pack’s tests/checks.py that judges it.