Chapter 10 · Testing & Evals¶
A skill is software with a probabilistic component. That doesn't mean you can't test it — it means you test it in layers, reserving judgment-based checks for the parts that are actually judgment.
┌─────────────────────────────┐
│ 3 · Behavioral evals │ whole-skill quality on golden tasks
│ (model-dependent) │ rubrics, LLM-as-judge
├─────────────────────────────┤
│ 2 · Trigger evals │ does the right skill fire?
│ (mostly deterministic) │ prompt → expect/not-expect
├─────────────────────────────┤
│ 1 · Script unit tests │ the deterministic core
│ (fully deterministic) │ unittest, CI, both OSes
└─────────────────────────────┘
Layer 1 · Unit tests for scripts¶
Everything from chapter 6 — pure functions, exit codes, determinism — exists so you can do this. Keep tests inside the skill folder so they travel with it:
changelog-forge/
├── SKILL.md
├── scripts/generate_changelog.py
└── tests/test_generate_changelog.py
Use unittest (stdlib — no dependencies, runs anywhere Python runs) and
import the script as a module:
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
import generate_changelog as gc
class CategorizeTest(unittest.TestCase):
def test_feat_goes_to_added(self):
self.assertEqual(gc.category("feat(api): add endpoint"), "Added")
def test_fix_goes_to_fixed(self):
self.assertEqual(gc.category("fix: correct date parsing"), "Fixed")
def test_breaking_override(self):
self.assertEqual(gc.category("feat!: drop v1 API"), "Breaking")
class RenderTest(unittest.TestCase):
def test_empty_sections_are_omitted(self):
block = gc.render_block({"Added": ["- abc1234 something"], "Fixed": []},
version="1.4.0", date="2026-08-30")
self.assertIn("### Added", block)
self.assertNotIn("### Fixed", block)
Run them locally and in CI. One caveat worth knowing: skill folders use
hyphenated names (changelog-forge), which can't be Python packages, so
python -m unittest discover can't crawl them — run each test file directly
instead (each ends with unittest.main()):
python examples/changelog-forge/tests/test_generate_changelog.py
python examples/commit-crafter/tests/test_check_message.py
python examples/lessons-keeper/tests/test_lessons.py
This repo does exactly this
The examples/
skills' tests run on Ubuntu and Windows in this repository's CI —
the cheapest cross-platform guarantee you can buy for a skill script.
Layer 2 · Trigger evals¶
The most common failure isn't bad instructions — it's the skill not firing, or firing on unrelated tasks. Trigger evals are a table of prompts with expected outcomes:
# evals/cases.yaml
skill: commit-crafter
should_trigger:
- "commit this please"
- "write a commit message for the staged files"
- "my last commit message is terrible, improve it"
- "squash these changes into a feat commit"
should_not_trigger:
- "what files changed in this diff?"
- "create a branch for the release"
- "how do I undo a commit?"
Run them by hand while iterating (fresh session, one prompt, watch what happens), or automate them if your tooling exposes a scripted interface to the agent. Track the misfire direction: under-triggering → add the prompt's vocabulary to the description; over-triggering → add negative triggers and narrow the claim.
Layer 3 · Behavioral evals¶
Does the skill produce good work? Define golden tasks — realistic, concrete inputs with a fixed environment (a fixture repo, a sample diff) — and score the output on a rubric.
Deterministic assertions first¶
Much of "quality" is mechanical, so check it with code before any judgment:
- the changelog entry covers every commit since the last tag (parse and compare),
- no
{{placeholders}}remain (grep), - the commit subject passes
check_message.pywith exit 0, - the generated config parses (
json.load,yaml.safe_load).
Then a rubric, scored by a judge¶
For the genuinely judgment-y parts, write a rubric and let a strong model score outputs (this repo's own eval style — "LLM-as-judge" — is standard practice for exactly this):
Rubric — changelog entry quality (score 1–5 each):
1. Accuracy — every user-facing change appears; nothing invented.
2. Readability — a non-author of the change understands each entry
without opening the diff.
3. Noise — chores, release bumps, and CI churn are absent.
4. Tone — consistent voice; commit-speak translated to user-speak.
Pass bar: no dimension below 3, weighted average ≥ 4.
Judge sampled runs, not every run — this layer is for development-time regressions and model-upgrade checks, not per-commit CI.
CI for skills¶
A minimal, high-value GitHub Actions setup — exactly what this repo runs:
# .github/workflows/ci.yml (essentials)
jobs:
test-example-skills:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: "3.12" }
- run: |
for file in examples/*/tests/test_*.py; do
python "$file"
done
Add structural validation to CI too: skills-ref validate on each skill
folder (chapter 2), plus a five-line
linter for your own invariants (description under 1024 chars, body under 500
lines, no README.md inside the skill).
The iterate loop¶
Evals feed the authoring loop from the quickstart, made systematic:
- Draft the skill.
- Run 2–3 realistic prompts (the trigger eval set, at minimum).
- Read outputs critically — both the result and the trace. Busywork (re-reading files, going in circles) means the skill is over-prescribing or unclear; that's a signal to cut, not to add rules.
- Improve, in order of preference: reframe the goal → show an example → move repeated work into a script. Fiddly overfit rules and oppressive MUSTs make skills worse over time.
- Re-run the same prompts. Stop when improvements stop landing.
Metrics worth tracking¶
| Metric | Signals |
|---|---|
| Trigger rate on eval set | Description quality; regression after edits |
| Tokens to complete a golden task | Over-prescription; bloated body |
| Steps/tool-calls to complete | Workflow clarity; missing scripts |
| Rubric score drift | Model upgrade damage; skill rot |
The skill review checklist¶
Run this before calling any skill done:
- [ ] Description passes the trigger eval set (fire and not-fire cases).
- [ ] Body under 500 lines; heavy content in
references/with read conditions. - [ ] Every reference linked one level deep, with when to read stated.
- [ ] Deterministic logic lives in scripts with unit tests in CI.
- [ ] Fragile steps have feedback loops (validate → fix → re-run).
- [ ] Boundaries stated: what the skill must never do.
- [ ] Frontmatter validates (
skills-ref validate) andmetadata.versionis set.
Chapter 11 · Packaging & Publishing — from a folder on your disk to a skill anyone can install.