Catching spec-to-docs drift in CI
Developer documentation drifts from the platform it describes in a predictable way: engineering changes the spec, the reference regenerates, and the guides that mention the old field, the old enum value, or the old path keep saying what they said. Nobody notices until a customer or a support ticket does. At Nium I was the only writer for a platform with 159 operations and about 300 articles, which made manual review a losing race. So I built the check.
What it does
The docs drift script is a Python workflow that reads the OpenAPI spec and the Markdown source of every guide, then reports where they disagree. It looks for three kinds of drift:
| Kind | Example | Why it matters |
|---|---|---|
| Stale references | A guide names POST /payout/bulk; the spec has no such operation | A developer or an agent integrates against something that does not exist |
| Missing coverage | An operation in the spec that no guide mentions | The reference says it exists; nothing says when to use it |
| Source-content gaps | A field, enum value, or status the spec defines that the guides describe differently or not at all | The guide and the reference tell two stories |
It outputs a report as JSON for the pipeline and as a spreadsheet for leadership, with one row per finding: file, line, what the guide says, what the spec says.
First run
The first run against Nium's docs produced 500+ potential inconsistencies across roughly 300 articles. "Potential" is doing work in that sentence: some were true drift, some were guides describing behavior the spec left implicit, and some were false positives from paths written in prose. The point of the first run was the triage, which gave me a prioritized backlog I could work through in Jira alongside engineering sprints instead of a vague sense that the docs were behind.
Running it every sprint
The check that matters is not the one you run once. I added a CircleCI job that pulls engineering's current OpenAPI specs, diffs them against the docs, and opens a pull request with the differences for review. That runs on a schedule matched to the sprint, so a breaking change in the spec shows up as a review item before the release goes out, not after a customer finds it.
The job is deliberately boring: it does not try to fix anything. It produces a diff a writer can read in ten minutes and decide on. That is the right division of labor between a script and a person.
What it changed
- Breaking changes stopped reaching customers through the docs first.
- Engineering review of docs changes got shorter, because the PR already listed what had moved in the spec.
- The script became the evidence behind the agent test: the stale references it flags are exactly the places an agent would integrate against a request that does not exist.
Running it yourself
The script is on GitHub and runs against any OpenAPI 3 spec and a folder of Markdown. See the project page for setup. It takes a spec path and a docs path, and writes the report next to them.