docguard
AGENTS.md32 starsChanged 2 months 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 checking a change actually works.
Of the AGENTS.md files we read, the 11,773 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
22 rules. About 0 are common, 8 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
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
- could be automatic: a setting could enforce it
- Very specific: line 70
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 80
When a command is launched from an implicitly selected nested package, inspect stderr for repository-root guidance.
- Very specific: line 86
Every structured finding has a stable code (STR001, ENV003, XRF002, …).
- Very specific: line 93
Read evidence.status before trusting a confidence label.
- Very specific: line 98
Read parserTier when a finding concerns source code.
- Very specific: line 101
When evidence.configured is true, inspect docguard verify --evidence --format json first.
- Very specific: line 113
Treat specs/ and planning docs as active intent only.
- Very specific: line 116
Run docguard specs preflight before drafting and docguard specs preflight --path <spec> before planning.
- Very specific: line 120
Run docguard reconcile --since <ref> --format json before completing a changed feature.
- Very specific: line 182
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 183
Never commit without updating CHANGELOG.md
- Very specific: line 184
If code deviates from docs, add // DRIFT: reason
- Distinctive: line 186
Test requirements in TEST-SPEC.md must be met
- Very specific: line 187
Run docguard guard before pushing — all checks must pass
- Distinctive: line 196
Never open a duplicate PR: Before opening ANY PR, search existing open AND closed PRs and issues for the same topic/title.
- Distinctive: line 210
Never add a package without first verifying it exists on the official registry (npm/PyPI).
- Very specific: line 211
Always pin to exact versions in package.json and requirements.txt.
- Distinctive: line 212
Prefer packages with >10k weekly downloads and >1 maintainer.
- Distinctive: line 213
If you suggest a package, confirm its first-publish date is older than 30 days.
- Very specific: line 214
Never modify .npmrc, pnpm-workspace.yaml, or dependabot.yml without explicit user confirmation.
- Very specific: line 217
Never write a workflow using pull_request_target with checkout of PR-controlled refs.
- Distinctive: line 218
Always pin third-party GitHub Actions to commit SHA, not @v1 or @main.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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-09-30 -->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),
rules (which instruction files each agent harness loads for a path; --for <path>),
explain (explain a validator/warning), verify (declared evidence; --semantic claims), feedback (report false positives), mcp (MCP server; stdio or loopback HTTP), report (compliance bundle), ci (guard + score gate), memory (what DocGuard
remembers; --pack [--symbols] for the context pack), trace (requirements traceability; --reverse; --owners for the doc ownership map), upgrade (check npm for a newer
release and migrate the config schema; --apply --schema-only stays offline), watch (live re-guard).
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 --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). - 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
- If code deviates from docs, add
// DRIFT: reason - Security rules in SECURITY.md are mandatory
- Test requirements in TEST-SPEC.md must be met
- 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 (Jules "Sentinel", "Bolt", "Palette", and any auto-PR agent)
- Never open a duplicate PR. Before opening ANY PR, search existing open AND closed PRs and issues for the same topic/title. If it exists, STOP — do not open another. (Dozens of duplicate command-injection and diff-optimization PRs were closed as noise.)
- Do not re-open resolved work. See
.jules/sentinel.md(execSync/command injection — RESOLVED in v0.21.1 + #296) and.jules/bolt.md(diff/scan micro-optimizations — already applied; code refactored since). These are historical learnings, not standing mandates to re-scan every run. - Bar for a new PR: a genuinely new, unaddressed finding, with evidence — a concrete exploit path / failing test (security) or a benchmark showing >20% real-workload improvement (performance). A Big-O note alone is insufficient.
- This repo has no web UI and no VS Code extension — skip all UX tasks.
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.

