Stamp Docs
Automatically updates version numbers and last-updated dates in Markdown and PowerPoint documents during commit, ensuring they reflect the current content accurately. The skill runs by itself at commit time via a pre-commit hook, and can also be used to check, backfill, or force version bumps on documents.
Editor's Note
To use this skill, ensure the document is staged before committing, as the pre-commit hook applies the stamp based on the staged content. For a major version bump, use the `--major` flag with the document path.
When to Use It
- Check the current state of document versions and dates
- Backfill newly added documents with initial version and date
- Force a major version bump after a rewrite
- Update document versions and dates automatically during commit
- Unwrap hard-wrapped Markdown paragraphs
SKILL.md
SkillsHunter provides this listing for informational purposes only. Review the skill’s source, license, and required permissions before use. You are responsible for deciding whether to install or run it. Terms of Use
stamp-docs
Every in-scope document carries a version and a last-updated date that is visible when it is viewed or printed, and that refreshes itself whenever the document changes.
How it already works without you
The pre-commit hook stamps the documents in the commit in front of it (scripts/docstamp.py --staged, since 18 September 2026 — buses-data OA-397, R4 of the process review), so the committed stamp describes the committed content by construction. You do not need to invoke this skill, re-stamp anything or remember an order of operations: edit, stage, commit, and the stamp in the commit is current. A document edited and not yet committed carries its previous stamp until it is committed, which is what a stamp should mean.
Until that day a Stop hook stamped the working tree after every turn, so a commit made mid-turn carried the new content and the old stamp; the story is in README.md. The hook and its --auto mode are both gone — --auto was deleted from the script on 21 September 2026.
The stamp
Version is major.minor starting at v1.0. An ordinary edit bumps the minor; a rewrite deserves --major. Dates read 27 July 2026.
Markdown — two lines just after the H1. The HTML comment is invisible in every renderer and is the machine anchor; the bold line is what a reader sees.
# Runbook R1 — Create a new area or place map
<!-- docstamp v1.4 | 2026-07-27 | sha=3f9a1c2b -->
**v1.4** · updated 27 July 2026
PowerPoint — a 9pt text box on every slide, shape-named docstamp so a re-run updates it instead of stacking a second one. Position is whichever candidate band is clear on every slide (top-right preferred); colour flips light or dark from the slide's background luminance. The record lives in the file's core properties.
Why a re-run changes nothing
The stamp carries a short hash of the document's own content with the stamp removed — for a deck, all slide text plus every embedded media blob, so a swapped image counts as a change. If the hash is unchanged the file is not rewritten at all, so mtimes never churn and a document re-committed unchanged keeps its version.
Commands
Every command on this page runs from stamp-docs — this skill's own folder in the claude-skills repository, where scripts/ and stamp-policy.json sit beside each other. There are no placeholders except the quoted paths, which are the documents or folders to act on.
python scripts/docstamp.py --check # audit; exits 1 if anything is missing or stale
python scripts/docstamp.py --list # what is in scope
python scripts/docstamp.py --backfill # stamp new documents at v1.0, dated from git
python scripts/docstamp.py --all # hash scan; stamps whatever changed
python scripts/docstamp.py --major "path/to/doc.md" # rewrite: v1.4 -> v2.0
python scripts/docstamp.py --minor "path/to/doc.md" # force a bump
python scripts/docstamp.py --staged # what the pre-commit hook runs: stamp the staged documents into the index; always exits 0
python scripts/docstamp.py --all --all-roots # every root, not just the one you are in
Add --dry-run to any of them. A walk covers only the root containing the working directory and prints which, with the absolute path it will write — standing in a linked worktree of a root, that path is the worktree and not the main checkout (buses-data OA-495, 28 September 2026: until then --all from .claude/worktrees/<name> stamped the main checkout and said only cwd is inside the buses checkout); from stamp-docs, which is in no root, that means every root, and it says so; --root buses|portal|ops names one instead, and --checkout [DIR] points one root at a checkout you name (a worktree, placed through git) and walks only that. None of these is an everyday step any more — the hook stamps every commit, in a worktree or not. --staged takes none of them: its subject is the repository enclosing the working directory, and a repository the policy does not name is a no-op that says so.
Markdown paragraphs
The house rule (~/.claude/CLAUDE.md) is that a newline in Markdown means a semantic break — end of paragraph, next heading, next list item, next table row — and never "the line got long". Hard wrapping is invisible to a reader but corrupts the diff: reflow one sentence and every following line in the paragraph is rewritten, so a one-word change reads as a rewritten section.
scripts/reflow_md.py unwraps prose that broke the rule. It is a manual tool — no hook runs it, and it has no default scope, so it only looks at the paths you name. Run it from stamp-docs, and <path> is the document or folder to unwrap.
python scripts/reflow_md.py "<path>" # dry run, the default
python scripts/reflow_md.py --apply "<path>" # rewrite in place
python scripts/reflow_md.py --check "<path>" # exit 1 if anything would change
Run from any folder; a <path> may be a file or a directory, and directories are walked for *.md. It skips node_modules, .git, .venv, __pycache__, dist and build, and honours the exclusions in stamp-policy.json so generated stage output is left alone — walking the Buses root drops from 141 candidate files to 97 because of that. A file named explicitly is always processed, exclusions or not.
Three guards make it safe over documents you have not read, and all three exist because the tool got it wrong first:
- YAML frontmatter is passed through untouched. An earlier version folded a memory file's
description:line intometadata:, silently corrupting the frontmatter. It was caught by the second guard, on a real file, which is the only reason we know that guard works. - A file is written only if the word sequence is identical before and after, bare
>blockquote markers excepted since folding a quote drops them. If a join would lose or reorder a word the file is left alone and the failure reported, and--checkexits 1. - Table rows are never joined —
NEW_BLOCKmatches a leading|, and a line whose predecessor ends in|is not joinable either. This guard is load-bearing and its absence is invisible: an early pass collapsed the whole "Where everything lives" table in twoBuses\Documentation\READMEs onto one line each, and because the word sequence was preserved the second guard saw nothing wrong. Neither had rendered as a table for weeks, and nobody noticed, because nothing in the workflow opens these files in a renderer. The word-sequence guard checks that no text was lost; only this one checks that no structure was. Repaired 2026-08-21.
Two things it does not do: it will not re-wrap (there is no way back), and it does not know a deliberate short line from a wrapped one below 60 characters — signatures, one-line answers and Hello, all survive because of that floor, but a genuinely short wrapped line would too.
Archived documents are out of scope, as of 17 August 2026 — _archive is in the excludeDirNames of both the Buses and the portal root (the portal gained a docs/_archive on 18 August 2026, and without the exclusion its three superseded docs would be re-stamped forever, a PR each). Neither tool touches superseded plans. Name such a file explicitly if you ever do want it reflowed.
Scope
stamp-policy.json holds it — edit that, not the code. Three roots today: the Buses working folder (.md + .pptx), the community-bus-maps repo (.md), and the local-only ops notes (.md).
Exclusions come in two layers, and the top one is shared (buses-data OA-235, 4 September 2026). baselineExcludeDirNames names the directories that are never a document in ANY repository — .git, node_modules, worktrees, scratch, dist, coverage, build — and every root inherits it; a root’s own excludeDirNames now holds only what is local to it (_latest and open-actions in Buses, data, staged, _archive and CHANGELOG.d in the portal). Before that the three lists were maintained separately and had drifted to sharing only .git: worktrees was in ONE of them, so 60 of the 90 markdown files the portal root walked were inside .claude/worktrees/ — a second and third checkout of the same repository. The measured effect of adding the baseline was 185 in-scope documents down to 155, and all 30 that left were worktree copies, checked one by one rather than assumed.
The cost was never the wasted work — it is that a stamp is an EDIT. Two sessions could not both run --all: on 3 September 2026 each bumped stamps on documents inside the other’s worktree, neither having touched the other’s files, and the standing rule then was re-stamp a document you edited BEFORE you commit it, so a stamp arriving from elsewhere was exactly what got swept into a commit describing something else.
Two kinds of reason live in that baseline and it matters which when adding to it: .git, node_modules, dist, coverage and build are excluded because they are not documents; worktrees and scratch because they are not ours to write to — a worktree is full of real documents and the objection is ownership. A directory excluded for a reason peculiar to one repository stays on that root.
A worktree is placed through git, never by its name. A linked worktree's --git-common-dir is the main checkout's .git, whose parent is what a root names, so docstamp.py --staged in the pre-commit hook stamps a worktree's commit with its root's exclusions whatever the directory is called — and since 21 September 2026 the audit places it the same way, through the same function (root_cfg_for_repo()). --checkout uses that resolution too, and refuses a directory it cannot place, because it writes; the audit, which only reads, audits an unplaced repository with no exclusions and says so on stderr. Both directions are proved in prove_policy.py and prove_staged.py, against a real git worktree add rather than a hand-written .git file, which git rev-parse rejects.
All three tools read the baseline through scripts/policy.py, and that is deliberate. A baseline each of them unioned for itself would be the same write-it-once-per-place fault one level down, with a worse failure mode — two agreeing and the third stamping what the others skip. scripts/prove_policy.py asserts the four resolution rules and then asks all three readers for their resolved exclusions and insists they match, with a control that the comparison can notice a disagreement at all. Run it from stamp-docs; there are no placeholders:
python scripts/prove_policy.py
Never stamp generated output. The stage pipeline already versions its own files by folder name (S4-generate/v1.3_2026-07-19_0517) and stamps its reports in the body; the portal's rendered sheets sit under a byte-identical gate that stamping would break. The policy excludes S[1-6]-*, _latest, node_modules, data/, and the dated _gtfs reports. Adding a root means adding exclusions for whatever it generates.
A generated report can also exclude ITSELF, and since 2026-08-28 that is the preferred way (open action OA-096, now closed). Any markdown file whose first 40 lines contain <!-- generated by is skipped, wherever it lives — generatedMarker in stamp-policy.json. This exists because the path-based rules only ever caught the generated files somebody remembered to name: stand-coverage_2026-08-22.md and frame-coverage_2026-08-23.md churned in every diff for weeks, the hook inserting a stamp and the next run of their generator deleting it, over a version number that described nothing. Naming those two would have fixed those two — nothing about writing a third generator reminds anybody that a policy file in another repository has to learn a new filename. So when you write a script that emits a markdown report, have it print that marker as its second line. The report is then excluded on the day it is written, by the person already thinking about it. It is read from the head only, and only a line that begins with the marker counts (since 2026-09-23, buses-data OA-446). Before that any line in the first 40 that merely CONTAINED it counted, so buses-data's Development Docs/README.md, which quotes the marker in backticks while naming the two reports that carry it, was skipped by --staged as generated while the pre-commit audit, which skips nothing, refused the commit as stale. prove_staged.py case 5b holds it.
Committing a stamped document
Since 18 September 2026 there is nothing to run when you edit a stamped document: the pre-commit hook stamps it as part of the commit (buses-data OA-397). A hand-run walk (--all, --check, --list) covers only the root you are standing in and prints which (buses-data OA-333); --all-roots asks for the estate-wide pass by name.
The stamp can be correct on disk and wrong in git — and the audit that catches it stays
--check audits the working tree. A stamp written after a commit could therefore be right on disk and wrong in HEAD, and anyone reading the file out of the repository — a cold start, a clone, a PR review — would see a stamp that does not describe what they are reading, looking exactly as authoritative as a correct one. Found 2026-08-17: three of the 44 stamped .md in the Buses repo were stale in HEAD, one of them claiming v1.12 · 9 August over a body that had moved on.
Stamping at commit time closes that by construction, and the audit that used to catch it is kept as the control that must never fire: check_committed_stamps.py --staged still runs in the pre-commit hook after the stamper, and the CI step still hashes HEAD's blobs. A green from either now says the mechanism worked; a red says something bypassed it. scripts/prove_staged.py drives the whole thing through real hooks and real commits, and its mutation arm runs the same mid-turn edit through a hook that does not stamp and requires the audit to refuse it.
To audit what is actually committed, hash HEAD's blobs rather than the files on disk:
python scripts/check_committed_stamps.py # every stamped .md in HEAD, per repo
Read it back rather than assuming: on 2026-08-25 the portal briefly went 3 STALE of 29 in main this exact way, and reads 32/32 once the follow-up landed. The checker exits 1 on findings, and it runs in CI: the status job of buses-data's .github/workflows/gates.yml runs it from its checkout of this repository — pinned to the engine commit in engine.lock.json, so a change to this script reaches that job when the pin next moves — over buses-data and community-bus-maps, naming those two roots explicitly. The third policy root, community-bus-maps-ops, is deliberately NOT passed — it is never pushed, a runner has no copy of it, and it holds the estate's one genuinely stale stamp, so judging it from CI would make the step red on day one for a reason nobody could fix. Proven both ways on 2026-08-27: exit 0 on the real corpus (Buses 82/82, portal 32/32 by explicit root), exit 1 on a scratch repository holding one deliberately wrong sha.
The 16 stale portal docs that were never stale
This file previously recorded, as known-outstanding, that "community-bus-maps has 16 of its 31 stamped .md stale in HEAD", and guessed at squash-merges compounding over many PRs. That was a bug in the audit tool, not in the stamps. check_committed_stamps.py decoded HEAD's blobs as utf-8, keeping the BOM; docstamp.py's read_text() strips it before hashing. str.strip() does not treat as whitespace, so the BOM stayed in the hashed body and every BOM-carrying file reported stale. The 16 "stale" files were exactly the repo's 16 BOM'd files; the 15 "correct" were exactly the 15 without.
Fixed 2026-08-18 by decoding utf-8-sig. Proof, on docs/DEPLOY.md at HEAD — which the tool called stale minutes after its stamp was committed in PR #42:
BOM stripped (docstamp) -> 80ce1414 stamp says 80ce1414 correct
BOM kept (old audit) -> c873552a stamp says 80ce1414 "stale"
The lesson is the expensive part: the tool reported a real-looking failure with per-file hashes attached, and the recommended fix was 16 version bumps pushed to a public repo. A red audit is a claim about the tool as much as about the data — reproduce one failing case by hand before acting on a batch.
The audit honours the policy's exclusions, so _archive and other out-of-scope trees are counted (N out of policy scope) rather than judged — provided it can place the repository at a root, which inside a linked worktree it could not until 21 September 2026 (see the last paragraph of this section).
--staged did not honour them until 2026-08-31, and the docstring said it did. The exclusions were applied on the HEAD path and not on the index path, and nothing revealed it for two days because the only way to reach the bug is to EDIT an archived document — archiving has always been a pure git mv, which changes no content, so a stale stamp never arose there. Then a documentation round in buses-data repointed the links inside nine files it was archiving, and the pre-commit hook refused the commit over nine documents this stamper deliberately refuses to stamp. An unsatisfiable refusal is worse than no check: it names a fix that cannot be carried out, and the only way past it is --no-verify, which is a habit that does not come back. Both halves were proved after the fix — an in-scope document with a stale stamp is still refused, and an out-of-policy one is skipped.
And the same bug was one level out, in CI, where the fix above does not reach. gates.yml audits by NAMED path — check_committed_stamps.py "$GITHUB_WORKSPACE/buses-data" … — and a named repo was documented as audited without exclusions, because the policy config travels with the policy ROOTS and a CI checkout is at a path no root has. So the local hook went quiet and CI went red about the same nine files, on the same push. Policy roots now carry checkoutDirNames: the names the same repository goes by when it is checked out elsewhere (buses-data, community-bus-maps). A repo matching nothing is still audited with no exclusions and SAYS so, on stderr, from both the HEAD path and --staged, because a silent filter is the worse of the two failures. Falsified in a throwaway repo with one stale _archive/ file and one stale Documentation/ file: named buses-data it reports 1 STALE and 1 out of policy scope, and renamed to anything else it reports 2 STALE and prints the warning.
And the placement itself was a second copy of the stamper's, which is how a worktree fell through it (21 September 2026). The audit matched a repository by path and then by checkoutDirNames; a linked worktree has neither, so every commit made in one had its staged documents audited with no exclusions and no warning, while the stamper — placing through --git-common-dir — correctly left _archive alone. A merge in a community-bus-maps worktree was refused over docs/_archive/GO-LIVE.md. The audit now asks docstamp.root_cfg_for_repo(), so the two cannot place a tree differently. prove_staged.py case 9 commits a stale-stamped _archive/x.md inside a linked worktree named nothing any list holds, with a stale in-scope control beside it; case 10 requires the no-match warning. Both went red against the old placement before the fix.
Gotchas
- Decks are git-ignored (
*.pptxin the Buses.gitignore), so git is no safety net and a git-status trigger would not see them at all. Copy them somewhere before a first stamp of a new deck, and verify afterwards that slide count, text blocks and media parts are unchanged. - A stamped deck's exported PDF goes stale, and there is no LibreOffice or pandoc on this machine to regenerate it. Re-exporting is manual in PowerPoint.
--backfilldates from git, not today, so a first stamp tells the truth about when the document last actually changed. It only does this for documents with no stamp yet — that restriction was missing until 2026-08-21, and a backfill run for one new README re-dated four documents edited the same morning to the day before, because an already-stamped file only reaches the stamping code when its content just changed and its git date is therefore the previous commit. If you are backfilling in a session where you have also edited stamped documents,--checkafterwards will not catch it (the sha is still correct — only the date is wrong); read the visible dates.- The stamp says a document changed; it cannot say the documents pointing AT it are still true. Found 2026-08-22:
Development Docs/open-actions.mdwas deliberately cut from 400 lines to 81 on 2026-08-20, and five places still sent a reader there for narrative and section headings it no longer carried — three other Development Docs,community-bus-maps/CLAUDE.md, and the project memory index. Every one of those links still resolved, so a link checker would have passed all five; only the content behind them had gone. When you cut content out of a document, grep the doc sets and both memory stores for its filename and for the headings you are removing, and repoint each hit. Where the content went to git history, name the commit SHA rather than "the version before the tidy-up" — open-actions.md now cites546cd62with the exactgit showcommand and the folder to run it from. A link checker over these doc sets now exists — built 2026-08-27, and not here: it isDocumentation/check-doc-links.mjsinbuses-data, run from that repository's root and wired into thedocsjob of itsgates.yml. It covers three of the four classes: a dead path, a dead#anchor, and a§nthe named target does not have — plus a link that climbs OUT of the repository, which resolves on the machine that wrote it and 404s for every other reader. It deliberately does NOT judge a citation by phrase, because there is no syntax to anchor that on; that residue isopen-actionsOA-139, and the mitigation stays the paragraph above this one. Its first run found 79 dead links, 77 of them from a document split made the same morning. - Existing metadata lines such as
**Last reviewed:** … **Against:** 0.8.1mean something different (reviewed against a code version). Leave them; the stamp sits above and both coexist.
View original Markdown
---
name: stamp-docs
description: Keep the bus-system documents (Markdown and PowerPoint) correctly stamped and correctly formatted — a visible version number and last-updated date that refresh themselves, and Markdown paragraphs kept as whole unwrapped lines. Stamping runs by itself at commit time, from each repository's pre-commit hook; invoke this skill to check the current state, backfill newly added documents, force a major-version bump after a rewrite, change which documents are in scope, or unwrap hard-wrapped Markdown. Use when asked to check/fix document versions or dates, "what version is this doc", "did the stamp update", "add the new folder to stamping", "bump that doc to v2", or to fix/unwrap/reflow hard-wrapped paragraphs in .md files.
---
# stamp-docs
Every in-scope document carries a version and a last-updated date that is visible when it is viewed or printed, and that refreshes itself whenever the document changes.
## How it already works without you
**The pre-commit hook stamps the documents in the commit in front of it** (`scripts/docstamp.py --staged`, since 18 September 2026 — buses-data OA-397, R4 of the process review), so the committed stamp describes the committed content by construction. **You do not need to invoke this skill, re-stamp anything or remember an order of operations**: edit, stage, commit, and the stamp in the commit is current. A document edited and not yet committed carries its previous stamp until it is committed, which is what a stamp should mean.
Until that day a Stop hook stamped the working tree after every turn, so a commit made mid-turn carried the new content and the old stamp; the story is in [README.md](README.md#what-keeps-it-up-to-date). The hook and its `--auto` mode are both gone — `--auto` was deleted from the script on 21 September 2026.
## The stamp
Version is `major.minor` starting at **v1.0**. An ordinary edit bumps the **minor**; a rewrite deserves `--major`. Dates read `27 July 2026`.
**Markdown** — two lines just after the H1. The HTML comment is invisible in every renderer and is the machine anchor; the bold line is what a reader sees.
```markdown
# Runbook R1 — Create a new area or place map
<!-- docstamp v1.4 | 2026-07-27 | sha=3f9a1c2b -->
**v1.4** · updated 27 July 2026
```
**PowerPoint** — a 9pt text box on every slide, shape-named `docstamp` so a re-run updates it instead of stacking a second one. Position is whichever candidate band is clear on *every* slide (`top-right` preferred); colour flips light or dark from the slide's background luminance. The record lives in the file's core properties.
## Why a re-run changes nothing
The stamp carries a short hash of the document's **own content with the stamp removed** — for a deck, all slide text plus every embedded media blob, so a swapped image counts as a change. If the hash is unchanged the file is **not rewritten at all**, so mtimes never churn and a document re-committed unchanged keeps its version.
## Commands
Every command on this page runs from `stamp-docs` — this skill's own folder in the `claude-skills` repository, where `scripts/` and `stamp-policy.json` sit beside each other. There are no placeholders except the quoted paths, which are the documents or folders to act on.
```bash
python scripts/docstamp.py --check # audit; exits 1 if anything is missing or stale
python scripts/docstamp.py --list # what is in scope
python scripts/docstamp.py --backfill # stamp new documents at v1.0, dated from git
python scripts/docstamp.py --all # hash scan; stamps whatever changed
python scripts/docstamp.py --major "path/to/doc.md" # rewrite: v1.4 -> v2.0
python scripts/docstamp.py --minor "path/to/doc.md" # force a bump
python scripts/docstamp.py --staged # what the pre-commit hook runs: stamp the staged documents into the index; always exits 0
python scripts/docstamp.py --all --all-roots # every root, not just the one you are in
```
Add `--dry-run` to any of them. A walk covers only the root containing the working directory and prints which, with the absolute path it will write — standing in a linked worktree of a root, that path is the worktree and not the main checkout (buses-data OA-495, 28 September 2026: until then `--all` from `.claude/worktrees/<name>` stamped the main checkout and said only `cwd is inside the buses checkout`); from `stamp-docs`, which is in no root, that means every root, and it says so; `--root buses|portal|ops` names one instead, and `--checkout [DIR]` points one root at a checkout you name (a worktree, placed through git) and walks only that. None of these is an everyday step any more — the hook stamps every commit, in a worktree or not. `--staged` takes none of them: its subject is the repository enclosing the working directory, and a repository the policy does not name is a no-op that says so.
## Markdown paragraphs
The house rule (`~/.claude/CLAUDE.md`) is that a newline in Markdown means a semantic break — end of paragraph, next heading, next list item, next table row — and never "the line got long". Hard wrapping is invisible to a reader but corrupts the diff: reflow one sentence and every following line in the paragraph is rewritten, so a one-word change reads as a rewritten section.
`scripts/reflow_md.py` unwraps prose that broke the rule. It is a **manual** tool — no hook runs it, and it has no default scope, so it only looks at the paths you name. Run it from `stamp-docs`, and `<path>` is the document or folder to unwrap.
```bash
python scripts/reflow_md.py "<path>" # dry run, the default
python scripts/reflow_md.py --apply "<path>" # rewrite in place
python scripts/reflow_md.py --check "<path>" # exit 1 if anything would change
```
Run from any folder; a `<path>` may be a file or a directory, and directories are walked for `*.md`. It skips `node_modules`, `.git`, `.venv`, `__pycache__`, `dist` and `build`, and honours the exclusions in `stamp-policy.json` so generated stage output is left alone — walking the Buses root drops from 141 candidate files to 97 because of that. A file named explicitly is always processed, exclusions or not.
Three guards make it safe over documents you have not read, and all three exist because the tool got it wrong first:
- **YAML frontmatter is passed through untouched.** An earlier version folded a memory file's `description:` line into `metadata:`, silently corrupting the frontmatter. It was caught by the second guard, on a real file, which is the only reason we know that guard works.
- **A file is written only if the word sequence is identical before and after**, bare `>` blockquote markers excepted since folding a quote drops them. If a join would lose or reorder a word the file is left alone and the failure reported, and `--check` exits 1.
- **Table rows are never joined** — `NEW_BLOCK` matches a leading `|`, and a line whose predecessor *ends* in `|` is not joinable either. This guard is load-bearing and its absence is invisible: an early pass collapsed the whole "Where everything lives" table in two `Buses\Documentation\` READMEs onto one line each, and because the word sequence was preserved the second guard saw nothing wrong. Neither had rendered as a table for weeks, and nobody noticed, because nothing in the workflow opens these files in a renderer. **The word-sequence guard checks that no text was lost; only this one checks that no structure was.** Repaired 2026-08-21.
Two things it does not do: it will not re-wrap (there is no way back), and it does not know a deliberate short line from a wrapped one below 60 characters — signatures, one-line answers and `Hello,` all survive because of that floor, but a genuinely short wrapped line would too.
**Archived documents are out of scope**, as of 17 August 2026 — `_archive` is in the `excludeDirNames` of both the Buses and the portal root (the portal gained a `docs/_archive` on 18 August 2026, and without the exclusion its three superseded docs would be re-stamped forever, a PR each). Neither tool touches superseded plans. Name such a file explicitly if you ever do want it reflowed.
## Scope
`stamp-policy.json` holds it — edit that, not the code. Three roots today: the Buses working folder (`.md` + `.pptx`), the `community-bus-maps` repo (`.md`), and the local-only ops notes (`.md`).
**Exclusions come in two layers, and the top one is shared** (buses-data OA-235, 4 September 2026). `baselineExcludeDirNames` names the directories that are never a document in ANY repository — `.git`, `node_modules`, `worktrees`, `scratch`, `dist`, `coverage`, `build` — and every root inherits it; a root’s own `excludeDirNames` now holds only what is local to it (`_latest` and `open-actions` in Buses, `data`, `staged`, `_archive` and `CHANGELOG.d` in the portal). Before that the three lists were maintained separately and had drifted to sharing only `.git`: `worktrees` was in ONE of them, so **60 of the 90 markdown files the portal root walked were inside `.claude/worktrees/`** — a second and third checkout of the same repository. The measured effect of adding the baseline was 185 in-scope documents down to 155, and all 30 that left were worktree copies, checked one by one rather than assumed.
**The cost was never the wasted work — it is that a stamp is an EDIT.** Two sessions could not both run `--all`: on 3 September 2026 each bumped stamps on documents inside the other’s worktree, neither having touched the other’s files, and the standing rule then was *re-stamp a document you edited BEFORE you commit it*, so a stamp arriving from elsewhere was exactly what got swept into a commit describing something else.
**Two kinds of reason live in that baseline** and it matters which when adding to it: `.git`, `node_modules`, `dist`, `coverage` and `build` are excluded because they are **not documents**; `worktrees` and `scratch` because they are **not ours to write to** — a worktree is full of real documents and the objection is ownership. A directory excluded for a reason peculiar to one repository stays on that root.
**A worktree is placed through git, never by its name.** A linked worktree's `--git-common-dir` is the main checkout's `.git`, whose parent is what a root names, so `docstamp.py --staged` in the pre-commit hook stamps a worktree's commit with its root's exclusions whatever the directory is called — and since 21 September 2026 the audit places it the same way, through the same function (`root_cfg_for_repo()`). `--checkout` uses that resolution too, and **refuses** a directory it cannot place, because it writes; the audit, which only reads, audits an unplaced repository with no exclusions and says so on stderr. Both directions are proved in `prove_policy.py` and `prove_staged.py`, against a real `git worktree add` rather than a hand-written `.git` file, which `git rev-parse` rejects.
**All three tools read the baseline through `scripts/policy.py`, and that is deliberate.** A baseline each of them unioned for itself would be the same write-it-once-per-place fault one level down, with a worse failure mode — two agreeing and the third stamping what the others skip. `scripts/prove_policy.py` asserts the four resolution rules and then asks all three readers for their resolved exclusions and insists they match, with a control that the comparison can notice a disagreement at all. Run it from `stamp-docs`; there are no placeholders:
```bash
python scripts/prove_policy.py
```
**Never stamp generated output.** The stage pipeline already versions its own files by folder name (`S4-generate/v1.3_2026-07-19_0517`) and stamps its reports in the body; the portal's rendered sheets sit under a byte-identical gate that stamping would break. The policy excludes `S[1-6]-*`, `_latest`, `node_modules`, `data/`, and the dated `_gtfs` reports. Adding a root means adding exclusions for whatever it generates.
**A generated report can also exclude ITSELF, and since 2026-08-28 that is the preferred way** (open action OA-096, now closed). Any markdown file whose first 40 lines contain `<!-- generated by ` is skipped, wherever it lives — `generatedMarker` in `stamp-policy.json`. This exists because the path-based rules only ever caught the generated files somebody remembered to name: `stand-coverage_2026-08-22.md` and `frame-coverage_2026-08-23.md` churned in every diff for weeks, the hook inserting a stamp and the next run of their generator deleting it, over a version number that described nothing. Naming those two would have fixed those two — nothing about writing a *third* generator reminds anybody that a policy file in another repository has to learn a new filename. **So when you write a script that emits a markdown report, have it print that marker as its second line.** The report is then excluded on the day it is written, by the person already thinking about it. It is read from the head only, and **only a line that *begins* with the marker counts** (since 2026-09-23, buses-data OA-446). Before that any line in the first 40 that merely CONTAINED it counted, so buses-data's `Development Docs/README.md`, which quotes the marker in backticks while naming the two reports that carry it, was skipped by `--staged` as generated while the pre-commit audit, which skips nothing, refused the commit as stale. `prove_staged.py` case 5b holds it.
## Committing a stamped document
**Since 18 September 2026 there is nothing to run when you edit a stamped document**: the pre-commit hook stamps it as part of the commit (buses-data OA-397). A hand-run walk (`--all`, `--check`, `--list`) covers only the root you are standing in and prints which (buses-data OA-333); `--all-roots` asks for the estate-wide pass by name.
## The stamp can be correct on disk and wrong in git — and the audit that catches it stays
`--check` audits the **working tree**. A stamp written after a commit could therefore be right on disk and wrong in `HEAD`, and anyone reading the file out of the repository — a cold start, a clone, a PR review — would see a stamp that does not describe what they are reading, looking exactly as authoritative as a correct one. Found 2026-08-17: three of the 44 stamped `.md` in the Buses repo were stale in `HEAD`, one of them claiming *v1.12 · 9 August* over a body that had moved on.
Stamping at commit time closes that by construction, and the audit that used to catch it is **kept as the control that must never fire**: `check_committed_stamps.py --staged` still runs in the pre-commit hook after the stamper, and the CI step still hashes `HEAD`'s blobs. A green from either now says the mechanism worked; a red says something bypassed it. `scripts/prove_staged.py` drives the whole thing through real hooks and real commits, and its mutation arm runs the same mid-turn edit through a hook that does not stamp and requires the audit to refuse it.
To audit what is actually committed, hash `HEAD`'s blobs rather than the files on disk:
```bash
python scripts/check_committed_stamps.py # every stamped .md in HEAD, per repo
```
Read it back rather than assuming: on 2026-08-25 the portal briefly went **3 STALE of 29** in `main` this exact way, and reads 32/32 once the follow-up landed. The checker exits 1 on findings, and **it runs in CI**: the `status` job of `buses-data`'s `.github/workflows/gates.yml` runs it from its checkout of this repository — pinned to the engine commit in `engine.lock.json`, so a change to this script reaches that job when the pin next moves — over `buses-data` and `community-bus-maps`, naming those two roots explicitly. The third policy root, `community-bus-maps-ops`, is deliberately NOT passed — it is never pushed, a runner has no copy of it, and it holds the estate's one genuinely stale stamp, so judging it from CI would make the step red on day one for a reason nobody could fix. Proven both ways on 2026-08-27: exit 0 on the real corpus (Buses 82/82, portal 32/32 by explicit root), exit 1 on a scratch repository holding one deliberately wrong sha.
### The 16 stale portal docs that were never stale
This file previously recorded, as known-outstanding, that *"`community-bus-maps` has 16 of its 31 stamped `.md` stale in `HEAD`"*, and guessed at squash-merges compounding over many PRs. **That was a bug in the audit tool, not in the stamps.** `check_committed_stamps.py` decoded `HEAD`'s blobs as `utf-8`, keeping the BOM; `docstamp.py`'s `read_text()` strips it before hashing. `str.strip()` does **not** treat `` as whitespace, so the BOM stayed in the hashed body and every BOM-carrying file reported stale. The 16 "stale" files were exactly the repo's 16 BOM'd files; the 15 "correct" were exactly the 15 without.
Fixed 2026-08-18 by decoding `utf-8-sig`. Proof, on `docs/DEPLOY.md` at `HEAD` — which the tool called stale minutes after its stamp was committed in PR #42:
```
BOM stripped (docstamp) -> 80ce1414 stamp says 80ce1414 correct
BOM kept (old audit) -> c873552a stamp says 80ce1414 "stale"
```
The lesson is the expensive part: the tool reported a real-looking failure with per-file hashes attached, and the recommended fix was 16 version bumps pushed to a public repo. **A red audit is a claim about the tool as much as about the data** — reproduce one failing case by hand before acting on a batch.
The audit honours the policy's exclusions, so `_archive` and other out-of-scope trees are counted (`N out of policy scope`) rather than judged — **provided it can place the repository at a root**, which inside a linked worktree it could not until 21 September 2026 (see the last paragraph of this section).
**`--staged` did not honour them until 2026-08-31, and the docstring said it did.** The exclusions were applied on the HEAD path and not on the index path, and nothing revealed it for two days because **the only way to reach the bug is to EDIT an archived document** — archiving has always been a pure `git mv`, which changes no content, so a stale stamp never arose there. Then a documentation round in `buses-data` repointed the links inside nine files it was archiving, and the pre-commit hook refused the commit over nine documents this stamper deliberately refuses to stamp. **An unsatisfiable refusal is worse than no check**: it names a fix that cannot be carried out, and the only way past it is `--no-verify`, which is a habit that does not come back. Both halves were proved after the fix — an in-scope document with a stale stamp is still refused, and an out-of-policy one is skipped.
**And the same bug was one level out, in CI, where the fix above does not reach.** `gates.yml` audits by NAMED path — `check_committed_stamps.py "$GITHUB_WORKSPACE/buses-data" …` — and a named repo was documented as *audited without exclusions*, because the policy config travels with the policy ROOTS and a CI checkout is at a path no root has. So the local hook went quiet and CI went red about the same nine files, on the same push. Policy roots now carry **`checkoutDirNames`**: the names the same repository goes by when it is checked out elsewhere (`buses-data`, `community-bus-maps`). **A repo matching nothing is still audited with no exclusions and SAYS so**, on stderr, from both the HEAD path and `--staged`, because a silent filter is the worse of the two failures. Falsified in a throwaway repo with one stale `_archive/` file and one stale `Documentation/` file: named `buses-data` it reports 1 STALE and 1 out of policy scope, and renamed to anything else it reports 2 STALE and prints the warning.
**And the placement itself was a second copy of the stamper's, which is how a worktree fell through it (21 September 2026).** The audit matched a repository by path and then by `checkoutDirNames`; a linked worktree has neither, so every commit made in one had its staged documents audited with no exclusions and no warning, while the stamper — placing through `--git-common-dir` — correctly left `_archive` alone. A merge in a `community-bus-maps` worktree was refused over `docs/_archive/GO-LIVE.md`. The audit now asks `docstamp.root_cfg_for_repo()`, so the two cannot place a tree differently. `prove_staged.py` case 9 commits a stale-stamped `_archive/x.md` inside a linked worktree named nothing any list holds, with a stale in-scope control beside it; case 10 requires the no-match warning. Both went red against the old placement before the fix.
## Gotchas
- **Decks are git-ignored** (`*.pptx` in the Buses `.gitignore`), so git is no safety net and a git-status trigger would not see them at all. Copy them somewhere before a first stamp of a new deck, and verify afterwards that slide count, text blocks and media parts are unchanged.
- **A stamped deck's exported PDF goes stale**, and there is no LibreOffice or pandoc on this machine to regenerate it. Re-exporting is manual in PowerPoint.
- **`--backfill` dates from git**, not today, so a first stamp tells the truth about when the document last actually changed. **It only does this for documents with no stamp yet** — that restriction was missing until 2026-08-21, and a backfill run for one new README re-dated four documents edited the same morning to the day before, because an already-stamped file only reaches the stamping code when its content just changed and its git date is therefore the *previous* commit. If you are backfilling in a session where you have also edited stamped documents, `--check` afterwards will not catch it (the sha is still correct — only the date is wrong); read the visible dates.
- **The stamp says a document changed; it cannot say the documents pointing AT it are still true.** Found 2026-08-22: `Development Docs/open-actions.md` was deliberately cut from 400 lines to 81 on 2026-08-20, and five places still sent a reader there for narrative and section headings it no longer carried — three other Development Docs, `community-bus-maps/CLAUDE.md`, and the project memory index. **Every one of those links still resolved**, so a link checker would have passed all five; only the content behind them had gone. When you cut content out of a document, grep the doc sets and both memory stores for its filename *and* for the headings you are removing, and repoint each hit. Where the content went to git history, name the commit SHA rather than "the version before the tidy-up" — open-actions.md now cites `546cd62` with the exact `git show` command and the folder to run it from. **A link checker over these doc sets now exists** — built 2026-08-27, and not here: it is `Documentation/check-doc-links.mjs` in `buses-data`, run from that repository's root and wired into the `docs` job of its `gates.yml`. It covers three of the four classes: a dead path, a dead `#anchor`, and a `§n` the named target does not have — plus a link that climbs OUT of the repository, which resolves on the machine that wrote it and 404s for every other reader. It deliberately does NOT judge a citation by phrase, because there is no syntax to anchor that on; that residue is `open-actions` **OA-139**, and the mitigation stays the paragraph above this one. Its first run found **79** dead links, 77 of them from a document split made the same morning.
- Existing metadata lines such as `**Last reviewed:** … **Against:** 0.8.1` mean something different (reviewed against a code version). Leave them; the stamp sits above and both coexist.
Community Reviews & Field Notes
Tried this skill on your own project? Share the model you used and the results you got.