Configuration

DocGuard is configured via .docguard.json in the project root. If no config file exists, sensible defaults are used with auto-detection.

Full Reference

{
  "projectName": "my-project",
  "version": "0.6",
  "profile": "standard",
  "projectType": "webapp",

  "requiredFiles": {
    "canonical": [
      "docs-canonical/ARCHITECTURE.md",
      "docs-canonical/DATA-MODEL.md",
      "docs-canonical/SECURITY.md",
      "docs-canonical/TEST-SPEC.md",
      "docs-canonical/ENVIRONMENT.md"
    ],
    "agentFile": ["AGENTS.md", "CLAUDE.md"],
    "changelog": "CHANGELOG.md",
    "driftLog": "DRIFT-LOG.md"
  },

  "projectTypeConfig": {
    "needsEnvVars": true,
    "needsEnvExample": true,
    "needsE2E": true,
    "needsDatabase": true,
    "testFramework": "vitest",
    "runCommand": "npm run dev"
  },

  "validators": {
    "structure": true,
    "docsSync": true,
    "drift": true,
    "changelog": true,
    "architecture": true,
    "testSpec": true,
    "security": true,
    "environment": true,
    "freshness": true
  },

  "severity": {
    "security": "high",
    "todoTracking": "low"
  },

  "collections": {
    "extractors": "src/extractors/*.py",
    "commands": "cli/commands/*.mjs"
  },

  "docs": {
    "dirs": ["reference", "website/docs"]
  },
  "findingSeverity": {
    "TRC004": "low",
    "SEC001": "high"
  },
  "ignore": ["generated/"],
  "securityIgnore": ["tests/fixtures/"],
  "suppressions": { "requireReason": false },
  "requiredChecks": ["apiSurface", "traceability"]
}

requiredChecks names the validators the project depends on. Each must reach a decision (verdict pass or fail) in every run. A validator that found nothing to judge, could not decide or could not run makes guard exit 4 and ci block (CI_REQUIRED_CHECK_UNDECIDED). A reasoned in-repo <!-- docguard:validator <key> n/a — reason --> marker is the only bypass. DocGuard reports disabling a required validator in config as REQ001, and an unknown key as REQ002. docguard policy shows which advisory codes this project’s CI history shows are ready to promote with findingSeverity.

Enforcement mode

enforcement selects how strictly guard judges the project (spec 097, docguard.strict-by-default). It is a string or an object, and it is separate from profile, which only says what kind of project this is:

{ "enforcement": "strict" }
{ "enforcement": { "mode": "strict", "asOf": "0.47" } }
  • strict: every validator that applies to the project must examine something. Suppose a validator applies and performs no check. Its cause is needs-declaration or needs-content (a declaration or a document the project can write). Then it makes guard exit 4 and ci block (CI_STRICT_UNEXAMINED), unless a reasoned waiver covers it. So does a validator that could not observe at all (blocked, or inconclusive with zero checks). A validator that does not apply is skipped, with what it looked for as the reason. A validator that performed at least one check and could not read the rest (some routes unreadable, an optional parser absent) is inconclusive. A cause of layout-not-recognized is a limit of DocGuard. A cause of history-unavailable means the check ran in a shallow clone (the one-commit default of actions/checkout), which lacks the git history the check reads. The fix is to fetch it (fetch-depth: 0). A cause of language-not-supported means the validator read a document in a language DocGuard has no rules for. DocGuard takes the language from docs.language, or from the document’s own name: <name>.<lang>.md, i18n/<lang>/, locales/<lang>/. It says which language and what to add: a <!-- docguard:heading <id> --> marker or a docs.labelAliases entry for a label. Nothing is needed for a check that reads English prose (Docs-Diff’s tech stack, Metrics-Consistency, semantic claims). None of these changes the exit code. DocGuard lists all of them after the Adopt block under “DocGuard could not read”. Each entry says what was missed and, for a layout, the layouts the validator does read. --fail-on-inconclusive still makes a project that asks for it exit 4. When the run exits 1 or 4, an Adopt block lists four things in order. First comes the fix for each unexamined validator. Then comes docguard guard --update-baseline. Then comes the waiver form with owner: and expires:. Last comes the key that selects the lower mode.
  • standard: the behavior before the default changed. No exit code changes.
  • Absent: strict. A project that has not chosen a mode is checked in full. profile never selects the mode: the stored value profile: "standard" is a project shape, not a choice of strictness. Every run states the mode and where it came from on the first line of its summary. --format json carries enforcement: { mode, asOf, source } (source is default or config). If your build turned red after upgrading, see Upgrading to Strict.

Under strict, --format json also carries strict: { evaluated, unexamined[], couldNotRead[], blocking[], gating[], pending[], waived[], ignoredDisabled[], baselined }. ignoredDisabled lists the validators.<key>: false entries strict did not honor (keys only in the compact form). Each unexamined entry is { validator, name, verdict, cause, reason, howToConfigure, newIn, blocking, documents? }. Each couldNotRead entry is { validator, name, verdict, cause, reason, layouts?, documents?, howToConfigure? }. reason is what the validator could not read. layouts (an unread layout only) lists what it does read. The compact form keeps the keys and a short reason. documents lists the agent-instruction files Freshness did not examine while it examined others (the validator’s own unexaminedDocuments). A file is in unexamined when the review no longer covers it, or when a root instruction file has no review record. That blocks. A file is in couldNotRead when it is any other file with no recorded review (a last-reviewed marker alone may be its vendor’s). That does not block. The compact form gives documents as a count. cause is one of needs-declaration, needs-content, layout-not-recognized, nothing-of-this-kind, history-unavailable or language-not-supported, or null. history-unavailable means a shallow checkout. It is listed under couldNotRead and never blocks. language-not-supported means a document in a language without rules. It is listed under couldNotRead with language, one entry per validator, and never blocks. null means the validator could not observe its input (it is inconclusive, and reason is the gap). Only the first two causes, and a validator that could not observe at all, are in unexamined. --changed-only runs a subset of the validators, so it does not evaluate the rule and says so.

asOf ("<major>.<minor>") holds a project at the strict set of that release. Every validator is listed under 0.48, so "0.47" keeps today’s exit codes and prints the strict report beside them. A validator or gating code the release table lists under a later version is reported as pending and does not change the exit code. Without asOf every item applies, and one added in the running release or the one before it is labeled “new in vX.Y” when it fails.

Under strict every registered validator runs, whatever the profile’s validators block or your own file says. A "validators": { "<key>": false } entry does not switch a validator off under strict. Nearly every such entry was written by docguard init from a profile, not chosen by a person. Honoring it would exempt existing projects from the checks the default is meant to give them. Guard says in one line, on every run, which entries it did not honor. To switch a validator off on purpose, use a reasoned waiver (<!-- docguard:validator <key> n/a — <reason> owner:<@handle> expires:<YYYY-MM-DD> -->) or "enforcement": "standard", under which the validators block works as it always has.

docguard init writes no enforcement key by default. docguard init --enforcement strict|standard writes it. The interactive setup asks once and writes the key only for the non-default answer. docguard upgrade reports, read-only and without writing, what the default changes for the project. It lists the validators that now fail with cause and fix, and the items only reported. It also lists the three ways forward (fix or declare, waive with reason, owner and expiry, or set "enforcement": "standard").

requiredSections adds sections a document must carry beyond the canonical ones STR003 checks, keyed by file. A bare name such as SECURITY.md means the canonical document:

{ "requiredSections": { "SECURITY.md": ["Threat Model"] } }

A missing heading is reported as STR007, informational until a project promotes it with findingSeverity. A reasoned <!-- docguard:section threat-model n/a — reason --> marker owns the absence. The enterprise-ai profile sets Risk Assessment and Threat Model for SECURITY.md (spec 082).

Profile Field

The profile field sets a baseline preset. User config overrides profile defaults.

Profile Description Validators Enabled
starter Minimal CDD — ARCHITECTURE + CHANGELOG structure, docsSync, changelog
standard Full CDD — all 5 canonical docs (default) Most validators
enterprise Strict — all docs + all validators All validators + freshness

See Profiles for details.

Validators

Validator Default What It Checks
structure true docs-canonical/ exists, required files present (STR001, STR002, STR004, STR005)
docSections follows structure Each canonical doc has its expected sections (STR003). DocGuard reports it as its own result, with key docSections and parent: "structure". Until a config names docSections, validators.structure, severity.structure and a structure N/A marker apply to it as before
docsSync true AGENTS.md references DocGuard workflow
drift true DRIFT-LOG.md exists and has entries when code deviates
changelog true CHANGELOG.md has [Unreleased] section, version entries
architecture varies Component map, layer boundaries, import graph analysis
testSpec true Test framework, coverage, critical flows documented
security varies Auth, secrets, RBAC documentation
environment true Setup steps, env vars, prerequisites, .env.example
freshness varies Docs updated recently relative to code changes (git-based)
suppressions true .docguardignore entries that expired (IGN001), cannot be read (IGN003), or have no reason while suppressions.requireReason is set (IGN002)
aidlc true AWS AI-DLC records after the workflow. It reports traceability targets that no longer exist, gaps left in completed stages, and unit deliverables removed later. It also reports unreadable records (AID001–AID004, informational by default)
decisionRecords true ADR status, supersession links and index rows, and unanswered Spec Kit clarifications or [Answer]: tags (DEC001–DEC006, informational by default)
requirementAnchors true Reports these findings. Reviewed code→requirement links whose code (ANC001) or requirement (ANC002) changed. Reviewed links whose tag is gone (ANC003). An unreadable anchor lock (ANC005, error). Tags that cite an undeclared (ANC007) or retired (ANC008) requirement. Files read below their exact tier (ANC010). Not applicable until .docguard-anchor-lock.jsonl exists or anchors.enabled is set

Severity overrides

severity.<validator> changes a validator’s exit-code weight without hiding anything from display. "high" promotes its warnings to blocking (CI fails). "low" demotes them (shown, but never fail the build). Valid values: high | medium | low. To silence a validator entirely, use validators.<key>: false.

findingSeverity.<CODE> applies the same enforcement levels to one stable finding code and takes precedence over the validator setting. This is the preferred control for a noisy rule because neighboring findings retain their policy. Intrinsic errors remain blocking unless their exact code is configured. A few codes are informational by default (STR005); validator severity leaves them informational, and findingSeverity.<CODE> can still promote them. Machine outputs preserve severity and add effectiveSeverity plus the enforcement source so audit consumers can distinguish detection from policy.

Test files — testPatterns

DocGuard finds test files named *.test.* or *.spec.* on its own. When yours follow another convention, list globs for them:

{ "testPatterns": ["test_*.mjs", "tests/**/test_*.py"] }

testPattern (one string) is the older form and is merged into the list. The patterns apply to both sides of Test Files drift (DDF002). Files on disk that match are tests. A backticked name in TEST-SPEC.md that matches is a documented test. A bare file name such as test_bot.mjs is compared with the pattern’s last segment, so tests/**/test_*.py accepts test_api.py.

Collections — verify documented counts against code

collections binds a documentation noun to a glob whose file count is the source of truth. With "extractors": "src/extractors/*.py", a doc claiming “16 extractors” while the glob matches 19 files becomes a guard warning (and a fix --write-able correction). Declaring the noun is the opt-in — no other marker needed. Reserved nouns (checks, validators, tests) keep their built-in DocGuard meaning. An unresolvable glob is skipped, never treated as 0.

Document language — docs.language and docs.labelAliases

{
  "docs": {
    "language": "pt-BR",
    "labelAliases": { "requirements": ["Requisitos do sistema"] }
  }
}

docs.language is a BCP 47 tag. Absent (or "en") means English, byte for byte as before. pt and es ship built-in headings and words, matched by primary subtag (pt-BR, pt-PT, es-MX). Any other valid tag is accepted and has no built-in set. So a document that carries no marker and no alias for a required heading is reported as not read (language-not-supported), never as missing. docs.labelAliases is flat, keyed by label id. Each value is a list of strings that extends the built-in set and never replaces it. An invalid tag or key is reported and ignored. The ids, the <!-- docguard:heading <id> --> marker, what is skipped and why are in Documents in other languages.

Glossary — docs.glossary

A glossary gives each concept one name. Write it as a Markdown table with a Use column, an Avoid column and an optional Meaning column:

| Use | Avoid | Meaning |
|---|---|---|
| configuration | config, conf | The settings in .docguard.json. |
| spec | specification | A feature description under specs/. |

The Glossary validator reports each document that uses an Avoid term in prose (GLS001, a warning), with the line and the term to use. It reports a row it cannot read (GLS002) and two rows that contradict each other (GLS003). Without a glossary it reports GLS004 at the informational level, which does not change the exit code.

{ "docs": { "glossary": "docs/TERMS.md" } }

Without docs.glossary, DocGuard uses the first of docs/GLOSSARY.md, docs-canonical/GLOSSARY.md and GLOSSARY.md that exists. A file with no Use and Avoid table is read as a free-form glossary: DocGuard does not check terms from it and does not report it as malformed.

How terms match:

  • Whole words only. A hyphen joins words, so config does not match config-file.
  • Case does not matter, except for a term with a capital letter after its first letter (PR, GitHub), which matches exactly.
  • A single word also matches its plural with s or es. There is no other stemming.
  • An Avoid term inside a longer Use term is not reported: with Use Spec Kit, “Spec Kit” never counts as “spec”.

Not checked: code blocks, inline code, link targets, URLs, file paths, text in double quotes, blockquotes, HTML comments, and the headings DocGuard requires. Also not checked: the glossary itself, CHANGELOG.md, DRIFT-LOG.md, decision records, specs/ and agent-instruction files such as AGENTS.md.

Waivers:

Scope Marker
One line <!-- docguard:ignore GLS001 — reason --> on that line
One term in one document <!-- docguard:glossary allow config — reason -->
One document <!-- docguard:glossary off — reason -->
The validator <!-- docguard:validator glossary n/a — reason -->

To start a glossary:

  1. Run docguard init --with glossary. It writes docs/GLOSSARY.md with the table header. It lists proposed rows in an HTML comment, for example spec / specification when your documents use both, with each count. It never overwrites a file.
  2. Move each proposal you accept into the table.
  3. Run docguard fix --doc glossary to get a prompt for an AI agent that fills in the rest.
  4. Run docguard guard.

Plain writing — docQuality.sentenceLimit

Doc-Quality checks each sentence against a word limit from ASD STE100 (Simplified Technical English): 25 words in descriptive text and 20 words in a numbered step (DQ009, informational: it does not change the exit code). It reports one finding per document, with the first five long sentences by line and the count. DQ006 still checks the average sentence length.

{ "docQuality": { "sentenceLimit": 30, "stepSentenceLimit": 25 } }

It also reports numbered steps that do not start with a verb (DQ010, English only, informational). A step that starts with “The”, “You”, “Should” or a word that ends in “-ing” does not tell the reader what to do.

Scope Marker
One sentence or step <!-- docguard:ignore DQ009 — reason --> (or DQ010) on its first line
One document, a different limit <!-- docguard:quality sentence-limit 30 — reason -->
One document, off <!-- docguard:quality sentence-limit off — reason -->, <!-- docguard:quality step-verbs off — reason -->

Documentation homes — docs.dirs

Conventional doc folders (docs/, doc/, documentation/, guides/, handbook/, manual/, wiki/, Docusaurus website/docs/, …) are auto-detected and claim-scanned without enrollment. docs.dirs EXTENDS that set with non-standard homes — it never replaces auto-detection. To exclude a conventional dir, list it in .docguardignore.

Excluding paths — .docguardignore

.docguardignore, at the project root, lists paths no validator should read. One pattern per line, gitignore-style. # at the start of a line is a comment, and blank lines are skipped. A pattern matches at a path-segment boundary at any depth (fixtures/ excludes fixtures/ and packages/a/fixtures/).

Pattern syntax, shared by .docguardignore and every .docguard.json array below:

Syntax Meaning
* Any characters except /
? One character except /
[abc], [a-z], [!abc] / [^abc] One character from (or, negated, not from) the set; never /. An unclosed [ is a literal [. POSIX classes such as [[:alpha:]] are not supported
**/ at the start or after / Zero or more directories: **/fixtures/** excludes fixtures/x and a/fixtures/x; a/**/b excludes a/b and a/x/y/b
/** at the end Everything inside
Any other ** (a**) Any characters, / included
\x The literal character x (\*.md is the file *.md)
Leading / Anchors to the project root: /build excludes build/ but not src/build/
Trailing / Dropped: dir/ also excludes a file named dir
Anything else Literal, including ( ) + ^ $ \| { } . (no {a,b} alternation)

Unlike gitignore, a slash in the middle does not anchor (docs/old also excludes site/docs/old). A leading ! is a literal character: negation is not supported. Before v0.44, ?, [, (, +, | and the other regular expression characters were passed through unescaped. So a|b was read as an alternation and excluded unrelated paths. An unclosed [ made the checks that read the ignore list fail with a regular-expression error. And **/x did not match a top-level x. A pattern without those characters and without **/ matches exactly what it matched before.

An entry can say why it exists and when it ends:

# pattern            [expires:YYYY-MM-DD]   [# reason]
build/                                      # generated output of the build
src/legacy/**        expires:2026-12-31     # removed with the v2 API
docs/archive/
  • Reason. Text after a # that follows whitespace. A # inside a pattern (C#/, notes#1.md) is still part of the pattern.
  • Expiry. expires:YYYY-MM-DD as the last word before the reason. The entry applies through the end of that day (UTC). From the next day it excludes nothing, and guard reports IGN001 so you can renew or delete it.
  • Unreadable expiry. Two cases exclude nothing. One is a date that is not a real YYYY-MM-DD day (for example expires:2026-02-30). The other is a line with an expiry or reason and no pattern. DocGuard reports both as IGN003, because it cannot tell when the exclusion should end.

A line with no whitespace-then-# and no trailing expires: word means exactly what it meant before v0.44. One that has them was read before as a pattern containing that text, which matched nothing.

To require a reason on every entry:

{ "suppressions": { "requireReason": true } }

Guard then reports IGN002 for each entry without one. The entry still applies. Raise it to blocking with "findingSeverity": { "IGN002": "high" }.

.docguard.json has its own arrays. ignore applies to every validator (merged with .docguardignore at load). securityIgnore applies to Security only, and todoIgnore to TODO-Tracking only. documentLifecycle lists paths the Document-Lifecycle check skips when it looks for terminal-status documents and completed specs. They hold plain patterns, or objects that carry waiver metadata (spec 084): { "pattern": "vendor/**", "reason": "third-party", "owner": "@ops", "expires": "2027-01-01" }. An expired object entry applies to nothing. suppressions.requireReason does not apply to them.

Every other kind of suppression can carry the same metadata at the end of its reason: // docguard:ignore SEC001 — rotating key in #812 owner:@ana expires:2026-12-31, <!-- docguard:validator apiSurface n/a — CLI only owner:@ana expires:2027-06-30 -->, and .docguardignore lines (dist/** # build output owner:@ops). An expired suppression of any kind stops suppressing the day after its date (UTC). Two policies make waivers accountable, and neither disables a suppression:

{ "suppressions": { "requireOwner": true, "maxDays": 90 } }

requireOwner reports IGN004 for a waiver with no owner:; maxDays reports IGN005 for one that expires later than the window, or never. With either set, guard also reads inline pragmas across the project to report expired ones (IGN001); that full read is skipped otherwise. Baseline fingerprints are exempt.

docguard ignore lists every suppression the project has, including inline pragmas, N/A markers and the baseline, with its reason and state. docguard ignore --format claimspec exports the reasoned .docguardignore entries as a claimspec ignore document (commands).

Directories skipped without configuration

DocGuard’s file walkers skip dependency and build-output directories by name, at any depth, with nothing in .docguardignore (DEFAULT_IGNORE_DIRS in cli/shared-ignore.mjs):

  • dependencies: node_modules, vendor (PHP, Go), .venv, __pycache__;
  • build output: dist, build, out, coverage, target (Rust, Maven), .gradle, obj (.NET, C), _build (Mix, dune, Sphinx), cdk.out;
  • framework caches: .next, .nuxt, .svelte-kit, .turbo, .vercel, .cache;
  • version control: .git, .jj, .hg, .svn.

A bin directory is skipped only when the directory holding it also holds a .NET project file (*.csproj, *.fsproj, *.vbproj). There it is build and publish output. Every other bin/ is read, such as a Node CLI’s bin/cli.js, Ruby binstubs or shell scripts. To skip a directory this list does not name, add it to .docguardignore.

Adoption baseline — baseline

When a committed .docguard.baseline.json exists (written by docguard guard --update-baseline), guard/ci suppress the frozen findings and gate only new drift. Set "baseline": false in .docguard.json to ignore the file entirely (same as always passing --no-baseline):

{ "baseline": false }

Suppression is always visible in output and in the baselineSuppressed JSON field — nothing is silently hidden.

A finding is matched by a fingerprint: its code, its file path without the line number, and its message with every number masked. Text that changes when unrelated files change is left out too. Today that is one case: the ` — IR soft-match: (N% similar) may already cover it` hint at the end of a TRC004 message, which names whichever test file currently matches best. Adding a test file therefore never brings back a baselined TRC004 finding. A baseline written before v0.44 still matches the findings it froze until a hint changes, and `guard --update-baseline` rewrites it in the new form.

Muting a validator

Two ways to turn a validator off, for two different intents:

Intent How Renders as
Operational toggle (CI speed, not relevant right now) .docguard.json → "validators": { "testSpec": false } silent — disabled
Intentional non-applicability (POC with no tests, library with no auth) inline marker in a canonical doc or AGENTS.md:
<!-- docguard:validator testSpec n/a — POC, no automated tests yet -->
➖ Test-Spec [N/A] (declared N/A: …) — visible, git-tracked

Use the marker when the validator does not apply. The reason stays next to the declaration, travels with the repo, and shows as N/A instead of a hidden skip or a fake green check. The key is the validator key from the table above (case and separator do not matter, so test-spec works too). DocGuard reports a mistyped key as a warning and does not ignore it silently. A POC with no tests usually marks both testSpec and traceability N/A.

Spec-first gate — specFirst

docguard specs require (and the Action’s command: spec-first) fails a change to a governed path that neither names its spec nor declares an exemption.

{
  "specFirst": {
    "paths": ["cli/**", "src/**"],
    "exemptKinds": ["release", "deps", "typo", "test-only"]
  }
}
  • paths: glob patterns of governed paths. Default: every changed path except Markdown, specs/** and recognized test files.
  • exemptKinds: the kinds accepted in Spec-Exempt: <kind> — <reason>. The reason is required and must be at least 10 characters.

Agent instruction budget — agentInstructions

Agents stop reading instructions at a byte limit (Codex: project_doc_max_bytes, 32 KiB). STR004 reports an AGENTS.md chain (root down to a directory; AGENTS.override.md replaces AGENTS.md) over the budget. STR005 reports an allowance that has slack to reclaim. It is informational: it never changes guard’s exit code unless findingSeverity.STR005 says so.

{
  "agentInstructions": {
    "maxBytes": 32768,
    "allowances": { "packages/big/AGENTS.md": 40000 }
  }
}

allowances freezes existing debt per chain, keyed by the chain’s deepest instruction file: the chain may shrink, and growth past the allowance is reported.

File kinds — fileKinds

Some files in a repository are not the project’s own work. A scaffolder’s templates/<app>/files/AGENTS.md is a form written into other repositories. A fixtures/ project is test data. vendor/ is someone else’s code. DocGuard asks one question, “is this file the project’s own”. It answers from a closed list of kinds: own, template, fixture, test, vendored, generated, backup and nested-checkout.

  • Unknown is own. Classifying a file as a copy removes it from checks, so a file nothing recognizes stays the project’s.
  • Directory names match as whole path segments, in any case (Templates/, EXAMPLES/). They match only before the first segment that starts with .: .claude/skills/templates/ holds files the harness loads. A package segment never counts (src/main/java/com/example).
    • template: templates, template, _templates, __templates__, scaffold(s), boilerplate(s), starter-kit(s), skeleton(s)
    • fixture: fixtures, __fixtures__, testdata, __mocks__, mocks, examples, samples, corpus, golden and the other test-data names
    • test (the project’s own tests): test, tests, __tests__, test-helpers, spec, specs; a Spec Kit specs/012-feature/ is own
    • corpus and golden mark copies for instruction files only: detection (routes, Security’s test-path context) still reads them as product
    • vendored: node_modules, vendor, vendored, third_party; generated: dist, build, out, coverage, target, generated
  • The folder that holds the file does not count for a file that describes its own folder, an agent-instruction file. templates/AGENTS.md governs templates/, and packages/templates/AGENTS.md governs a package.
  • Backups apply to documents only (ARCHITECTURE copy.md, ARCHITECTURE-old.md, *.md.bak, or a document below archive, backup, old or deprecated inside docs/), never to code. A backup is read as no document. It is not a canonical document. Freshness does not review it. Cross-references are not read from it. docguard llms does not list it. It never stands in for a missing role document. A backup-named document in a documentation directory is STR008. A document in an archive folder is left out without a warning.
  • Nested checkouts. A directory below the root that holds its own .git is another project’s files and is never walked. Security is the one reader that still scans one: a secret in a copy is a leaked secret.
  • Where each reader asks. TODO tracking skips templates, fixtures and build output (out/, target/) like the other walkers. Reference-existence does not let a template, fixture, vendored or generated copy define the symbol a document names. The canonical-layout detection and the role hint never propose a document under a template, fixture, test, vendored, generated, backup or nested-checkout path.

fileKinds.own lists glob patterns for files that are the project’s own wherever they sit, such as a real package that happens to be called examples:

{ "fileKinds": { "own": ["examples/billing-sdk/**"] } }

.docguardignore and ignore still win and remain the way to exclude a file. Nothing is dropped silently. guard --format json carries files.kinds (a count per kind, and up to 20 paths per kind of instruction files and backup documents left out as copies). The text output prints one line when any were left out. PSR006 warns when a template or fixture copy shares a governing instruction file’s name. The instruction-chain budget (STR004) does not count a copy.

Mirrors

Some files are copies of one thing for different agent harnesses. They are the root instruction files AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md (the same set inside one nested folder is compared only within that folder). They are also a skill or command at the same relative path under different agent roots (.agent/, .agents/, .claude/, .codex/, .gemini/, .github/, .specify/extensions/<ext>/). A file with the same name in another folder is a different document, never a mirror.

  • Identical mirrors are one subject. A finding a check would raise on each copy is raised once, on the first path. The order is AGENTS.md, then CLAUDE.md, GEMINI.md, .github/copilot-instructions.md, and for skills the lexically first root. It names every path: mirrors on the finding in --format json, an also in: line in text. What each harness loads, and the budgets that count it, do not change. A pointer file (@AGENTS.md) and a symlink are not mirrors.
  • PSR007 (warn) fires when a skill or command copy differs from its mirror. It names both paths, how many lines differ and which was committed more recently (or says it cannot tell). Two Spec Kit installs for different harnesses differ by design and are not reported. PSR005 checks each against its install manifest.
  • PSR008 (warn) fires when two root instruction files share at least 80% of their non-blank lines but are not identical. So one can say npm where the other says yarn. Pointers and files written by docguard agents --sync are not compared (docguard agents --check does that). Files that are simply different documents share few lines and are never reported.

guard --format json carries files.mirrors (groups, identical sets and the drift list). GEMINI.md is read for dead pointers and @ imports like the other instruction files.

Path-scoped agent rules — validators.pathScopedRules

The Path-Scoped-Rules validator (PSR001–PSR008) is on by default and not applicable when the project has no agent instruction files. PSR003 uses the same agentInstructions.maxBytes for the bytes one harness loads for a path, excluding AGENTS.md chains (STR004’s). Its allowances are keyed by harness, either for every path ("claude") or for a group that contains a given path ("claude:src/web/app.tsx"):

{
  "agentInstructions": { "allowances": { "cursor:src/web/app.tsx": 40000 } },
  "validators": { "pathScopedRules": false }
}

Set "pathScopedRules": false to turn the check off. See docguard rules.

Spec Kit checks — specKit

{
  "specKit": {
    "phantomCheck": true,
    "untouchedClaimCheck": true
  }
}
  • phantomCheck: false disables SPK008/SPK009: checked tasks whose named deliverables do not exist and carry no implementation evidence.
  • untouchedClaimCheck: false disables SPK010/SPK011: checked tasks naming an existing path that no commit since the feature began changed. A named directory counts as changed when a file inside it changed.

Doc dependency lock — covers= and validators.docDependency

The Doc-Dependency validator is on by default but has nothing to check until a doc section declares the code it describes:

<!-- docguard:section id=pricing source=human covers="src/pricing.mjs#discount, src/rules/**" -->

docguard review --accept <doc>#<id> --reason "<what you checked>" records the review in .docguard-doc-lock.json (commit it). Set "validators": { "docDependency": false } to turn the check off. See docguard review.

Requirement anchors — anchors and validators.requirementAnchors

docguard anchors lists, in any project, what each @implements / @req tag anchors to.

Guard reports on anchors only once the project opts in. That means either a committed .docguard-anchor-lock.jsonl or this setting:

"anchors": { "enabled": true }
Key Default Meaning
anchors.enabled false Report ANC findings in guard before the project has an anchor lock
anchors.fanOutLimit 10 Most importing files docguard anchors lists as ripple for one changed anchor before it collapses them into a count
anchors.failOn reviewed-exact Which suspect (ANC001) and lost (ANC003) links fail guard. reviewed-exact fails only links that someone accepted as reviewed (never baselined ones). They must be at symbol, statement or route scope, read at an exact tier (Babel, python3 ast). File-scope and pattern-tier links warn, because they change on edits that leave the requirement alone. none makes every anchor finding a warning. A requirement-text change (ANC002) never fails. The default comes from a replay of 150 commits of this repository. In that replay, no commit that only changed formatting flagged an exact-tier link
anchors.import [] Also read strictdoc @relation(...) and openfasttrace [impl->dsn~name~3] tags as anchors. Read-only: DocGuard never writes them
anchors.importMap {} Foreign ID → requirement: "strictdoc:REQ-1": "acme.billing#FR-001", or "oft:dsn~refund": { "requirement": "acme.billing#FR-002", "revision": 2 } so an OpenFastTrace tag behind revision 2 is reported outdated (ANC001). An unmapped ID is ANC007
anchors.orphanPaths the scope.sourcePaths of current specs Where docguard anchors --orphans looks for untagged symbols: globs (src/**/*.go), files or directories. Nothing is listed when neither is set
anchors.treeSitter.artifacts unset The opt-in tree-sitter tier. Set runtime and runtimeWasm to the web-tree-sitter files. Set grammars to one .wasm per language (go, rust, java, csharp, php, ruby, c, cpp). Each file must match the sha256 that schemas/docguard-anchor-treesitter.manifest.json pins, which are the versions vetted in tools/anchor-oracle/VETTING.md. A missing or mismatched file is ANC010, and the pattern tier answers. DocGuard never detects this tier automatically
anchors.testguard.evidence .testguard/evidence.json The saved TestGuard evidence that docguard anchors reads to mark the tests of a changed requirement as re-verified. The path is project-relative. DocGuard reads it with the same reader as other evidence, which rejects symlinks and paths outside the project. DocGuard never runs TestGuard or a test
anchors.testguard.claims testguard.claims.json The TestGuard claims file. A claim counts only while its statement, source and fault set still match what was probed. Suppose the evidence says its claims came from outside the repository, and this key is not set. Then DocGuard reads no claims file (not even the default) and reports those two comparisons as not checked. Set the key to a local copy to compare
validators.requirementAnchors true Set false to turn the Requirement-Anchors validator off

See docguard anchors.

Doc ownership — ownership

Declares which doc section is responsible for which source paths. trace --reverse, review --suggest and the MCP tool docguard_docs_for_path report the owner, and the Doc-Ownership validator (OWN001–OWN007) keeps the map true.

{
  "ownership": {
    "roots": ["src"],
    "entries": [
      { "doc": "docs-canonical/ARCHITECTURE.md", "section": "component-map",
        "purpose": "What each module is responsible for", "paths": ["src/**"] },
      { "doc": "docs-canonical/DATA-MODEL.md", "section": "entities",
        "purpose": "The schema", "paths": ["src/db/schema.ts"] }
    ]
  }
}
  • entries[].paths: files, directories or globs. Each file has at most one owner. An exact path beats any glob. A longer literal directory prefix beats a shorter one. Any other overlap is a tie (OWN002).
  • entries[].section: a docguard:section id or a heading anchor in doc.
  • roots: directories whose source code must be owned (OWN001). By default, the top-level source modules, skipping test, fixture and example paths. A declared root is checked as declared.

DocGuard never writes this block; docguard trace --owners --suggest prints a draft. Without it (and without .devin/wiki.json) the validator is not applicable.

A committed .devin/wiki.json is linted against Devin’s documented rules (checked 2026-09-30): at most 30 pages, 100 notes and 10,000 characters per note. Set "devinWiki": { "maxPages": 80 } on an enterprise plan.

Code-derived diagrams — diagrams.moduleGraph

Shapes the module-graph section (see Diagrams drawn from code). All keys are optional:

{
  "diagrams": {
    "moduleGraph": { "depth": 2, "maxNodes": 30, "include": ["src"] }
  }
}
  • depth (1–8, default 2): directory segments that make a module, so src/api/routes.ts belongs to src/api.
  • maxNodes (2–60, default 30): the node limit before grouping and merging.
  • include: directories to draw. Default: every product source file.

The entity-diagram section has no options.

Symbol map budget — memory.symbolMap

memory --pack --symbols stops the symbol map at memory.symbolMap.maxBytes bytes (default 4096, between 256 and 16384), at a whole line. It states how many ranked files it left out. About 4 bytes stand for one token. The section is opt-in, and the agent-context benchmark kept it that way (benchmarks/agent-context/results/README-v3.md).

{ "memory": { "symbolMap": { "maxBytes": 4096 } } }

Project Type Detection

DocGuard auto-detects your project type from the manifest at the project root (package.json, pyproject.toml, requirements.txt, setup.py, Pipfile, Cargo.toml, go.mod, …). init, generate and a project without a .docguard.json all use the same detector:

Signal Detected Type
A Cloudflare Worker config api
bin field cli
next, react, vue, angular, svelte webapp
express, fastify, hono, koa, @nestjs/core api
main, exports, module library
django dependency or manage.py webapp (Django)
fastapi, flask or starlette dependency api
click or typer dependency cli
Web framework in Rust or Go (axum, actix-web, gin, …) api
clap (Rust) or a Rust binary crate cli
Any other package library

When the root holds two manifests (a Python service with a package.json for tooling), the one that names a framework wins.

Project Type Defaults

Type Env Vars .env.example E2E Database
cli ✗ ✗ ✗ ✗
library ✗ ✗ ✗ ✗
webapp ✓ ✓ ✓ ✓
api ✓ ✓ ✗ ✓

Existing documentation layouts

Use explicit document roles to check Markdown files in an existing layout. A mapping replaces the default path for that role and makes the mapped file required. It also adds the file to the canonical inventory. Missing files and content defects stay findings. You do not need project names or framework-specific paths.

{
  "docs": {
    "roles": {
      "architecture": "docs/design.md",
      "dataModel": "specs/data-model.md",
      "environment": "operations/setup.md",
      "apiReference": "reference/http.md"
    }
  }
}

Supported roles are architecture, dataModel, security, testSpec, environment, apiReference, and requirements. Paths must name Markdown files inside the project. DocGuard rejects private directories, parent traversal, absolute paths, and symlink destinations. Several roles can point to one document. Each role’s content checks still apply, and a mapping does not prove the content is correct. Default roles stay the same unless you map them.

Mapped paths use an explicit ownership contract for writes:

  • A missing mapped target may be generated when exactly one role maps to it.
  • An existing file with <!-- docguard:generated true --> grants DocGuard full-document ownership. Generation and mechanical whole-document repair keep their normal backup behavior.
  • An existing human document grants bounded ownership only through one unique, well-formed <!-- docguard:section id=<id> source=code --> region. generate --plan --write, sync --write, and section regeneration may replace that region while preserving every surrounding byte.
  • Missing, duplicate, nested, unclosed, or source=human markers reject the write before mutation. Several roles mapped to one file also reject whole-document generation.
  • --force never grants ownership and cannot bypass these checks.

Broad legacy scaffolding such as diagnose --auto remains unavailable for a mapped layout because it cannot select an operation-specific owned target safely. Read-only plans identify mapped destinations without requiring ownership markers.

The docs.dirs setting adds directories to the document inventory and opts them into freshness review. Being in the inventory does not mean every detector checks every file. Semantic extraction covers canonical Markdown, explicitly mapped Markdown roles, README, and AGENTS, within its safety and size limits. Other prose stays unverified.

Review signals and historical material

Freshness findings are low-confidence signals from repository history. They do not prove semantic drift, and they do not tell you to rewrite anything automatically. Review the intent and the implementation. Then record a review date or propose the code or document change.

Use an explicit historical, superseded, or deprecated status when a document records past decisions rather than current instructions:

<!-- docguard:status historical -->

These statuses skip currentness assertions. They do not hide structural or other applicable findings. A filename that contains ADR does not automatically exempt an active decision. Explicit validator and section exemptions still need reasons.

Understanding check coverage

Guard JSON includes checkCoverage and an applicability record per validator. States distinguish checked, partial, disabled, not-applicable, missing-prerequisite, unsupported, no-matches, and error. A passing gate means the selected policy passed. It does not mean DocGuard examined unsupported languages or unmatched inputs. CI and reports keep this disclosure. Python architecture analysis uses the AST of the installed Python interpreter and does not import project modules. It resolves unique repository-local modules in regular flat and src/ packages, plus explicit relative imports. Dynamic imports, runtime sys.path changes, parser failure or absence, and ambiguous modules stay partial or unsupported coverage. DocGuard keeps the supported edges and findings.

Wrangler configuration gives static evidence for Worker classification and untyped official handler arguments. DocGuard never runs configuration or application code. With the optional Babel parser, environment extraction recognizes these forms. They are module-handler env, exported Pages onRequest* context.env, this.env on classes that extend an entrypoint imported from cloudflare:workers, and env imported from that module. It follows lexical aliases and excludes shadows. Computed non-literal keys, indirect exports, user-defined lookalike classes, and other runtimes stay outside this bounded analysis. The fallback covers ordinary handler env scopes and reports AST-only forms as partial coverage.

Evidence boundaries in documentation and schema scans

Documentation-coverage filename checks search supported Markdown in conventional and explicitly configured homes, mapped role files, and supported extension metadata. Configured homes add to the defaults. Excluded files, private paths and symlinks cannot satisfy a documentation reference. The search does not prove that an explanation is absent from external sites, RST, or unsupported formats.

A parsed direct file-read or file-write call gives stronger path evidence than a path construction or an existence check. Ambiguous paths stay low-confidence review signals. A directory name alone does not prove a configuration file. The bounded detector does not resolve arbitrary import aliases or dynamic paths. Schema synchronization applies source exclusions. It deduplicates overlapping roots by source file and keeps models in distinct files, even when the names match.

Feature requirement scoring recognizes eligible test annotations and labels with the validator parser. An arbitrary fixture string is not linkage evidence. A recognized link does not prove behavioral coverage. Duplicate requirement IDs across separate specs are a known scoping limitation.

Requirement identity across documents

DocGuard identifies a requirement definition by its repository-relative document path plus its ID. A bare test annotation such as @req FR-001 earns linkage credit only when that ID is defined in one document. When features reuse an ID, qualify the declaration: @req specs/payments/spec.md#FR-001. The same spelling works in a test label. Use forward slashes. An optional leading ./ is accepted. Qualifiers are exact repository-relative paths, not paths relative to the test file.

Validation and trace --features share definition parsing and reference resolution. A qualified reference credits only its target document. An ambiguous bare reference credits neither feature and produces a review finding for each unresolved definition. A wrong qualifier is an orphan reference and never falls back to a bare match. Repeated mentions within one document do not create extra identities. Linkage is evidence of a declaration, not proof of correct behavior. Lifecycle and arbitrary verification-link semantics are separate concerns.

Version-age note — DOCGUARD_NO_UPDATE_HINT

When the installed DocGuard was released more than 14 days ago, guard’s text output, the MCP server’s initialize instructions and the context pack say so. They also suggest docguard upgrade to check npm. DocGuard reads its own release date from the CHANGELOG.md it ships with. The note makes no network call and never claims a newer version exists. The threshold is fixed.

It is silent when the date cannot be read for certain, in a DocGuard source checkout, and in guard’s text output when CI is set. Machine outputs (JSON, SARIF, JUnit, MCP tool results) never carry it. Turn it off everywhere with:

export DOCGUARD_NO_UPDATE_HINT=1