docguard
AGENTS.md33 starsChanged 46 days agoMITView on GitHub
This project follows Canonical-Driven Development (CDD). Documentation is the source of truth. Read before coding. DocGuard is an official GitHub Spec Kit community extension. docguard --help is the authoritative list (counts intentionally not hardcoded here — they drift). The surface, grouped as --help shows it: The Daily 5 — init (bootstrap + scan), guard (CI gate, all validators), diff (doc↔code gaps; --since <ref> for changed-file impact), sync (refresh code-truth sections), score (CDD maturity 0-100). Tools — demo (zero-install tour), diagnose…
- Commits and pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,542 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository23 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-implementSkill
- speckit-planSkill
- speckit-specifySkill
- speckit-tasksSkill
- speckit-taskstoissuesSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-implementSkill
- speckit-planSkill
- speckit-specifySkill
- speckit-tasksSkill
- speckit-taskstoissuesSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
21 rules. About 0 are common, 7 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 71
Prefer the machine contract over parsing prose: docguard guard --format json returns status (PASS/WARN/FAIL, matches exit code 0/2/1 — but …
- Distinctive: line 81
When a command is launched from an implicitly selected nested package, inspect stderr for repository-root guidance.
- Very specific: line 87
Every structured finding has a stable code (STR001, ENV003, XRF002, …).
- Very specific: line 94
Read evidence.status before trusting a confidence label.
- Very specific: line 99
Read parserTier when a finding concerns source code.
- Very specific: line 102
When evidence.configured is true, inspect docguard verify --evidence --format json first.
- Very specific: line 114
Treat specs/ and planning docs as active intent only.
- Very specific: line 117
Run docguard specs preflight before drafting and docguard specs preflight --path <spec> before planning.
- Very specific: line 121
Run docguard reconcile --since <ref> --format json before completing a changed feature.
- Very specific: line 186
PR-first workflow — no direct-to-main commits: Create a branch (git checkout -b <type>/<slug>), push, gh pr create, let CI run, …
- Distinctive: line 187
Never commit without updating CHANGELOG.md
- Very specific: line 194
If code deviates from docs, add // DRIFT: reason
- Distinctive: line 196
Test requirements in TEST-SPEC.md must be met
- Very specific: line 222
Run docguard guard before pushing — all checks must pass
- Distinctive: line 252
Never add a package without first verifying it exists on the official registry (npm/PyPI).
- Very specific: line 253
Always pin to exact versions in package.json and requirements.txt.
- Distinctive: line 254
Prefer packages with >10k weekly downloads and >1 maintainer.
- Distinctive: line 255
If you suggest a package, confirm its first-publish date is older than 30 days.
- Very specific: line 256
Never modify .npmrc, pnpm-workspace.yaml, or dependabot.yml without explicit user confirmation.
- Very specific: line 259
Never write a workflow using pull_request_target with checkout of PR-controlled refs.
- Distinctive: line 260
Always pin third-party GitHub Actions to commit SHA, not @v1 or @main.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI Agent Instructions — DocGuard
<!-- docguard:last-reviewed 2026-11-03 -->This project follows Canonical-Driven Development (CDD). Documentation is the source of truth. Read before coding. DocGuard is an official GitHub Spec Kit community extension.
Workflow
- Read
docs-canonical/before suggesting changes - Check existing patterns in the codebase
- Run
docguard diagnoseto see what needs fixing - Confirm your approach before writing code
- Implement matching existing code style
- Log any deviations in
DRIFT-LOG.mdwith// DRIFT: reason - Verify with
docguard guard— all checks must pass
Project Stack
- Language: JavaScript (ES modules)
- Runtime: Node.js 18+
- Dependencies: One —
@babel/parser(exact-pinned, optional-load); Node.js built-ins otherwise - Testing:
node:test(built-in) - Distribution: npm + PyPI; the release also publishes the MCP server image to GHCR, the Claude Desktop MCPB bundle and the Homebrew tap
- Version: see
package.json(single source of truth — do not hardcode here)
Key Files
| File | Purpose |
docs-canonical/ARCHITECTURE.md | System design |
docs-canonical/DATA-MODEL.md | Config, file formats and output contracts |
docs-canonical/SECURITY.md | Auth & secrets |
docs-canonical/TEST-SPEC.md | Test requirements |
docs-canonical/ENVIRONMENT.md | Environment setup |
docs-canonical/REQUIREMENTS.md | Spec-kit aligned requirements |
CHANGELOG.md | Change tracking |
DRIFT-LOG.md | Documented deviations |
Commands
docguard --help is the authoritative list (counts intentionally not hardcoded
here — they drift). The surface, grouped as --help shows it:
The Daily 5 — init (bootstrap + scan), guard (CI gate, all validators),
diff (doc↔code gaps; --since <ref> for changed-file impact), sync (refresh
code-truth sections), score (CDD maturity 0-100).
Tools — demo (zero-install tour), diagnose (guard → AI fix prompts),
fix (AI fix instructions; --doc <name>), generate (reverse-engineer docs;
--plan; --spec <area> for an as-built Spec Kit spec), agent (task graph; --task <text> for bounded current evidence),
retire (remove reviewed docs from active context),
specs (check/refresh/preflight/approve/complete the spec lifecycle registry; require for the spec-first gate; reanchor for a squash-discarded revision),
reconcile (classify code/spec changes since a Git ref without rewriting intent),
review (doc sections whose covered code changed; --accept, --prune, --suggest),
anchors (code→requirement links and whether each changed since review; accept records a review),
rules (which instruction files each agent harness loads for a path; --for <path>),
explain (explain a validator/warning), verify (declared evidence; --semantic claims), ignore (every suppression with its reason and expiry), feedback (report false positives), mcp (MCP server; stdio or loopback HTTP; tool calls stay inside the served directory and each --root), report (compliance bundle), ci (guard + score gate), policy (which advisory codes CI history shows are ready to promote), memory (what DocGuard
remembers; --pack [--symbols] for the context pack; --export/--consolidate aidlc for AWS AI-DLC memory), trace (requirements traceability; --reverse; --owners for the doc ownership map; --matrix exports requirement → anchor → test), upgrade (check npm for a newer
release and migrate the config schema; --apply also refreshes out-of-date agent files and the registered Spec Kit extension; --apply --schema-only stays offline), watch (live re-guard). sensor --aidlc speaks AWS AI-DLC's sensor contract for the DocGuard AI-DLC plugin, and stays out of --help because it is meant for machines. score --dora maps DocGuard's evidence onto DORA's documentation and AI capabilities.
init --with <name> scaffolders — agents, hooks, ci, badge, llms,
publish (also reachable as standalone deprecation aliases).
Deprecation aliases — setup → init --wizard; audit → guard
(permanent); impact → diff --since.
Consuming Guard Output (agents)
Prefer the machine contract over parsing prose: docguard guard --format json
returns status (PASS/WARN/FAIL, matches exit code 0/2/1 — but FAIL exits 3,
not 1, when the project has no .docguard.json, so branch on status rather
than assuming 1), findings[]
({code, severity, confidence, disposition, evidence, parserTier, message, location, suggestion}),
nextStep, reportable[] (findings whose code is unmeasured or whose
confidence is low — verify before acting), coverage
(Markdown tier map incl. the specKit tier and unclassified[]), evidence, and semanticClaims.count
(documented numbers not yet verified against code).
When a command is launched from an implicitly selected nested package, inspect
stderr for repository-root guidance. Human output supplies an exact rerun;
machine modes emit a docguard.repository-root-guidance JSON diagnostic there
so stdout remains a valid JSON/SARIF/JUnit artifact. The current command still
checks only the selected package unless it is explicitly rerun with --dir.
- Every structured finding has a stable code (
STR001,ENV003,XRF002, …).docguard explain <CODE>gives the contract and fix. - Triage on
disposition, not on severity alone.actmeans DocGuard asserts a defect and names the correction — apply it.escalatemeans DocGuard observed a signal and the judgement is yours; read the source before changing anything. A high-confidence finding can still be an escalation: FRS002 counts commits exactly and still does not establish that the document is stale. - Read
evidence.statusbefore trusting a confidence label.measuredquotes the reviewed corpus withnand a Wilson interval;not-measuredmeans the label is a maintainer's prior that has never been checked against labelled cases. Most codes are unmeasured — that does not make their findings wrong, only unverified. - Read
parserTierwhen a finding concerns source code.regex-fallbackorfallback-languagemeans an AST was unavailable for that file, so absence of a finding is weak evidence; the owning validator also reportspartial. - When
evidence.configuredis true, inspectdocguard verify --evidence --format jsonfirst. Averified-within-scoperesult covers only its selected statement. Contradictions can indicate code regressions from approved intent; stale reports must be regenerated from their declared inputs. - Mechanical fixes go through
docguard fix --write(provenance-checked, fail-closed) — never hand-apply what the tool fixes deterministically. - Genuine false positives: suppress at the site with
// docguard:ignore <CODE>(reason required) or<!-- docguard:validator <key> n/a — reason -->, and report them viadocguard feedback. - Doc≠code does not mean the doc is wrong — canonical docs are the spec. If the
code regressed from a documented decision, fix the code or log a
// DRIFT: reason+ DRIFT-LOG.md entry instead of rewriting the doc. - Treat
specs/and planning docs as active intent only. Review candidates withdocguard retire --plan; retire only explicit, clean tracked documents after their shipped outcomes are represented in current docs andCHANGELOG.md. - Run
docguard specs preflightbefore drafting anddocguard specs preflight --path <spec>before planning. Refresh.docguard-specs.jsonwithspecs --writeand record approval withspecs approve --id <id> --write; never edit generated intent/evidence fields or treat bare requirement IDs as completion proof. - Run
docguard reconcile --since <ref> --format jsonbefore completing a changed feature. Only its mechanical write plan may run automatically; unsupported changes and possible regressions require review.docguard specs completerecords that review and regenerates the active context projection. - For a concrete implementation task, prefer
docguard agent --task <text> --format json. Follow only selected current evidence, retain its retrieval-only assurance, inspect additional repository facts as needed, and fall back to normal discovery whenselection.statusisabstained.
AI Skills
DocGuard provides enterprise-grade AI behavior protocols via the Spec Kit extension:
| Skill | Purpose |
docguard-guard | 6-step quality gate with severity triage and structured reporting |
docguard-fix | 7-step research workflow with validation loops (max 3 iterations) |
docguard-review | Read-only semantic cross-document consistency analysis |
docguard-score | CDD maturity assessment with ROI-based improvement roadmap |
docguard-sync | Mechanical code-truth refresh with explicit prose review boundaries |
Skills are located at extensions/spec-kit-docguard/skills/*/SKILL.md. They tell agents how to think, not just what to run.
Spec Kit Hooks
DocGuard integrates into the spec-kit workflow. extensions/spec-kit-docguard/extension.yml
is authoritative; a hook is mandatory when its optional field is false.
| Hook | Command | Required? |
before_specify | speckit.docguard.brief | Mandatory |
before_tasks | speckit.docguard.preflight | Mandatory |
after_tasks | speckit.docguard.score | Optional |
after_implement | speckit.docguard.guard, then speckit.docguard.complete | Mandatory, then optional |
after_converge | speckit.docguard.complete | Optional |
Extension Structure
extensions/spec-kit-docguard/
├── skills/ # AI behavior protocols (docguard-guard, -fix, -review, -score, -sync)
├── scripts/bash/ # Orchestration scripts (--json output)
├── commands/ # Spec Kit slash commands
├── templates/ # Hook registration templates
└── extension.yml # Commands, scripts, hooks declarationRules
- Spec-first (Constitution X). A change to
cli/**runs the Spec Kit pipeline:specs/###-slug/spec → plan → tasks → implement. The PR description names the spec (specs/015-spec-first-gateor its Spec ID), or declares one lineSpec-Exempt: <release|deps|typo|test-only> — <reason>. CI enforces this withdocguard specs require --since origin/main --message-file <body>. When the area being changed has no spec, write an as-built spec scoped to that area first. - Changes must not make DocGuard slower, noisier or heavier by accident. The
CI
budgetjob compares the PR with its base on one runner: guard wall time (×1.15, 150 ms floor), new error findings on this repository, agent-facing bytes (context pack, task packets, MCP responses, llms bundles; +10%), package weight and runtime dependencies. A cost the change needs is declared in the PR body asBudget-Exempt: <metric> — <reason>. Reproduce locally withnpm run budget -- --base <base-worktree>(specs/031-non-regression-budgets). The CI test job fails any single test over 100 seconds at reference-runner speed (TEST_CEILING_MS,tools/suite-runtime-budget.mjs); the suite total is reported, not gated (specs/051-release-cut-green FR-007, TEST-SPEC.md). - PR-first workflow — no direct-to-main commits. Create a branch (
git checkout -b <type>/<slug>), push,gh pr create, let CI run, self-review, squash-merge. Tag releases only after merge onmain. The only acceptable direct-to-main: typo fixes in comments or README badge URLs. - Never commit without updating CHANGELOG.md
- Regenerate checked-in generated files in the same change; each has a drift test
that fails and names its command:
npm run llmsafter editing a canonical or optional doc (llms.txt,llms-full.txt),npm run docs:referenceafter changing a finding code or a validator's display name (the docs site's finding-code reference), andnpm run generate:precision-evidenceafter a reviewed benchmark baseline change (cli/precision-evidence-data.mjs). - If code deviates from docs, add
// DRIFT: reason - Security rules in SECURITY.md are mandatory
- Test requirements in TEST-SPEC.md must be met
- Tests that build Git repositories pass the fixture options per call. Every
fixture
gitcall goes throughtests/helpers/git.mjs(FIXTURE_GIT,fixtureGit): hooks and signing off for that call, never for the whole environment, so DocGuard's own Git calls still meet the machine's config. A scan test rejects a directgitspawn without afixture-git-exempt:reason, and the CIhermeticityjob runs the suite under a hostile global config (specs/066-test-git-hermeticity). - Workflow jobs run code without a repository write token. Workflows default
to
contents: read; a job asks for its own scope. A job that runs tests or DocGuard holds no write permission and checks out withpersist-credentials: false; a job holdingcontents,actions,pull-requestsorissueswrite runs no package manager, build tool or test.tests/workflow-permissions.test.mjsenforces it (specs/068-release-least-privilege). - A changed requirement link is reviewed, not silenced. This repository
commits
.docguard-anchor-lock.jsonl, so guard reports a link whose code or requirement changed since its review (ANC001, ANC002) or whose tag is gone (ANC003); ANC001 and ANC003 fail guard for a link accepted as reviewed. Read the change, then rundocguard anchors accept --link '<key>'(or--file <path> --bulkfor a file you changed) with a--reasonthat says what you checked. Accept only links in files your change touched. The lock merges withmerge=union: after a rebase, ANC009 means two lines for one link, so restoreorigin/main's lock and re-accept only your own files. CODEOWNERS sends every lock change to a maintainer (specs/070-requirement-anchors, CI-RECIPES.md Recipe 3f). - Run
docguard guardbefore pushing — all checks must pass - Standalone file writes use
safeWrite()with backups before overwrite. Lifecycle operations spanning multiple files usecommitFileTransaction()so preparation, rollback, and post-write validation cover the complete set.
Agent Rules
Automated agents / bots (Google Jules and any auto-PR agent)
- Jules runs only the routines in
.jules/routines/(bug-hunt,test-gaps,docs-drift, weekly), after.jules/RULES.md. Each starts withnode .jules/preflight.mjs <routine>; onSTOPit ends with no PR. Never ask a question: take the pessimistic in-scope option, or end the task with a summary and no PR. - One PR per routine target, titled
[jules:<routine>] <target> — …..github/scripts/jules-policy.mjs(viajules-triage.yml) closes a PR that is empty, a duplicate of an open PR, work declined in the last 60 days, over the five-PR queue, or off its routine's contract. It never closes a PR for its subject: a security or performance fix reaches a maintainer. - Only new test files merge alone.
auto-merge.ymlmerges a green Jules PR only when every file is a newly addedtests/<name>.test.mjs, pinned to the head CI verified. Edited tests, fixtures, any Markdown (instruction and prompt files ship to npm), code and CI wait for a maintainer. - Agents never edit an existing test,
CHANGELOG.md,.github/,.jules/or instruction files, and never mention an agent by handle: in Jules' Reactive Mode a mention is an instruction. Setup:bash .jules/setup.sh(fails unless the suite and guard are green). Spec:specs/067-jules-policy.
Dependencies
- Never add a package without first verifying it exists on the official registry (npm/PyPI).
- Always pin to exact versions in
package.jsonandrequirements.txt. No ^, ~, or >= ranges. - Prefer packages with >10k weekly downloads and >1 maintainer.
- If you suggest a package, confirm its first-publish date is older than 30 days.
- Never modify .npmrc, pnpm-workspace.yaml, or dependabot.yml without explicit user confirmation.
CI/CD
- Never write a workflow using
pull_request_targetwith checkout of PR-controlled refs. - Always pin third-party GitHub Actions to commit SHA, not @v1 or @main.
Claim probing (TestGuard)
testguard.claims.json states what this codebase guarantees, as claims with
mechanical faults. testguard probe injects each fault and reports the ones the
suite fails to detect — a test that pins a defect stays green under coverage,
so this is the check that catches it.
This suite runs on node --test, which ships no json reporter, while TestGuard
reads Jest-shape JSON. tools/node-test-json-reporter.mjs translates between
them:
npx testguard-cli@0.15.0 probe --confirm 3 --serial \
--node-modules "$PWD/node_modules" \
--runner-cmd "node --test --test-reporter=$PWD/tools/node-test-json-reporter.mjs --test-reporter-destination={out} {files}"Pass an absolute reporter path: the probe runs in a scratch worktree built from a commit, so a relative path resolves there and untracked files do not exist.
npx testguard-cli@0.15.0 gate --changed origin/main reports changed source files
that carry no claim. It does not find bugs; it refuses to let a change land without stating
what must be true, which is the step that surfaces them. A file the probe cannot
observe (for example, one that only runs as a subprocess) is excused in
testguard.ignore.json, with a reason that names what protects it instead.
Evidence and contributions
A structural score is a maturity proxy. Preserve assurance and nullable factual accuracy in automation; a clean guard does not establish arbitrary prose correctness. Review human intent separately from generated code facts. To challenge any finding, run docguard feedback --code <CODE> --preview, inspect the metadata-only public draft, and check the supplied search link for existing open and closed work. Contribute a synthetic failing example paired with a neighboring valid case. Submission remains opt-in.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

