DocGuard
Technical Brief · v0.46.0 · Ricardo Accioly · MIT

Your docs are green. That is not the same as your docs being true.

DocGuard reads what your docs claim about your code. It reads the code too. It reports every claim that no longer matches, and says which findings it is sure about and which it is not.

The problem

The faster AI writes code, the faster everyone loses the map of what was built. Every agent session starts from zero and works out again how the system works. The docs are the map. Nothing checks whether the map still matches the territory.

A real finding, from DocGuard's own demo fixture — a 4-service payments API with deliberate drift
4. [MED] Traceability
   DATA-MODEL.md — exists but no matching source code found (unlinked doc)
   → Doc lives in canonical/ but isn't in the manifest — guard skips it, drift accumulates silently.

npx docguard-cli demo finds seventeen of these in half a second in a project whose docs look complete. Each names the file, the claim, and what you lose if you trust it.

A maturity score asks “Is the map whole?” 100/100 every required chapter present — and that is true DocGuard's guard asks “Does the map match the territory?” 17 claims that no longer match the code

Fig. 1 — The same docs, two questions. DocGuard reports both and never lets one replace the other.

The method, in one sentence each — the third column is the one most tools do not have

verified

The doc says it; the code agrees. Believe it.

drift

The doc says it; the code says otherwise. DocGuard names the fix.

escalate

Something changed near this claim. The judgment is yours — DocGuard says so instead of guessing.

A document can be beautifully formatted and completely wrong. A green check is worth exactly as much as the question it answered.

The design constraint everything else follows from · PHILOSOPHY.md
DocGuard
02 — Two tiers

Two tiers, so the tool never overwrites your thinking

A canonical doc holds two kinds of sentence. Some come from code — endpoints, entities, environment variables. Some are human reasoning — why the queue is idempotent, which trade-off was rejected, the gotcha nobody would guess. A tool that rewrites the whole file destroys the second kind each time it refreshes the first.

DocGuard keeps both in one readable markdown file, separated by HTML-comment markers. It owns the bytes inside a source=code block and may rewrite them when the code changes. It never touches anything else.

The marker, as it appears in a real ARCHITECTURE.md
<!-- docguard:section id=api-endpoints source=code -->
| GET  | /api/orders/:id   | orders.controller.ts |
| POST | /api/orders       | orders.controller.ts |
<!-- /docguard:section -->
The orders service is idempotent on client-supplied keys because the mobile
client retries on any 5xx; see ADR-007 for the rejected alternative.   ← never regenerated
docs-canonical/ARCHITECTURE.md ## Component Map <!-- source=code --> | service | file | routes | ... (regenerated by docguard sync) code-derived DocGuard owns it. Rewritten surgically. ## Key Design Decisions We chose event sourcing over CRUD because the audit trail is a regulatory requirement, not a feature. Rejected: soft-delete flags. human reasoning Preserved byte for byte. Guarded, never generated. ## Tech Stack <!-- source=code --> Node 18+ · @babel/parser (pinned) · zero test dependencies code-derived Fails Generated-Staleness if the scan disagrees.

Fig. 2 — One file, two owners. The tool refreshes the blue bands and checks the gray one. It never does the reverse.

Three verbs, one memory

DirectionVerbWhat it does
code → docsgenerateBuild a canonical memory from any codebase. Forty-six scanners build the code-truth skeleton (routes, schemas, screens, env vars, IaC). An agent writes the prose around it.
code ↔ docssyncWhen code changes, refresh only the affected source=code sections. Automatic where certain; a structured agent task where not.
docs ↔ codeguardCheck that the memory still matches reality: deleted endpoints still documented, routes never documented, env vars nobody reads, requirement IDs no test traces to.

Any language works. JavaScript/TypeScript and Python get a syntax tree. Rust, Go, Java/Kotlin, Ruby, PHP and C# get a fallback that reads code shape. Every finding says which produced it; silence on a fallback file is weak evidence, not a pass.

The tool is allowed to be wrong about the table. It is never allowed to be wrong about your paragraph — so it is not allowed to touch it.

Pillar 2 of Canonical-Driven Development
DocGuard
03 — Anatomy of a finding

One claim, from document to verdict

Every run follows the same five steps. None of them calls a language model. The pipeline is deterministic, offline and reproducible: the same tree gives the same findings on every machine. That is why a finding can be a CI gate and not an opinion.

1 · scan code AST for JS/TS and Python; routes, schemas, env reads, imports, test IDs, IaC. 2 · read docs Canonical docs, README, AGENTS.md, specs — nested folders included. 3 · compare 33 validators, each one claim family against one evidence source. 4 · classify Five channels per finding: who decides, how sure, was it ever measured. 5 · report Terminal, JSON, SARIF, JUnit, badge; exit 0/1/2; an agent-ready fix prompt. no network · no LLM at validation time · one pinned dependency (@babel/parser, with a regex fallback) · Node 18, 20, 22, 24

Fig. 3 — The pipeline. Step 4 is where DocGuard differs from a linter: a finding is not one number, it is five independent answers.

What a finding carries

A finding used to answer one question — how worried should you be? — with one field. That field did three jobs: how certain the detector was, whether a human had to look, and whether anyone had checked the number against reality. DocGuard now splits it into five independent channels. A blocking error can still be an escalation. A high-confidence observation can still be one only you can judge.

ChannelThe question it answersValues
severityDoes CI block?error · warn · info
dispositionWho decides — the tool or you?act DocGuard states a defect and names the fix · escalate the judgment is yours
confidenceHow sure is the detector of its observation?high · low
evidenceHas the reviewed corpus ever measured this code?measured with n and a Wilson bound · not-measured (a maintainer's prior, nothing more)
parserTierWhich analyzer could see this file?js-ast · py-ast · regex-fallback · fallback-language · mixed
escalate · confidence: high

“13 code commits since ARCHITECTURE.md was reviewed.” The count comes from git log, so it is exact. It proves only that a review is due, never that the document is wrong. Editing until it stops printing fixes nothing.

act · confidence: high

“README says 15 validators; the package ships 33.” Both sides are counted from disk, so the tool may rewrite the number. It also records where the count came from. A later reader can see the fix was about the same subject.

Across fourteen real repositories, 671 findings split 234 the tool would fix and 437 it handed to a human. It says which is which on every line.

CHANGELOG · calibrated finding channels, September 2026
DocGuard
04 — The detectors

Thirty-six detectors, each proven before it is on by default

Each validator compares one family of documented claims with one source of evidence. grouped by what they read, which decides how much a finding is worth.

36
validator modules; new checks start advisory
cli/validators/
73
code scanners feeding them, two full AST parsers
cli/scanners/
1
pinned runtime dependency, with a regex fallback
@babel/parser
0
model, network or telemetry calls at validation time
PRIVACY.md
FamilyReadsValidatorsThe claim it tests
Code truth · 9AST: routes, schemas, env reads, importsDocs-Sync · Docs-Diff · API-Surface · Schema-Sync · Environment · Architecture · Surface-Sync · Docs-Coverage · Generated-Staleness“This endpoint / entity / variable / layer rule exists and looks like this.” The findings the tool fixes itself.
Structure · 8File tree, headings, manifestsStructure (with Doc Sections) · Changelog · Document-Lifecycle · Spec-Registry · Spec-Kit · Metadata-Sync · Doc-Ownership · Decision-Records“Required chapters exist, requirements reach tasks, versions agree, decisions name their successor.” Completeness, not correctness.
References · 6Links, symbols, IDs across two revisionsCross-Reference · Reference-Existence · Traceability · Test-Spec · Path-Scoped-Rules · AI-DLC“This link resolves; this symbol exists; this requirement has a test; a path-scoped rule matches files; an AI-DLC record names real files.”
Change & time · 5git log, the diff since a ref, code fingerprintsFreshness · Diff-Suspicion · Drift-Comments · Doc-Dependency · Requirement-Anchors“Something changed near this claim.” Exact, but escalated: a review is due.
Numbers & self · 3Counts on disk, typed JSON, its own packageMetrics-Consistency · Canonical-Sync · Evidence“The number in this sentence equals the number on disk.” Includes the tool's own README, so its count claims are checked, not remembered.
Quality & hygiene · 5Prose metrics, secret patterns, TODOs, suppressionsDoc-Quality · API-Doc-Smells · TODO-Tracking · Security · Suppressions“Readable, not bloated, not documented in name only; no secret committed; no TODO untracked; no suppression past its expiry.” Soft by design.

A validator with nothing to validate returns N/A with a reason, never a pass. A green line says what it looked at.

The bar for shipping one

Built from a method

Where a published method exists, the detector implements it (page 5). Where none does, the finding's own help text calls the heuristic a heuristic.

Run read-only on real repos

First-run conditions on production codebases; every finding hand-classified as true, false, or inert (page 6).

Kept, tuned, or cut

A detector that floods gets precision levers and is re-measured. One that adds nothing is removed — not shipped default-off.

DocGuard
05 — The research

Built from papers, then measured on real repositories

The change-aware detectors are not inventions. Each implements a published result. Each also needed a precision lever the paper never required before it could run unattended in someone else's CI.

DetectorPublished basisWhat was takenWhat had to be added before default-on
Diff-SuspicionOutdated-comment detection, arXiv 2010.01625A fixed rule reached F1 74.7, beating every post-hoc neural model: prose that shares tokens with a deleted part of the diff is suspect. Applied to docs, not comments.Two signals must both hold (the doc references the changed file and shares its removed symbols); a generic-token filter; a per-doc cap. See Fig. 4.
Reference-ExistenceTwo-revision symbol check, arXiv 2212.01479A backticked symbol that existed when the doc was last updated but is gone at HEAD marks the doc outdated. Field tests reached roughly 50% maintainer acceptance.CLI flags excluded, two-revision gate required: the two documented false-positive modes of the source method.
API-Doc-SmellsAPI-documentation smell taxonomy, 1,000-unit benchmarkThe two smells with strong deterministic detectors: Bloated (F1 0.90) and Lazy (F1 0.95), based on documentation length per signature-headed section.The three semantic smells that need a BERT model were left out on purpose and routed to staged agent judgment instead.
Finding labelsTRACE — calibrated explainability, IEEE TMLCN 2026The HIGH / MEDIUM / LOW vocabulary, used as deterministic strata (a validator's check pass-ratio).A plain statement that the strata were never calibrated against outcomes. DocGuard measures precision instead (page 6).
Doc generationAITPG — multi-agent debate + RAG, IEEE TSE 2026The staged prose pattern behind generate and diagnose: the CLI structures, the agent writes, the validators check.Nothing generated is trusted: every source=code section is re-checked on the next run.

And the paper that argues against the whole idea

Evaluating AGENTS.md (arXiv 2602.11988, revised June 2026) found that repository context files did not generally improve agent task success in its evaluated settings. They also increased inference cost. The study also found agents generally followed the instructions they were given.

DocGuard's README cites this study in its own “Why” section and says plainly that the results do not establish DocGuard's effectiveness. They led to two changes. The tool keeps context short (retired plans leave the tree; memory packs task-specific context, not everything). It also measures outcomes instead of assuming them.

Diff-Suspicion on one real route-inventory doc · v0.31 sweep raw rule 45 findings — unreviewable + subject binding path/module refs only + filter + cap capped a reviewable set, zero verified false positives

Fig. 4 — Why a paper's F1 is the start, not the end. The same rule, three levers later.

The recall-maximizing variants of these detectors were built, tested, and rejected: a false-positive flood destroys trust faster than a miss does.

VALIDATION.md · “What we do not claim”
DocGuard
06 — The measurement

The number comes with its n, or it does not ship

Most tools publish an accuracy figure. DocGuard publishes a frozen benchmark, the cases behind it, the confidence interval, the caveat, and a loader. The loader refuses to quote the number if anyone edited any of those by hand.

1.000
finding precision · 12 expected findings, 0 unexpected
Wilson 95% · 0.757 – 1.000
0.000
false-positive rate on 12 clean controls
Wilson 95% · 0.000 – 0.243
0.7%
of 671 real-world findings carry any benchmark evidence at all (5 of 671)
14 repositories · disclosed, not hidden
12 defect cases · 12 clean controls · 12 repository groups · 12 causal families defect 12 found control 12 quiet per-detector cells are small: security n=20 · structure n=2 · architecture n=0 (null)

Fig. 5 — The frozen corpus, benchmarks/baseline.json. Every dot is a retained case the loader recomputes from.

The caveat, verbatim from the envelope — the loader rejects the file if this text is changed
Benchmark precision on a deliberately balanced corpus of 12 defect and 12 clean-control cases … This is DocGuard's precision on labelled cases, not the probability that a finding in your repository is real; quote every ratio with its n and Wilson 95% bound.

DocGuard does not publish a calibration document. The real base rate of a stale claim is nowhere near the corpus's 50/50 split, so a probability taken from this corpus would mislead. The README says so in the same paragraph that cites the number.

Three mechanisms that keep the number honest

Fail-closed loader

The baseline is an envelope of retained cases plus derived ratios. The loader recomputes every ratio from the cases and refuses an envelope if someone edited its numbers, caveat or measure by hand. A test covers each rejection path. TestGuard probes that nobody can remove the guard silently.

Adjudication record

The corpus could only take in a false positive that was already fixed. So a disagreement the maintainers reviewed and declined left no trace, and “precision 1.0” described the contribution pipeline, not the detectors. An adjudication row now records the disagreement and leaves the measurement intact.

Feedback samples the unmeasured

docguard feedback used to sample only findings that the confidence label already doubted. So the channel meant to test the label sampled nothing it could learn from. It now selects “unmeasured code, or low confidence”, and the command says what it left out.

“Precision 1.000” is true, and it is a claim about twelve labeled cases. The tool is built to stop that sentence from ever being shortened.

specs/007 · Independent Precision Evidence Loop
DocGuard
07 — Field reports

Field reports become tests, not tickets

More than a hundred releases in under eight months. What fed them matters more than the pace. Each report from a real working session became a regression test with a control. Agents wrote most reports after they hit friction on a real tree. The control asserts the behavior before the fix, so a later change cannot silently break it again.

MarAprMayJunJulAugSep v0.1.0first release v0.19 · May 26Canonical-Sync: the toolstarts auditing its own README v0.31–0.32 · Julyresearch batch; six-reporead-only sweeps v0.37–0.42 · Sep 14–18R1–R9: lifecycle, benchmark,evidence, channels — 4 in a day v0.27 · Jun 19LLM field report #3:findings architecture, group-A FPs v0.29 · Jul 3report #6: a wrong “16 extractors”shipped past a green guard Sep 17–22reports 0415 / 0420; and thetool's own README (below) 195 test files · 2,085 tests at v0.42.0 → 297 test files · 4,282 tests at v0.46.0 · Node 18 / 20 / 22 / 24 on every push

Fig. 6 — Blue above the line: capability. Clay below: something real broke, and became a test.

Dogfooding, including the part that went wrong

DocGuard guards its own repository on every push. guard, score, diff, badge and the packed npm tarball run without installed dependencies. A machine checks the count claims in its README. Its sibling, TestGuard, probes its claims with planted faults. This habit found three things:

found · v0.32

The semantic-claim extractor ignored .docguardignore; an excluded audit contributed 28 of 39 “unverified claims”. Fixed; the count fell to 12 — and one of those 12 was real drift, a stale suite-runtime claim in TEST-SPEC.md.

found · v0.32

REF002 flagged DocGuard's own source: doc comments used realistic ADR-012 examples and fixtures cited ADRs. The fix skips tests and fixtures and uses placeholders without digits, such as ADR-NNN. It shipped with zero self-findings.

missed · Sep 22

The README said “33 tests” from March 15 through all 92 releases while the suite grew past 2,000. Every self-guard stayed green. Metrics-Consistency had computed the test count since v0.8.2 and never compared it to anything. A human found it, not the tool.

What the fix could and could not do — PR #448
declared test cases (static, AST)   1,721     reported by node:test   2,085
// loops generate cases a static count cannot see — so the static number is a FLOOR.
MET003 flags a documented count below the floor (stale for certain) and passes anything above it.
It carries no mechanical fix: writing the floor would replace a stale number with a wrong one.

A green self-guard proves the existing checks passed, not that the right checks exist. This page tells the honest version: a half-built check, a human reader, and a lower-bound design that refuses to guess. That is why page 10 covers the limits.

DocGuard
08 — What 0.43 and 0.44 add

From checking the map to governing how it changes

Through 0.42, DocGuard asked one question: do the docs still match the code? Versions 0.43 and 0.44 add more questions. Which section should a change have touched? Did a feature go through its spec first? What must an agent read? Did the tool get slower or noisier? Fifty-one specs (014–064) were written, planned and tasked before their code. Thirty-four carry TestGuard claims probed with planted faults.

51
specs delivered through the Spec Kit pipeline since 0.42
specs/014 – specs/064
55%
smaller MCP guard response: each fact once, nothing lost
spec 037 · budget fixture
10%
growth in agent-facing bytes or package size before a PR must state a reason (guard time: 15%)
spec 031 · every PR
3,281
tests on Node 18, 20, 22 and 24 at v0.44.0
npm test
AreaWhat changedWhy it matters
Docs know
their code
A section declares the code it describes (covers=); a reviewed fingerprint lock names the section to re-read when that code changes. Module and entity diagrams are drawn from code.Freshness said a review was due somewhere. This says which paragraph, and why.
Spec first,
enforced
A spec-first gate classifies each change to governed paths as covered, exempt or uncovered. Completions record the reviewed revision and survive squash merges. As-built specs describe older code.“We follow Spec Kit” becomes a checked property of the history, not a habit.
Agents read
less, better
MCP doc tools answer which docs describe this file and return one bounded section. Path-scoped rules report which instruction files each harness loads for a path.The AGENTS.md study on page 5 measured cost; these cut what an agent must read to find the rule that applies.
The tool
measured
Budgets run base and head side by side on every PR. An install older than 14 days tells the agent so — from its own CHANGELOG, no network call — and names docguard upgrade.A guard that slows down or grows noisier erodes trust the same way drift does.
Reads real
projects
Served routes for every framework it detects, NestJS to ASP.NET Core; unreadable paths counted, never guessed.Gaps found on ten real repositories, closed by specs 040–064.
Exceptions
explained
Ignore entries carry a reason and an expiry; docguard ignore lists every suppression.A suppression now says why, and until when.
kept · a promise with a test

The compact guard response was meant to lose nothing. A reconstruction test reads every field back and caught the first draft dropping validator messages.

held back · measured

The symbol map ships opt-in. A frozen 54-trial benchmark found no regression but no benefit on navigation tasks. Steps were unchanged and latency was 6% lower, against a 15% bar. So it stays off by default.

Every feature in these releases started as a written spec.

specs/014 – specs/064 · testguard.claims.json
DocGuard
09 — What 0.45 and 0.46 add

From governing change to proving every verdict

Through 0.44, a green line meant the check found nothing. Versions 0.45 and 0.46 make it say what it looked at. It records which function a requirement lives in, and whether a check could see what it needed. AWS AI-DLC and DORA ideas were rebuilt, not copied.

22
specs delivered through the Spec Kit pipeline since 0.44
specs/070 – specs/092
6
closed verdicts; “could not look” is never a pass
spec 081 · every validator
0
findings lost across 45 real projects, release against release
hermetic A/B · v0.45.2 → 0.46
4,282
tests on Node 18, 20, 22 and 24 at v0.46.0
npm test
AreaWhat changedWhy it matters
Requirements
in the code
An @implements tag anchors to the function under it, and turns suspect when that code or the requirement changes.Traceability that knows which function, not just which file.
Every check
decides
Each validator ends in one of six verdicts. A git call that fails is a recorded gap, never a finding.“Could not look” stops reading as “looked and found nothing”.
Checks you
grow into
New checks start advisory. docguard policy shows which ones CI history says are ready to promote. Suppressions name an owner and an end date.Stricter over time, on evidence from your own runs.
Chains and
decisions
Requirements must reach tasks; ADR supersession must run both ways; authoring guidance comes from the registry the validators read.The tool’s own skill had told agents to write a section its checker rejected.
AWS AI-DLCReads AI-DLC’s records and memory; a plugin sensor fails a gate on drift the stage introduced, not drift it inherited.A gate that fails on old warnings gets switched off.
DORA
evidence
score --dora maps DORA’s documentation items and AI capabilities to repository evidence.DORA found documentation multiplies what every practice pays back.
Releases
compared
Each release is compared with the last, finding by finding; nineteen parsers are fuzzed on every run.A batch of fixes cannot quietly change what users see.
found · by its own fuzzer

A 265 KB line of HTML comments took the comment reader 9.7 seconds. Now under a millisecond, with identical output.

kept honest · advisory first

The release A/B added 159 findings across twelve projects, all advisory: listed, never counted against an exit code.

A check that could not see is not a check that passed. Since 0.46, DocGuard says which one it was.

specs/070 – specs/092 · CHANGELOG.md
DocGuard
10 — Limits and fit

What it does not claim

  • No recall guarantee. Precision-first means some real drift is missed by design. The variants that caught more were tested and rejected because they also flooded.
  • No judgment of prose. DocGuard never auto-decides whether a paragraph is true. Exact declarations in .docguard-evidence.json can verify selected statements; every other statement stays unverified, and the badge prints how many.
  • No calibrated probabilities. HIGH / MEDIUM / LOW are deterministic strata. The one number DocGuard measures is precision on labeled cases, with n and a bound, and a caveat that cannot be deleted.
  • Not proof that context helps. The README cites the AGENTS.md study on page 5 because it cuts the other way. DocGuard offers a way to find out on your repository, with outcomes measured.
  • Soft by default. The research-backed detectors ship as low-confidence warnings. Exit code 2 still fails an ordinary shell step; the severity policy is yours.
  • A maturity score is not a verdict. 100/100 means the map is whole; only guard says whether it is true. Nor is score --dora a DORA survey.

Where it fits

AlongsideWhat that doesWhat DocGuard adds
GitHub Spec KitGenerates feature specs, plans, tasks — spec → code, once.Governance after generation: drift tracking, lifecycle (retire what shipped), spec-quality checks. DocGuard is an official Spec Kit community extension.
AGENTS.mdOne instruction file: build, test, style.AGENTS.md is one of the required files. DocGuard validates it, packs task-specific context from the canonical docs, and keeps every agent on the same map.
Kiro · Cursor rulesIDE-bound spec or rule files.Portable across any IDE and any agent; enforced in CI rather than read by one editor.
AWS AI-DLCA gated lifecycle where agents write each stage’s artifacts.A plugin sensor that fails a gate on new drift; reads AI-DLC’s records and memory.
TestGuardBreaks a promise on purpose and asks whether a test noticed.The other half of the same question: whether the documentation of that promise is still true. They share an evidence format, and TestGuard fault-probes DocGuard's own claims in CI.

Three more things that follow from it

Ships widely, sends no data

npm and PyPI packages with provenance attestation, Homebrew, a GitHub Action, a Docker image, an MCP server and Claude Desktop bundle, a Spec Kit extension. No telemetry, no network at validation time.

Evidence, not output

JSON, SARIF and JUnit carry all five channels on every finding. The badge prints the unverified-claim count next to the check count. The benchmark envelope includes its cases.

Built for AI-written code

When an agent writes both the code and the docs, the typical failure is confident, plausible documentation of a system that no longer exists. A deterministic comparison against the tree can catch it.

A score tells you the map is complete. DocGuard tells you which parts of the map still match the territory — and which parts it cannot tell.

github.com/raccioly/docguard · npm docguard-cli · MIT · Ricardo Accioly