Documentation as Code: Versioning and Testing Skills

Last Tuesday someone renamed a parameter on a tool. The change was reviewed, the tests passed and it shipped. The skill that tells the agent how to call that tool still uses the old name, and nothing in the build noticed. Now the agent makes confident calls that fail. Documentation that drifts from the code it describes is worse than none, because the reader believes it.

Skills live beside the code

The book's answer is to stop treating skill files as a wiki and manage them like source. They sit in the same repository, in a dedicated directory, with a naming convention (one file per skill, ending in .skill.md). They move through the same branches and the same code review as everything else.

One rule does most of the work: a pull request that changes a tool's schema (L1) or implementation (L4) must also update the skill documents it affects. That puts the documentation edit at the moment when the knowledge is freshest, which is when the person changing the tool is still holding the details in their head. Nobody has to remember to update a document three weeks later.

Making drift visible

A rule that relies on memory will be forgotten, so a validation pipeline backs it up. It checks that every tool named in a skill's steps is a registered tool in L4 or L6, that each parameter matches the tool's schema, that links to other skills point at skills that exist, and that example conversations use only declared parameters. Each finding is reported against a skill file with a section, a message and a severity of error or warning.

The book also links the two sides explicitly. A tool schema can carry a list of related skills, and each skill declares the tools it calls. When a tool's parameters change, the build pipeline can list every skill that needs attention.

The core of such a check is small. This sketch of my own pulls backtick-quoted names out of the Steps section and flags any that the registry does not know:

import re

def phantom_tools(skill_text: str, registry: set[str]) -> list[str]:
    steps = skill_text.split("## Steps")[1].split("## ")[0]
    named = set(re.findall(r"`([a-z][a-z0-9-]*)`", steps))
    return sorted(named - registry)

# phantom_tools(open("renew-loan.skill.md").read(), {"get-loan", "renew-loan"})

The book's reference checker works on the same principle, reading quoted names from both the Steps and Chaining sections, and treats an orphaned reference as a build error.

Three kinds of test

  1. Completeness. A skill with no purpose, no steps or no error handling fails the build. The steps must mention at least one tool, and the error handling must cover at least two failure modes, so a skill cannot pass by gesturing vaguely at problems.
  2. Reference existence. Every named tool must exist. This is the check that would have caught Tuesday's renamed parameter at the pull request, not in production.
  3. Example conversations as lightweight integration tests. A harness pulls the tool calls out of each example and checks their parameters against the tool's schema. It never runs the tools. It only proves that the documented interaction is structurally possible.

There is a generation step too. Skeleton skills can be produced from tool metadata, giving each tool a draft with purpose, parameters and error-handling scaffolding. A domain expert then adds the workflow logic, decision trees and examples. The side effect is useful: no tool can quietly exist without a skill.

What the tests cannot tell you

All of this guards consistency. A skill can pass every check and still give poor advice, such as apologising at the wrong moment or offering a remedy the business dislikes. Automation covers the factual layer, and human review of the pull request covers the judgement. That division is the reason to keep skills in the review flow rather than in a separate documentation tool.

The takeaway

Skills change as often as anything on the server, so they need the safeguards code gets: version control, review, automated validation and tests. Start with the first article on what a skill contains, and see layer-specific testing for the upper layers for where these checks sit in the wider test strategy.

What the book covers

  • The validation pipeline for skill references and its result types
  • Bidirectional links between tool schemas and skill documents
  • Generating skeleton skills from tool metadata
  • Completeness checks, reference checks and example-conversation tests