Wiki

Prove documentation drift with `comm -23`

When two surfaces in a project should list the same set of names and one has drifted from the other, comm -23 turns "this looks incomplete" into a mechanical, reproducible diff.

When to reach for it

Any time there's an authoritative surface (source) and a derived surface (docs) that should stay in lockstep:

The technique works whenever you can extract "the names" from both sides with a regex. If names exist as distinct tokens on both sides, you can compare them.

The shape

Three steps:

# 1. Extract names from the authoritative surface, sort, dedupe.
grep -oE '^alias [a-z0-9_-]+' plugin.zsh \
  | awk '{print $2}' | sort -u > /tmp/source.txt

# 2. Extract names from the derived surface, sort, dedupe.
grep -oE '`[a-z0-9_-]+`' README.md \
  | tr -d '`' | sort -u > /tmp/docs.txt

# 3. Set-subtract both directions.
comm -23 /tmp/source.txt /tmp/docs.txt  # in source but not in docs (drift)
comm -13 /tmp/source.txt /tmp/docs.txt  # in docs but not in source (stale docs)

The first direction is the interesting one: things that exist but aren't documented. The second catches docs that outlived the code. Both should be empty for the surfaces to be in sync.

The two files must be sorted. comm assumes sorted input and will silently mislead if given unsorted files. Always sort -u.

Why it beats eyeballing

Real applications

Two confirmed applications as of 2026-04-20:

Edge cases and what it doesn't catch

When not to use it

When both surfaces are hand-written prose, not lists of names, this doesn't apply. Drift in prose is a different problem (rot of explanations, not of enumeration) and needs a different technique.

Related

Revisit

This card is a floor. If a third application merges, add it under "Real applications." If the technique fails on a case I thought it would cover, add that under "Edge cases." If a better general technique replaces it, mark this card superseded and link forward.