What Is Documentation Drift, and How Do You Catch It?
Every codebase has documentation that was true once. A function gained a parameter, a default changed, an endpoint started returning a different shape, and the page that describes it stayed exactly as it was. Nobody decided to let the docs go wrong. They simply stopped being looked after the moment the code moved on.
That gap between what the documentation says and what the code does is documentation drift. It is the most common reason people stop trusting docs, and once a team stops trusting its docs, it stops reading them, which removes the last reason anyone had to keep them current.
This guide covers why drift happens, why it is worse than missing documentation, how to measure it instead of guessing, and how to stop it from reaching your main branch.
Why documentation drifts
Drift is not a discipline problem. It is a structural one, and it has three causes that show up in almost every team.
Docs live somewhere the change does not go. A wiki page, a separate docs repository or a README three folders up is not part of the diff a developer is looking at when they change a function. If updating the docs means leaving the change to go and find them, they will usually not be updated.
Nothing fails when docs are wrong. A broken test stops a merge. A type error stops a build. A stale paragraph stops nothing. Work that has no consequence when it is skipped gets skipped under deadline pressure, every time.
Review cannot see what is missing. A reviewer reads the lines that changed. They cannot see the doc that should have changed and did not, because it is not in the pull request at all.
Any fix that depends on people remembering will hold for a sprint or two and then fade. The fixes that last change the structure: they put the docs where the change is, and they make staleness visible.
Why stale docs are worse than no docs
Missing documentation is an honest gap. A developer who finds nothing knows to read the code.
Stale documentation is confident and wrong. It sends a new teammate down the wrong path, it gets pasted into a support answer, and it gets fed to the AI coding assistant that is now reading your repository alongside you. An outdated description of a function is a bug report waiting to happen, written in the one place people go to avoid reading the source.
That is why the goal is not "more documentation". It is documentation you can tell is current.
How to measure drift instead of guessing
You cannot manage what you cannot see, and "these docs feel old" is not a measurement. The most useful definition of drift is concrete:
For each documented file, how many commits have touched the source since its documentation was last generated?
That number has three properties that make it practical:
- It is computed from git history, which every repository already has. Nothing has to be tagged or maintained by hand.
- It is per file, so it points at exactly which docs to look at instead of declaring the whole docs folder suspect.
- It is honest about uncertainty. If the history is not available, the right answer is "unknown", not "up to date".
To compute it, each generated doc records the commit it was written from. Later, you ask git how many commits have modified the source file since that commit. Zero means the doc describes the code as it is. Three means three changes have landed that the doc has never seen.
Three levels of response
Once drift is a number, you can decide what it is allowed to do. Most teams move through three levels.
1. Make it visible
Show the drift count for every documented file in a place the team already looks. This alone changes behavior: a doc that says "7 commits behind" next to its name gets regenerated far sooner than one that silently aged.
2. Warn in the pull request
When a pull request changes a file whose documentation is already behind, say so in the pull request itself, on the file. The author sees it while the change is fresh, which is the cheapest moment to fix it.
3. Fail the check
For code where wrong documentation has a real cost (a public API, an SDK, anything another team builds on), let a stale doc fail the pull request's check, so it cannot merge until the docs catch up. This is the only level that does not depend on anyone choosing to act.
Not every repository needs level three. A prototype does not. A library other people call almost certainly does.
Where a drift check can and cannot run
It is worth being precise about what each place can enforce.
- A CI check runs after code is pushed. It can fail a pull request's status and, with branch protection that requires that check, stop a merge. It cannot stop the push itself, because the push has already happened by the time it runs.
- A local git hook runs on the developer's machine before a push leaves it, so it can stop the push. It is a courtesy rather than a control: anyone can skip it with
git push --no-verify, or simply never install it.
The reliable gate is the one in CI. A pre-push hook is useful for catching yourself before the round trip, not as a guarantee.
How Writulos Scribe handles drift
Writulos Scribe was built around this exact definition of drift.
- Every doc the GitHub Action writes is stamped with the commit it was generated from, in an HTML comment at the top of the file that is invisible when the markdown renders.
- On each run, the Action counts the commits that have touched each source file since then. That count is the drift.
- In your dashboard, each documented file shows "Up to date", "N commits ago", or "Unknown". Every plan shows it, Free included.
- On pull requests, a changed file whose docs are behind gets an inline warning annotation naming the file and the number of commits.
- On Pro and Business, with the gate switched on, that warning becomes a failed check, so the pull request cannot merge until the docs are regenerated. Business makes the gate one organisation-wide switch that starts on.
Two details keep it trustworthy. Counting commits needs history, so the workflow checks out with fetch-depth: 0; without it, drift is reported as "Unknown" rather than quietly claimed to be fine. And whether a run may fail is decided by your plan on Writulos's servers, not by the workflow file, so nobody can switch the gate on (or off) for the whole team by editing YAML.
For the local half, Scribe also publishes a small pre-push hook written in plain POSIX shell. It reads only your git history, needs no network and no API key, and stops a push when the docs for a file you changed are behind. Like every hook, it can be skipped with --no-verify, which is why the CI check is the guarantee.
A practical starting point
If you want to start catching drift this week:
- Pick the code where wrong docs cost the most, usually anything other people call.
- Generate a baseline, so every file starts at zero drift.
- Turn on visibility first. Watch the numbers for a couple of weeks and see which files drift fastest.
- Add the pull request warning, so authors see drift on the files they touch.
- Turn on the failing check for the repositories where stale docs are a real risk, and make it a required status check in branch protection.
Drift does not go away because a team tries harder. It goes away when a stale doc stops being invisible and starts being a failed check.
Ready to measure it on your own code? Add the GitHub Action or try Scribe in the browser first, with no account. Want a number before you install anything? The free docs freshness check estimates it for any public repository, and the short version of this guide is on the documentation drift page.