Maintaining Project Documentation
Overview
Two families of documents drift for different reasons, so they have different rules:
- Lifecycle docs (root):
ROADMAP.md,CHANGELOG.md,AUDIT.md. They drift because update triggers were never defined: a session establishes a convention, the session ends, the convention evaporates, and the next run reverse-guesses it and guesses wrong. - Knowledge docs (
docs/): guides, concept/architecture docs, reference, reports. They drift because nothing structurally binds them to the code.
Open work is not a document this skill keeps. It lives in the tracker that
~/.claude/skills/ticketing/references/tracker.md defines, issues or ticket
files, and moving it through its states is triage's job, user-invoked, so
that sitting is the owner's to open. This skill writes a deferred item into
the tracker and stops there.
The canonical rule
Every mechanism here is one move: name a single canonical source, and make every other copy derived: copied, generated, or symlinked. Drift is what happens when two copies can both be hand-edited.
| What drifts | Canonical | How the derived copy stays honest |
|---|---|---|
| Doc formats across projects | templates/*.template.md | copied verbatim by scaffold-docs.sh |
| API reference | rustdoc / docstrings | compiler + doctests |
| Translations | the declared source-language doc | regenerated at each release sweep |
| Agent instructions | AGENTS.md | CLAUDE.md is one line, @AGENTS.md, importing it |
| A finding's evidence | its docs/audits/ report | the tracker item, in the tracker reference's shape, links the report instead of copying its measurements |
| Doc and comment shape | scripts/doc-lint.py in the project | the hook, prek and CI all call that one script |
Authoring or restructuring any doc this skill owns starts by opening the matching
templates/*.template.md and following its section order. Placeholders are
<ANGLE_BRACKET>; the <!-- HINT … --> comments go away once filled.
scripts/scaffold-docs.sh <project-dir> [--agent] [--audit-report <scope>] copies
those templates in verbatim without clobbering. Use it for new-project bootstrap
and for dropping a fresh audit-report shell.
When this fires
landing runs this on the branch before it merges, so the doc rewrites and
the CHANGELOG line travel with the merge; the table is the same check for
work that lands any other way. Before you declare a task done, touch what each row the
task matches names:
| Trigger event | Touch |
|---|---|
| Merge a fix/feature batch | CHANGELOG [Unreleased]: one line per change someone using or working on the project sees · re-verify every knowledge doc whose Updated: stamp predates the batch · each item the batch deferred goes to the tracker in needs-triage |
| Ship a crate / cut a release | ROADMAP: rewrite the item's status sentence and the Updated line · CHANGELOG version section + tag · doc freshness sweep |
| Complete an audit / re-audit | new report in docs/audits/ + AUDIT index row · each open finding to the tracker in needs-triage, linking its report · ROADMAP quality-history line |
| Change direction / decide a gate | rewrite the affected ROADMAP section |
| A design doc ships | distill the durable parts into docs/concepts/; the design doc itself is not edited |
| Edit user-facing docs (guide/concept/reference) | place per the docs/ layout · update the doc's Updated: stamp · regenerate any translation |
| Change how the project is built, tested, run or configured | README: rewrite the affected how-to · AGENTS.md Commands block, each command run first (Family 3) · never a dated note in either |
| Start a new project, or change a project-specific convention | create or update AGENTS.md per Family 3 |
Every action above is a rewrite of the affected text. The only document that
appends is CHANGELOG, and it appends one line. A "docs: record the round"
commit that grows README or ROADMAP is the failure this table exists to
prevent, and scripts/doc-lint.py (see Enforcement) rejects the shapes it
produces.
A deferred item is written in the needs-triage shape the tracker reference
gives, into the tracker form it picks for this repository, and its
evaluation is left to the triage sitting. A repository that still carries an
older append-only list sends new items to the tracker all the same; folding
the old list in is triage's one-time pass, which only the owner starts.
If none of the rows apply, this skill is not needed.
Family 1 — Lifecycle docs (live in repo root)
Root, not docs/: these are the project dashboard, meant to be the first
thing a reader sees.
Roles (one sentence each; keep them distinct)
| Doc | Role | Mutability |
|---|---|---|
ROADMAP.md | The map: direction, vision, layer/status, gates, sequencing, and the development process. An item's status is one sentence using two words only: code complete (merged) or accepted, in the sense landing defines: the spec's verification step passed | Living: rewrite whole sections freely |
CHANGELOG.md | What shipped (Keep a Changelog format) | Append-only; a released section is immutable |
AUDIT.md | The audit index; each full report is an immutable file in docs/audits/ | Index is living; the reports it points to are frozen |
When the spec's verification step can only run after deploy, the status stays code complete and the sentence names the pending step in the spec's words.
AUDIT rules (index + frozen reports)
- A completed audit writes its full report to
docs/audits/YYYY-MM-DD-<scope>.md: verdict, method, and every finding with its mechanism / measurement / evidence. That file is immutable once written: a later re-audit gets its own file, never an overwrite. - Root
AUDIT.mdis an index table:Date | Scope | Verdict | Open findings | Report. - A re-audit is a new report. Its measurements stay in that report; the tracker item links the report rather than copying them, so the evidence has one home.
- Templates:
templates/AUDIT.template.md(the index),templates/audit-report.template.md(each report).
CHANGELOG rules
- The merge that changes what someone using or working on the project sees
(behaviour, a command, a configuration key) updates
[Unreleased]in the same commit. A separate "update the changelog later" step is a missed step. - One entry, one line: what changed and where, as that reader sees it. The why is the commit message's job, the evidence is the report's. CHANGELOG is the only lifecycle doc that appends, which is exactly why each append is small.
- At release: move
[Unreleased]into a[x.y.z] — YYYY-MM-DDsection, create the matching VCS tag, and point the compare/release footer links at the real remote. - Frozen public contracts (e.g. a pinned RNG bit-stream) get a standing note at the top stating that any change to them is a semver-major event.
- Template:
templates/CHANGELOG.template.md.
Family 2 — Knowledge docs (live under docs/)
Layout (Diátaxis-derived — classify by reader intent)
docs/
guides/ how-to: deployment, trading manual, runbooks, migration guides
concepts/ explanation: architecture, design rationale, mental models
reference/ look-up facts that live outside the code: file formats, fixture
schemas, config-key catalogues
reports/ dated, immutable deliverables: investor report, feasibility study
plans/ one job's design doc and its tickets, as
YYYY-MM-DD-<topic>-design.md and YYYY-MM-DD-<topic>-tickets.md,
plus out-of-scope.md, the rejections triage keeps
reviews/ qa/ audits/ benchmarks/ sessions/ process trail (as-is)
- API reference is rustdoc / docstrings, canonical in the code, where
doctests keep the examples honest and the compiler flags drift. A
docs/reference/api.mdrestating signatures has no canonical source, so it rots. - A design doc in
docs/plans/is a write-once historical record. When it ships, distill the durable parts into adocs/concepts/doc, which becomes the living current truth. - Every living knowledge doc opens with
Updated: YYYY-MM-DD (@<commit>).
Bilingual policy
The canonical rule applied to language. Each document declares one
canonical-language source, chosen by audience (investor/ops-facing → per project
norm; developer-facing → English). Translations are derived: regenerate them from
the canonical source at each release sweep. Name them <name>.<lang>.md (e.g.
deployment.zh.md) so the canonical/derived relationship reads off the filename.
A single-audience doc keeps one file.
Family 3 — Agent instruction files and README (project root)
The operating brief for the next agent session, the one reader that is you, next time.
AGENTS.mdis canonical. It is the file Codex, Cursor and Gemini CLI read on their own; Claude Code readsCLAUDE.md, so that file is one line,@AGENTS.md, importing it. One source, every tool. Claude-only material (a.claude/rules/pointer, a skill name) goes below the import line inCLAUDE.md, and almost nothing qualifies.- Content rule: only what is UNIQUE to this project and NOT derivable. The
highest-ROI section is the exact command block: agents burn tokens guessing
whether it's
cargo testoruv run pytest. Everything else points rather than duplicates: architecture →docs/concepts/+ROADMAP.md. Whatever is global already applies from~/.claude/CLAUDE.md. README.mdis for humans: quick start, configuration, where things are. It is rewritten when those change and holds no dates, rounds or history: an operational narrative belongs indocs/guides/, a change in CHANGELOG. A README that collects session notes stops answering "how do I run this" within a few rounds.
Template: templates/AGENTS.template.md + templates/CLAUDE.template.md
(or scaffold-docs.sh … --agent). Sections: What this is · Commands ·
Architecture · Project-specific conventions · Gotchas · Lifecycle docs.
The next-session test
Every line earns its place by one question: remove it — does the next session take a wrong turn, one you would have to step in and correct? Keep the line if yes. Everything else is load the project pays for on every single turn.
The test has teeth because it asks about a wrong turn, not about usefulness. Plenty of true, interesting facts pass "useful" and fail this.
Writing one
- Read the ground truth first: build manifests (
Cargo.toml,pyproject.toml,package.json), the CI config,README.md, and any existing agent file. Facts come from these, never from inference. - Run every command you intend to write. The command block is the highest-ROI section and a wrong invocation there misleads every future session. Done when each line has been executed once in this project and its output seen; no line arrives by pattern-matching from another repo.
- Draft from
templates/AGENTS.template.md, section by section, deleting the<!-- HINT -->comments as you fill them. - Apply the next-session test to every line, including ones you just wrote.
- Sweep the failure modes below. Done when each has been checked against the draft. A file that still runs long is almost always carrying material that belongs somewhere else, so a long one gets a second pass with that question.
Failure modes
-
Restating the global file: anything in
~/.claude/CLAUDE.mdalready applies to this project. Repeating it doubles the cost and creates two places to edit. -
Restating a skill's description: a model-invoked skill's description is already in every window; naming its triggers again is duplication.
-
Always-on material only some tasks need: a section that matters to one kind of work belongs in a skill or a
docs/doc the file points at. -
Unverified commands: an invocation copied from a sibling project, or from memory of how this stack usually works.
-
A rule where a fact would do: "use the semantic index for code search" is a rule that fires even when grep is the better move; "this repo has a semantic code index" is a fact the agent can act on with judgement. Prefer the fact.
-
Maintenance: update Commands when an invocation changes; add a line when a new convention or gotcha is found; refresh Architecture pointers on structural change.
-
Legacy / missing files are migrated on touch, not in a sweep: the next task that lands in a project brings its agent file up to template.
-
/initproduces a first draft; trim it to the template and then maintain it. A generated file left unpruned rots as fast as no file at all.
Enforcement — the shapes are checked, not requested
Instruction files and skills are advisory: a rule the model can ignore will be ignored the day it is inconvenient. What holds is a check that runs where the writing happens.
scripts/doc-lint.py(template:templates/doc-lint.template.py) lives in the project and checks: the ROADMAPUpdatedline and per-item status length, CHANGELOG entry length, README prose length and dated history sentences, design-doc write-back sections, and in source files consecutive-comment-block length and comments that cite a task, round, ticket or commit. Every limit carries the commit it was measured on;scripts/doc-lint-measure.pyre-derives them. A limit with no provenance is a guess, and the template's starting values are somebody else's measurements, so re-measure before the project's first release.- Change-scoped by default.
--diff,--base REFand--from-hookreport only findings the change introduced, matched against the base by rule and offending line. A tree carrying old debt is gated on "adds none" while the debt is cleared in its own sub-project;--allreports everything for that job. - Three callers, one script.
.claude/settings.json(template:templates/claude-settings.template.json) runs it as aPostToolUsehook onWrite|Edit(exit 2 feeds the reason back to the model, which fixes the file in the same turn) and as aStophook over the diff. The project's pre-commit config and CI lint job call the same script, so a human edit is held to the same shape. Keep.claude/settings.jsonand.claude/rules/tracked; only.claude/settings.local.jsonis personal. .claude/rules/docs.md(template:templates/docs-rule.template.md) is the four-line statement of the shapes, path-scoped to the lifecycle docs so it costs nothing until one of them is opened.
New-project bootstrap
When a project first grows past a README, run:
scripts/scaffold-docs.sh <project-dir> --agent
It drops ROADMAP.md, CHANGELOG.md, AUDIT.md, and (with --agent)
AGENTS.md, CLAUDE.md, .claude/rules/docs.md, .claude/settings.json,
scripts/doc-lint.py and scripts/doc-lint-measure.py from the templates,
verbatim and without clobbering. Then fill the <PLACEHOLDERS> (the
Commands block of AGENTS.md first, it has the highest ROI), wire
doc-lint into the project's pre-commit and CI, and re-measure its limits
before the first release. Open work needs no root file: the first deferred
item goes wherever the tracker reference sends it.
Add each docs/ subfolder when its first document exists (YAGNI). AUDIT.md
starts as a bare index header; its first row is added when the first audit lands.