Skip to content
mentoor

Topic 4 of 5 · 5 min read

Detecting and fixing doc drift

Goal: Find statements in a doc that no longer match the code and verify an agent's drift report against the source.

Doc drift is when a doc says one thing and the code does another, and you find it by comparing specific claims to the code, not by rereading the page. Agents can do the comparing, but their report is only useful if every finding cites a file and line.

Check yourself · 1 of 3

An agent says a README default is wrong. Which detail makes the finding checkable?

Choose one answer

Why it matters

Drift is silent. Nothing fails when a README keeps describing a flag that was removed. Readers find out when a command errors. Over time people stop trusting the docs and ask in chat instead. Regular checks keep that trust.

How to do it

  1. Use mechanical checks first. Link checkers find dead links. Compiling or running every code sample in the docs finds broken examples. A test that runs the quickstart commands finds missing flags. These cost nothing per run.
  2. Then ask an agent for an audit. Give it one doc and the code it describes. Ask for a table: the claim, the doc location, the code that confirms or contradicts it (path:line), and a verdict: matches, differs, or cannot tell.
  3. Demand citations. A finding with no path:line is a guess. Throw it back.
  4. Verify the verdicts yourself. Open the cited lines for every "differs" and sample the "matches". Agents miss drift and also report false drift, for example by reading a test fixture as the default.
  5. Fix at the source of truth. If the code is wrong, fix the code; otherwise fix the doc, in a small pull request.

Before and after

Weak audit: "The README is mostly accurate, but a few options may be outdated."

Fixed audit:

Claim Doc Code Verdict
Default port is 3000 README:14 config.ts:9 sets 8080 Differs
--verbose prints debug logs README:22 cli.ts:41 defines it Matches
Retries are configurable docs/api.md:60 no setting found Cannot tell

The second version can be checked in a minute, and the unknown row is honest.

What goes wrong

  • Uncited findings. "Several defaults are wrong" gives you nothing to fix.
  • False alarms from the wrong file. The agent compares the doc to a test fixture or an old branch.
  • Missed drift. The agent checks the claims it noticed and silently skips others. Ask it to list every claim it checked.
  • Only checking once. Put the mechanical checks in CI so drift is found when it starts.

Examples

Checking one 'differs' finding

The agent reports: "README:14 says the default port is 3000; config.ts:9 sets 8080." You open config.ts and find line 9 sits inside testConfig. The real default at line 31 is 3000. The finding was false, and the README was right. Without the citation you could not have seen that.

A runnable-example check

for f in docs/examples/*.sh; do bash "$f" > /dev/null || echo "FAILED: $f"; done

Run it in CI. A renamed flag now fails the build and not a reader's afternoon.

Key points

  • Doc drift is a mismatch between a doc's claims and the code; find it by checking claims, not by rereading.
  • Run link checks and runnable examples first; they are cheap and need no judgement.
  • Ask the agent for a table of claim, doc location, code citation as path:line, and verdict.
  • Open the cited lines yourself; agents report false drift and miss real drift.
  • Move mechanical checks into CI so drift is caught when it is introduced.

Common mistakes

  • Accepting an agent audit that gives opinions without a file and line for each finding.
  • Trusting a clean report as proof; the agent may have skipped claims, so ask which claims it checked.
  • Fixing the doc when the code is the real bug, or the reverse, without asking which is intended.
  • Running a drift check once at release time instead of on every change.

Check yourself · 2 of 3

Which check finds a documented shell command that no longer works, with no AI?

Choose one answer

Check yourself · 3 of 3

An agent audit returns 'matches' for every claim in a doc. What is a sensible next step?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic