- Status: active
- Source of truth:
AGENTS.md,docs/index.md,docs/structure.md,docs/playbooks/index.md,docs/adr/index.md,packages/cli/src/docs/docs-validation-service.ts - Verified with:
npm run build,npm run test:unit,npm run validate:docs - Last verified: 2026-03-25
This file defines how Spec2Flow keeps repository guidance small, current, and mechanically enforceable.
The target is not "more documentation." The target is a working harness that resists two failure modes:
- bloat: too many overlapping docs, mega-docs, and duplicated explanations
- drift: docs that still read well after the code, commands, or contracts have moved on
Spec2Flow already has the right foundation for an AI-readable repository:
llms.txtgives agents a first-stop machine-readable intake map.AGENTS.mdstays short and architectural instead of becoming a giant handbook.docs/index.mdroutes readers to the smallest relevant source-of-truth set.docs/playbooks/gives stage-scoped operating guidance instead of burying workflow details in root docs.docs/adr/captures durable decisions separately from plans and exploratory prose.docs/plans/keeps migration and rollout material out of the primary docs root.schemas/, TypeScript types, and checked commands provide enforceable contracts.npm run validate:docsalready catches missing metadata, dead links, bad script references, archived-plan misuse, and docs-root layout drift.
This means Spec2Flow is no longer at the "aspirational harness" stage. The repository already has real structure and real checks.
The current weak points are narrower now, but they are still real:
- an active doc can be structurally valid while still being old
- a design or plan doc can remain
activeafter the stable docs already became the real truth - a command can still exist while no longer being the best proof path for the behavior the doc claims
- multiple active docs can overlap and slowly diverge even when all links still work
- agents can treat a long narrative as canonical if the doc does not state what is enforced versus advisory
This is why dates matter, but only when paired with command and source-of-truth validation.
Every active doc must expose a small metadata block near the top:
Status:active,reference,historical,completed, ordraftSource of truth: the code paths, schemas, or docs that actually own the behaviorVerified with: the smallest stable command path that can still prove the doc is not fictionLast verified: the most recentYYYY-MM-DDdate when the active doc was re-checkedSupersedes/Superseded by: optional file-level handoff metadata when one canonical design or API doc replaces another
Dates are necessary, but not sufficient.
A date alone is theater. The anti-drift unit is:
- an active status
- a real source-of-truth pointer
- a real verification command path
- a recent verification date
If one of those four is missing, the doc is not trustworthy enough to act as active guidance.
Spec2Flow now treats documentation freshness as an enforced runtime concern, not a polite suggestion.
Rules:
- active docs must use
Last verified: YYYY-MM-DD - active docs cannot use future dates
- active docs cannot stay older than the freshness window enforced by
npm run validate:docs - historical and completed docs are exempt from freshness windows, but they must not sit in the active docs root
- archived plans can stay searchable, but active docs must point to archive index pages rather than archived plan files directly
This is the key answer to "should docs include dates?"
Yes. For active docs, dates are worth adding because they give the validator something concrete to measure. Without a date, stale docs can look authoritative forever.
Spec2Flow should keep moving repeated rules down this ladder:
llms.txt,AGENTS.md, anddocs/index.mdThese establish reading order and source-of-truth routing.- Scoped instructions
.github/instructions/*.mdtells agents how to edit docs, TypeScript, and schemas without polluting always-on architecture guidance. - Metadata contract
Status,Source of truth,Verified with, andLast verifiedmake freshness and ownership explicit. - Structure rules
docs/structure.mdanddocs/plans/index.mdkeep plan sprawl and historical drift out of primary navigation. - Deterministic validation
packages/cli/src/docs/docs-validation-service.tsturns metadata, script, link, and archive rules into failures instead of wishes. - Contracts and tests
schemas/, TypeScript types, generated examples, and unit tests keep behavior drift visible even when prose still looks clean.
The repository gets safer every time a recurring prose rule moves one rung lower.
For active docs and canonical navigation docs, validation should fail on:
- missing or malformed metadata
- broken source-of-truth paths
- overbroad source-of-truth directories when a concrete file path should own the truth instead
- broken markdown links
- referenced
npm runcommands that no longer exist - referenced
npm runcommands that are marked deprecated in the docs-validation registry - direct links to archived plan files from active or canonical docs
- plan-like docs placed directly under
docs/root - active docs whose
Last verifieddate is stale - non-reciprocal
Supersedes/Superseded byrelationships
This is the minimum viable anti-drift gate. If a repo wants "iron-law" behavior, this command has to be annoying in the right places.
No validator can prove that prose is perfectly written or that every explanation is the shortest possible one.
Humans and agents still need to decide:
- whether a new doc should exist at all
- whether a plan should be folded into a stable doc and archived
- whether two docs overlap enough that one should defer to the other
- whether a verification command is still the smallest honest proof path
The rule is simple:
If the repo can enforce it mechanically, do that. If it cannot enforce it mechanically yet, document it once in the narrowest owning place and then plan the enforcement upgrade.
To keep the docs root sharp:
- one doc should answer one dominant question
- indexes should route; they should not become encyclopedias
- stable decisions should move to ADRs
- stage procedure should move to playbooks
- rollout and migration narrative should move to
docs/plans/ - examples should show concrete evidence, not carry primary architecture truth
When a doc starts mixing architecture, operations, migration history, examples, and policy in one place, that is a bloat signal, not a sign of thoroughness.
When behavior changes:
- update the owning code, schema, or command path
- update the smallest active doc that should describe it
- update
Last verified - run the smallest honest validation path
- run
npm run validate:docs
When a plan becomes true:
- move stable truth into root docs, ADRs, playbooks, or contracts
- change the plan status or archive it
- remove the plan from primary navigation if it no longer drives implementation
Spec2Flow should consider its doc harness healthy only when all of the following are true:
- new agents read
llms.txtfirst and can find the right doc quickly - active docs declare who owns the truth and how it was last checked
- root docs stay small because plans, ADRs, playbooks, and examples each keep to their lane
npm run validate:docscan reject stale or structurally misleading docs- schemas, tests, and examples backstop the prose with executable truth
That is the real anti-drift posture: not trust in good intentions, but a repository that makes lying documentation expensive.