raccioly/docguard

๐Ÿ’ป Developer Tools
0 Views
0 Installs

๐Ÿ“‡ ๐Ÿ  ๐ŸŽ ๐ŸชŸ ๐Ÿง - Deterministic documentation-drift detection for AI agents. Validates a project's canonical docs against its actual code โ€” no LLM guessing; every finding has a stable code and a suggested fix. Five read-only tools over stdio: guard, score, explain, verify-claims, diagnose. npx -y docguard-cli mcp

Quick Install

One-Click IDE Configuration
claude_desktop_config.json
{
  "mcpServers": {
    "raccioly-docguard": {
      "command": "npx",
      "args": [
        "-y",
        "raccioly-docguard"
      ]
    }
  }
}
Or

Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.

Documentation Overview

๐Ÿ›ก๏ธ DocGuard

English ยท Portuguรชs (BR) ยท Espaรฑol

The enforcement layer for Spec-Driven Development. Validate. Score. Enforce. Ship documentation that AI agents can actually use.

CI npm npm downloads PyPI License: MIT Node.js Runtime deps Spec Kit Extension Glama MCP Registry


โœจ See what DocGuard catches in 30 seconds โ€” no install, no setup:

npx docguard-cli demo

Runs against a baked-in sample project with intentional drift and shows you the findings + a clear path to fixing them.

DocGuard demo


Table of Contents


What is DocGuard?

DocGuard enforces Canonical-Driven Development (CDD) โ€” a methodology where documentation is the source of truth, not an afterthought. AI writes the docs, DocGuard validates them.

Traditional DevelopmentCanonical-Driven Development
Code first, docs maybeDocs first, code conforms
Docs rot silentlyDrift is tracked and enforced
Docs are optionalDocs are required and validated
One AI agent, one contextAny agent, shared context via canonical docs

DocGuard is an official GitHub Spec Kit community extension. It validates the artifacts that Spec Kit creates, ensuring your specs stay high-quality throughout the development lifecycle.

๐Ÿ“– Philosophy ยท ๐Ÿ“‹ CDD Standard ยท โš–๏ธ Comparisons ยท ๐Ÿ”ฌ Validation ยท ๐Ÿ—บ๏ธ Roadmap

Architecture

graph TD
    CLI["CLI Entry<br/>docguard.mjs"] --> Commands["Commands (20)"]
    Commands --> guard["guard"]
    Commands --> generate["generate"]
    Commands --> score["score"]
    Commands --> diagnose["diagnose"]
    Commands --> setup["setup wizard"]
    Commands --> other["diff ยท init ยท fix ยท trace ยท impact ยท sync<br/>explain ยท memory ยท upgrade ยท agents ยท hooks ยท badge ยท ci ยท watch"]

    guard --> Validators["Validators (27)"]
    generate --> Scanners["Scanners (4)<br/>routes ยท schemas ยท doc-tools ยท speckit"]
    score --> Scoring["Weighted Scoring<br/>8 categories"]
    diagnose --> Validators
    diagnose --> AIPrompts["AI-Ready<br/>Fix Prompts"]

    Validators --> Output["Output"]
    Scanners --> Output
    Scoring --> Output
    Output --> Terminal["Terminal"]
    Output --> JSON["JSON"]
    Output --> Badge["Badge"]

    style CLI fill:#2d5016,color:#fff
    style Validators fill:#1a3a5c,color:#fff
    style Scanners fill:#1a3a5c,color:#fff
    style Output fill:#5c3a1a,color:#fff

Distribution: Node.js core (npm) ยท Python wrapper (PyPI) ยท GitHub Action (action.yml) ยท Spec Kit Extension (ZIP)


Why DocGuard?

Documentation that drifts from code is worse than no documentation โ€” it confidently misleads humans and AI agents alike. DocGuard treats your canonical docs as an enforced contract: deterministic validators diff what the docs claim against what the code does, on every commit, with no LLM required. The full thesis (and the research behind it) lives in PHILOSOPHY.md; recent feature highlights moved below.

The field data backs the enforcement-over-instructions bet: an ETH Zurich study across 138 repos / 5,694 agent PRs found the most popular style of agent-instruction file hurts agent performance, and practitioners keep converging on the same lesson โ€” written rules are routinely ignored; programmatic checks are what agents (and humans) actually respect. That is exactly the layer DocGuard provides: not another instructions file, but the validator suite that makes the instructions and docs verifiably true.


โšก Quick Start

Package naming: this repo is raccioly/docguard; the published package is docguard-cli on both npm and PyPI; the installed command is docguard. Same project โ€” the -cli suffix is just the registry name. The package runs no install scripts, so npm i -g docguard-cli --ignore-scripts is equivalent.

Node.js (npm)

# No install needed โ€” run directly
npx docguard-cli diagnose

# Or install globally
npm i -g docguard-cli
docguard diagnose

Python (PyPI)

pip install docguard-cli
docguard diagnose

Note: The Python package is a thin wrapper that delegates to npx. Node.js 18+ is required on the system.

More ways to integrate

  • pre-commit โ€” changed-only guard on every commit:
    repos:
      - repo: https://github.com/raccioly/docguard
        rev: v0.29.0
        hooks: [{ id: docguard-guard }]   # docguard-guard-full for pre-push
    
  • MCP (Claude, Cursor, any MCP client) โ€” claude mcp add docguard -- npx -y docguard-cli mcp; 5 read-only tools (guard, score, explain, verify-claims, diagnose). Registry manifest ships in-repo (server.json, Smithery-ready).
  • GitLab CI โ€” component staged at templates/ci/gitlab-component.yml (guard/score/ci job with a SARIF artifact).
  • Homebrew โ€” brew install raccioly/tap/docguard (formula in packaging/homebrew/).

Core Workflow

# 1. Initialize docs for your project
npx docguard-cli init

# 2. Or reverse-engineer docs from existing code
npx docguard-cli generate

# 3. AI diagnoses issues and generates fix prompts
npx docguard-cli diagnose

# 4. Validate โ€” use as CI gate
npx docguard-cli guard

# 5. Check maturity score
npx docguard-cli score

The AI Loop

diagnose  โ†’  AI reads prompts  โ†’  AI fixes docs  โ†’  guard verifies
   โ†‘                                                       โ†“
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ issues found? โ†โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

diagnose is the primary command. It runs all validators, maps every failure to an AI-actionable fix prompt, and outputs a remediation plan. Your AI agent runs it, fixes the docs, and runs guard to verify.

Mechanical vs. agent fixes

DocGuard splits drift into two kinds and is explicit about which is which:

KindExampleHow it's fixed
Mechanical (deterministic)An endpoint documented in API-REFERENCE.md that the OpenAPI spec confirms is gonedocguard fix --write deletes the row + detail block itself โ€” no AI
Agent (needs judgment)Rewriting an X-Ray prose section as CloudWatch; writing a new endpoint's request/responseRouted to an AI agent via diagnose / fix --doc prompts

docguard fix --write only touches docs marked <!-- docguard:generated true --> (override with --force), is idempotent, and prints exactly what changed. It never rewrites prose โ€” that stays with the agent.

Hands-off loop (set and forget)

guard โ”€โ”€โ–ถ fix --write (mechanical, auto) โ”€โ”€โ–ถ guard โ”€โ”€โ–ถ diagnose (agent prompts for the rest)
  • CI / pre-commit: docguard hooks --type pre-commit --auto-fix installs a hook that applies mechanical fixes, re-stages the docs, then runs guard; anything left is surfaced as agent prompts.
  • Agent-driven: docguard diagnose --auto scaffolds missing docs and applies mechanical fixes, then emits prompts for the content rewrites that remain.
  • JSON for automation: guard/diagnose --format json include a mechanicalFixes array and tag each issue mechanical vs agent, so an agent can apply or delegate precisely.

๐ŸŒฑ Spec Kit Integration

DocGuard is a community extension for GitHub's Spec Kit framework. While Spec Kit focuses on creating specifications (via AI slash commands like /speckit.specify and /speckit.plan), DocGuard focuses on validating their quality.

How They Work Together

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚    Spec Kit      โ”‚          โ”‚    DocGuard       โ”‚
โ”‚                  โ”‚          โ”‚                   โ”‚
โ”‚  /speckit.specifyโ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ†’  โ”‚  docguard guard   โ”‚
โ”‚  Creates specs   โ”‚          โ”‚  Validates specs  โ”‚
โ”‚  (AI-driven)     โ”‚          โ”‚  (automated)      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
PhaseToolWhat happens
1. Initializespecify initCreates .specify/ directory and templates
2. Write specs/speckit.specifyAI creates spec.md with FR-IDs, user stories
3. Validatedocguard guardChecks spec quality (mandatory sections, FR/SC IDs)
4. Plan/speckit.planAI creates plan.md with technical context
5. Validatedocguard guardChecks plan quality (sections, structure)
6. Tasks/speckit.tasksAI creates tasks.md with phased breakdown
7. Validatedocguard guardChecks task quality (phases, T-IDs)
8. Implement/speckit.implementAI writes code
9. Enforcedocguard guardFinal quality gate โ€” CI/CD

What DocGuard Validates in Spec Kit Projects

  • spec.md โ€” Mandatory sections (User Scenarios, Requirements, Success Criteria), FR-xxx IDs, SC-xxx IDs
  • plan.md โ€” Summary, Technical Context, Project Structure sections
  • tasks.md โ€” Phased task breakdown (Phase 1, 2, 3+), T-xxx task IDs
  • constitution.md โ€” Detected at .specify/memory/constitution.md or project root
  • Requirement traceability โ€” FR, SC, NFR, US, AC, UC, SYS, ARCH, MOD, T IDs

Installing as a Spec Kit Extension

specify extension add docguard

This installs DocGuard's slash commands (/docguard.init, /docguard.guard, /docguard.review, /docguard.fix, /docguard.update) into your AI agent's command palette.


Usage

DocGuard ships 20 commands (the "Daily 5" + 15 situational tools, including the zero-install demo, the mcp server, and the ci pipeline gate). Six additional one-shot scaffolders are accessed via docguard init --with <name>. Seven v0.19 commands continue to work as deprecation aliases through v0.20.x โ€” see MIGRATION-v0.20.md.

The Daily 5 โ€” what you'll reach for 95% of the time:

CommandWhat It Does
initBootstrap a project (--wizard for interactive ยท --with <name> for scaffolders)
guardValidate against canonical docs โ€” 27 validators
diffShow gaps between docs and code (--since <ref> for impact mode)
syncRefresh code-truth doc sections โ€” keeps memory always up to date
scoreCDD maturity score (0-100; --diff for delta between refs)

Tools (situational, but day-to-day useful):

CommandPurpose
demoZero-install showcase โ€” runs guard against a baked-in drifting fixture (npx docguard-cli demo)
diagnoseAI orchestrator โ€” guard โ†’ emit fix prompts in one command
fixGenerate AI fix instructions for specific docs (--doc <name> --format prompt)
fix --writeApply deterministic fixes (no AI โ€” version bumps, counts, anchors, sections)
fix --historyAudit log of every mechanical fix applied (from .docguard/fixed.json)
generateReverse-engineer docs from existing codebase (--plan for AI scan) โ€” includes auto-generated Mermaid ER diagrams from your detected schemas (Prisma/Drizzle/TypeORM/Sequelize/Django/Rails) in DATA-MODEL.md
agentOne-shot agent task graph โ€” ordered, pre-filled code-truth, per-task verify (--format json)
explain <warning|CODE>Paste any warning โ€” or a finding code like SEC001 โ€” to get the validator's docstring, fix path, and how to suppress
verify --semanticExtract documented numbers/limits/enums (retention days, rate limits, GSI/role counts, status enums) as a task list for an agent to check against code โ€” the semantic-drift class regex/AST can't see
verify --instructionsAudit AGENTS.md/CLAUDE.md themselves for drift: duplicate rules, never-vs-always contradictions, stale file pointers, unknown commands โ€” plus clustered rule pairs as agent judgment tasks
feedbackReport likely false positives back to DocGuard โ€” local-first record + a 1-click prefilled, redacted GitHub issue (zero typing)
mcpMCP server โ€” exposes guard/score/explain/verify/report/diagnose as native tools for Claude, Cursor, and any MCP client. Stdio: claude mcp add docguard -- npx docguard-cli mcp. Team-shared HTTP: docguard mcp --transport http --port 8585 (loopback by default; non-loopback binds require --api-key)
reportCompliance-evidence bundle for audits โ€” guard verdict + CDD score + ALCOA+ attributes + fix history, stamped with git commit and a tamper-evident sha256 integrity hash (--format json, --out <file>). Evidence, not a gate: always exits 0
ciPipeline gate: guard + score in one command โ€” never scaffolds or touches source; its only write is its own .docguard/history.jsonl (opt out: --no-history). --threshold <n> fails below a score, --fail-on-warning for strict mode, --format json for parsers
score --trendScore trajectory from recorded ci runs โ€” sparkline, delta, and the last 10 runs with commit stamps
memoryPer-domain accuracy headline (endpoints / entities / env / tech)
memory --diffDrill into which specific claims don't match code
memory --packWrite .docguard/context-pack.md โ€” compact, code-truth-stamped session-start context for AI agents
score --diffDrill into which checks pulled each category down
trace / trace --reverse <file>Requirements traceability โ€” forward AND reverse
trace --featuresPer-feature spec-adherence scores (requirement coverage, task completion, task evidence, artifacts) โ€” worst-first with fix hints
upgrade [--apply] [--pr]Check + migrate .docguard.json schema; --pr opens a PR
watchLive mode: re-run guard on file changes

init --with <name> scaffolders โ€” picked at init time:

ScaffolderWhat It Generates
agentsAGENTS.md, CLAUDE.md, .cursor/rules/, .github/copilot-instructions.md
hooksGit pre-commit / pre-push hooks
ciGitHub Actions / pipeline YAML
badgeShields.io score badges for README
llmsllms.txt (AI-friendly summary)
publishExternal doc-site config (Mintlify) โ€” experimental

Run them solo (docguard init --with hooks) or stacked (docguard init --with agents,hooks,badge,ci).

Deprecation aliases โ€” setup ยท agents ยท hooks ยท ci ยท badge ยท llms ยท publish ยท impact keep working in v0.20.x with a yellow stderr warning. audit โ†’ guard is permanent (no warning). See MIGRATION-v0.20.md.

CLI Flags

FlagDescriptionCommands
--dir <path>Project directory (default: .)All
--verboseShow detailed outputAll
--quiet / -qSuppress banner โ€” for hooks, CI loops, scriptsAll
--format jsonMachine-readable output (clean JSON, no ANSI bleed)guard, score, diff, trace, diagnose, memory, impact, explain
--format sarifSARIF 2.1.0 output โ€” findings as rules/results for GitHub Code Scanning and SARIF dashboardsguard
--format junitJUnit XML output โ€” one testcase per validator, for GitLab CI (artifacts:reports:junit), Jenkins, Azure DevOps, CircleCIguard
--update-baselineAdopt DocGuard on a legacy repo without a red day one: freeze today's findings into a committed .docguard.baseline.json; guard/ci then gate only NEW drift. Suppression is always visible ("N pre-existing finding(s) suppressed"), and --no-baseline shows the full pictureguard
--fullGenerate llms-full.txt (full doc bodies inlined) instead of the llms.txt link indexllms
--packWrite .docguard/context-pack.md โ€” agent session-start contextmemory
--syncRegenerate the agent-file family (CLAUDE.md, Copilot, Cursor, โ€ฆ) from AGENTS.md; hash-marked, never touches hand-written files without --forceagents
--checkCI gate for the synced agent-file family โ€” exit 2 when a variant is staleagents
--forceOverwrite existing files (creates .bak backups)generate, agents, init
--force-redoBypass ping-pong suppression in .docguard/fixed.jsonfix --write
--profile <name>Starter / standard / enterpriseinit
--no-spec-kitSkip auto-init of .specify/ / .agent/ scaffoldinginit
--changed-only [--since <ref>]Pre-commit lite mode (5 fast validators on changed files only)guard
--timingsPer-validator wall-time profile (slowest first)guard
--show-failingShow warnings/errors even when status is PASSguard
--pinRecord running CLI version into .docguard.json (reproducibility)guard
--diffPer-category drill-downscore, memory
--check-onlyExit 1 if behind (for CI)upgrade
--applyActually run the migrationupgrade
--prOpen a PR with the migrationupgrade
--reverse <file>Reverse traceability (code โ†’ docs)trace
--no-indirectSkip the reverse-import-graph analysis (docs about modules that import a changed file)impact, diff --since
--prsOpen-PR doc-conflict analysis โ€” two PRs impacting the same canonical doc = merge-order risk (needs the gh CLI)impact
--transport http --port --host --api-key --pathServe MCP over Streamable HTTP instead of stdio (team-shared server; loopback-only unless an api-key is set)mcp
--historyShow fix audit logfix

Example Output

$ npx docguard-cli generate

๐Ÿ”ฎ DocGuard Generate โ€” my-project
   Scanning codebase to generate canonical documentation...

  Detected Stack:
    language: TypeScript ^5.0
    framework: Next.js ^14.0
    database: PostgreSQL
    orm: Drizzle 0.33
    testing: Vitest
    hosting: AWS Amplify

  โœ… ARCHITECTURE.md (4 components, 6 tech)
  โœ… DATA-MODEL.md (12 entities detected)
  โœ… ENVIRONMENT.md (18 env vars detected)
  โœ… TEST-SPEC.md (45 tests, 8/10 services mapped)
  โœ… SECURITY.md (auth: NextAuth.js)
  โœ… REQUIREMENTS.md (spec-kit aligned)
  โœ… AGENTS.md
  โœ… CHANGELOG.md
  โœ… DRIFT-LOG.md

  Generated: 9  Skipped: 0

๐Ÿ” Validators

DocGuard runs 27 automated validators on every guard check. Every one is language-aware as of v0.16 โ€” patterns for Python (test_*.py), Rust (tests/*.rs), Go (*_test.go), Java (*Test.java), Ruby (*_spec.rb), PHP, and JS/TS all match.

#ValidatorWhat It ChecksDefault
1StructureRequired CDD files existโœ… On
2Doc SectionsCanonical docs have required sections (or N/A markers)โœ… On
3Docs-SyncRoutes/services referenced in docs + OpenAPI cross-checkโœ… On
4Drift-Comments// DRIFT: comments logged in DRIFT-LOG.md (skips test files by default)โœ… On
5ChangelogCHANGELOG.md has [Unreleased] sectionโœ… On
6Test-SpecTests exist per TEST-SPEC.md rulesโœ… On
7EnvironmentEnv vars documented, .env.example existsโœ… On
8SecurityNo hardcoded secrets in source codeโœ… On
9ArchitectureImports follow layer boundaries (honors config.ignore)โœ… On
10FreshnessDocs not stale relative to code changes (rename-aware via git log --follow)โœ… On
11TraceabilityRequirement IDs (FR, SC, NFR, US, AC, T) trace to testsโœ… On
12Docs-DiffCode artifacts match documented entitiesโœ… On
13API-SurfaceAPI-REFERENCE.md endpoints match real routes (OpenAPI cross-check)โœ… On
14Metadata-SyncVersion refs consistent across docsโœ… On
15Docs-CoverageCode features referenced in documentationโœ… On
16Doc-QualityWriting quality (readability, passive voice, atomicity, IEEE 830)โœ… On
17TODO-TrackingUntracked TODOs/FIXMEs and skipped tests (skips test files by default)โœ… On
18Schema-SyncDatabase models documented in DATA-MODEL.mdโœ… On
19Spec-KitSpec quality validation (FR-IDs, mandatory sections, phased tasks)โœ… On
20Cross-ReferenceInternal markdown links + anchors resolve (with "did you mean?" hints); Obsidian wikilinks validated when the repo uses them as file links (.obsidian present or a target resolves)โœ… On
21Generated-Stalenesssource=code sections match scanner output; status: draft doc ageโœ… On
22Canonical-SyncDocGuard's own README count claims match code-truth (DocGuard repo only โ€” N/A elsewhere)โœ… On
23Metrics-ConsistencyHardcoded numbers match actual countsโœ… On
24Surface-SyncItem-level enumerable drift โ€” names in doc tables/lists (commands, checks, etc.) match code-truth (opt-in via surfaceSync.surfaces; N/A unless configured)โœ… On
25Diff-SuspicionChange-driven: a doc/agent-instruction file that references code changed since the ref AND shares removed domain symbols is flagged for review (arXiv 2010.01625, F1 74.7)โœ… On
26Reference-ExistenceTwo-revision check: a backticked code symbol present when the doc was last updated but gone at HEAD is flagged as outdated (arXiv 2212.01479)โœ… On
27API-Doc-SmellsBloated (โ‰ฅ300 words) / Lazy (โ‰ค6 prose words) API documentation units, keyed on signature-headed sections (F1 0.90/0.95)โœ… On

Per-validator controls (in .docguard.json):

{
  "validators": {
    "test-spec": false,                 // disable (kebab-case OR camelCase both accepted)
    "freshness": true
  },
  "severity": {
    "todoTracking": "high",             // warnings fail CI
    "freshness": "low"                  // warnings ignored for exit code
  }
}

๐Ÿ“„ Templates

DocGuard ships 18 professional templates with metadata, badges, and revision history:

TemplateTypePurpose
ARCHITECTURE.mdCanonicalSystem design, components, layer boundaries
DATA-MODEL.mdCanonicalSchemas, entities, relationships
SECURITY.mdCanonicalAuth, permissions, secrets management
TEST-SPEC.mdCanonicalTest strategy, coverage requirements
ENVIRONMENT.mdCanonicalEnvironment variables, deployment config
REQUIREMENTS.mdCanonicalSpec-kit aligned FR/SC IDs, user stories
DEPLOYMENT.mdCanonicalInfrastructure, CI/CD, DNS
ADR.mdCanonicalArchitecture Decision Records
ROADMAP.mdCanonicalProject phases, feature tracking
KNOWN-GOTCHAS.mdImplementationSymptom โ†’ gotcha โ†’ fix entries
TROUBLESHOOTING.mdImplementationError diagnosis guides
RUNBOOKS.mdImplementationOperational procedures
VENDOR-BUGS.mdImplementationThird-party issue tracker
CURRENT-STATE.mdImplementationDeployment status, tech debt
AGENTS.mdAgentAI agent behavior rules
CHANGELOG.mdTrackingChange log
DRIFT-LOG.mdTrackingDeviation tracking
llms.txtGeneratedAI-friendly project summary (llmstxt.org)

๐Ÿค– AI Agent Support

One-click MCP install

Add to Cursor Install in VS Code

  • Claude Code: claude mcp add docguard -- npx docguard-cli mcp
  • Claude Desktop: download docguard-v<version>.mcpb from the latest release and drag it into Settings โ†’ Extensions โ€” you'll be asked which project folder to analyze. No npm, no JSON editing.
  • Anything MCP: DocGuard is a verified namespace on the official MCP registry (io.github.raccioly/docguard).

DocGuard works with every major AI coding agent. All canonical docs are plain markdown โ€” no vendor lock-in.

AgentCompatibilityAuto-Generate Config
Google Antigravityโœ…docguard agents --agent antigravity
Claude Codeโœ…docguard agents --agent claude
GitHub Copilotโœ…docguard agents --agent copilot
Cursorโœ…docguard agents --agent cursor
Windsurfโœ…docguard agents --agent windsurf
Clineโœ…docguard agents --agent cline
Google Gemini CLIโœ…docguard agents --agent gemini
Kiro (AWS)โœ…โ€”

Always-on nudge hook (Claude Code)

docguard hooks --claude            # install   (remove: docguard hooks --claude --remove)

Registers a PostToolUse hook in the project's .claude/settings.json. After the agent edits a canonical doc it is nudged to run docguard guard --changed-only; after it edits a code file the docs reference, it is nudged toward docguard impact. Merge-safe (only DocGuard's own entry is ever added/removed), throttled to one nudge per file per 30 minutes, and the hook runtime can never break a session (errors are silent by contract). Explicit opt-in โ€” init never installs it for you.


โšก Slash Commands

DocGuard provides AI agent slash commands for integrated workflows. Installed automatically via docguard init or specify extension add docguard:

CommandWhat It Does
/docguard.initInitialize Canonical-Driven Development in a new or existing project
/docguard.guardRun quality validation โ€” check all 27 validators
/docguard.reviewAnalyze doc quality and suggest improvements
/docguard.fixGenerate targeted fix prompts for specific issues
/docguard.updateUpdate canonical docs after code changes โ€” detect drift and sync documentation

These commands are installed into your AI agent's command directory:

.github/commands/     โ†’ GitHub Copilot
.cursor/rules/        โ†’ Cursor
.gemini/commands/     โ†’ Google Gemini
.claude/commands/     โ†’ Claude Code
.agents/workflows/    โ†’ Antigravity

๐Ÿง  AI Skills (Enterprise)

Beyond slash commands, DocGuard provides 4 enterprise-grade AI skills โ€” deep behavior protocols that tell AI agents not just what to run, but how to think, validate, and iterate. Skills are modeled after Spec Kit's skill architecture.

SkillLinesWhat It Does
docguard-guard1556-step quality gate with severity triage (CRITICALโ†’LOW), structured reporting, remediation
docguard-fix1957-step research workflow with per-document codebase research and 3-iteration validation loops
docguard-review170Read-only semantic cross-document analysis with 6 analysis passes and quality scoring
docguard-score165CDD maturity assessment with ROI-based improvement roadmap and grade progression

Workflow Hooks

DocGuard integrates into the spec-kit workflow as an automated quality gate:

HookWhenBehavior
after_implementAfter /speckit.implementMandatory โ€” always runs DocGuard guard
before_tasksBefore /speckit.tasksOptional โ€” reviews doc consistency
after_tasksAfter /speckit.tasksOptional โ€” shows CDD maturity score

Orchestration Scripts

For advanced users and CI/CD pipelines, DocGuard includes bash scripts with --json output:

ScriptPurpose
docguard-check-docs.shDiscover project docs, return JSON inventory with metadata
docguard-suggest-fix.shRun guard, parse results, output prioritized fixes
docguard-init-doc.shInitialize canonical doc with metadata header

๐Ÿ“ Examples

Three real-world projects to see DocGuard in action:

ExampleScenarioWhat You'll See
01-express-apiNode.js API with zero docsCold-start: generate โ†’ instant coverage
02-python-flaskPython app with drifted docsDrift detection: catch when docs lie
03-spec-kit-projectFull CDD + Spec KitGold standard: what maturity looks like

See examples/README.md for step-by-step instructions.


๐Ÿงช Testing

Test Suite

npm test    # 33 tests across 18 describe blocks

Covers all 15 CLI commands, project type detection, compliance profiles, JSON output format, and help completeness.

CI Matrix

Node.jsOSStatus
18ubuntu-latestโœ…
20ubuntu-latestโœ…
22ubuntu-latestโœ…

Self-Validation (Dogfooding)

DocGuard runs its own guard, score, diff, diagnose, and badge commands against itself in CI โ€” ensuring the tool passes its own checks.


๐Ÿข Enterprise Adoption

Everything runs local or in your CI โ€” no SaaS, no data leaving your infra. The pieces that matter at company scale:

NeedDocGuard answer
Adopt on a legacy repo without a red pipeline on day oneguard --update-baseline freezes existing findings into a committed .docguard.baseline.json; only NEW drift gates from then on (suppression always visible)
Audit trail for compliance reviewsdocguard report โ€” commit-stamped evidence bundle (guard verdict, findings by code, CDD score, ALCOA+ data-integrity attributes, fix history) with a tamper-evident sha256 integrity hash
Every CI system, not just GitHubguard --format sarif (GitHub Code Scanning) ยท --format junit (GitLab, Jenkins, Azure DevOps, CircleCI) ยท --format json (anything else)
Trajectory, not snapshotsdocguard ci records every run to .docguard/history.jsonl; score --trend shows the sparkline + delta
AI agents on the teamMCP server (stdio or team-shared HTTP) exposes guard/score/explain/verify/report/diagnose as read-only tools; agents --sync keeps the whole agent-file family drift-proof
Data-integrity framing auditors knowALCOA+ scoring (FDA 21 CFR Part 11 / EMA Annex 11 vocabulary) built into score and report

โš™๏ธ CI/CD Integration

Full recipes: see docs-canonical/CI-RECIPES.md for guard, auto-fix (commits mechanical fixes back to PRs), nightly sync, score-on-PR, and pre-commit configs.

GitHub Actions โ€” Guard (most common)

name: DocGuard Guard
on: [pull_request, push]
permissions: { pull-requests: write }   # for the sticky PR comment (optional)
jobs:
  docguard:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - uses: raccioly/docguard@v0.12.0
        with:
          command: guard

On pull requests, guard mode also gives inline PR feedback (both default on):

InputDefaultDescription
annotationstrueInline ::error/::warning annotations on the PR diff, one per guard finding (capped at 50; a final notice reports how many were elided)
pr-commenttrueSticky PR comment with the guard verdict, top findings (by code), and which canonical docs the PR's changed files impact (diff --since origin/<base>). Needs permissions: pull-requests: write; degrades to a log warning without it

Both run even when guard fails โ€” that's when the feedback matters. Prefer native code-scanning integration? docguard guard --format sarif uploads straight to GitHub Code Scanning via github/codeql-action/upload-sarif.

GitHub Actions โ€” Auto-Fix (commits mechanical fixes back)

name: DocGuard Auto-Fix
on: { pull_request: { types: [opened, synchronize, reopened] } }
permissions: { contents: write, pull-requests: write }
jobs:
  autofix:
    runs-on: ubuntu-latest
    if: github.event.pull_request.head.repo.full_name == github.repository
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.ref }}
          token: ${{ secrets.GITHUB_TOKEN }}
          fetch-depth: 0
      - uses: raccioly/docguard@v0.12.0
        with: { command: fix, auto-commit: 'true', comment-on-pr: 'true' }

Pre-commit Hook

npx docguard-cli hooks --type pre-commit

Workflow starters (copy directly)

Two ready-to-use templates ship with the Spec Kit extension and as standalone files:

  • extensions/spec-kit-docguard/templates/github-workflows/docguard-guard.yml โ€” mandatory CI gate
  • extensions/spec-kit-docguard/templates/github-workflows/docguard-autofix.yml โ€” PR auto-fix

โœจ What's New

Highlights of the current line (v0.29 โ†’ v0.33):

  • Adoption baseline โ€” guard --update-baseline freezes a legacy repo's existing findings into a committed .docguard.baseline.json; guard/ci then gate only NEW drift, with suppression always visible. Adopt today, burn down at your own pace.
  • docguard report โ€” commit-stamped compliance-evidence bundle (guard verdict, findings by code, CDD score, ALCOA+ attributes, fix history) with a tamper-evident sha256 integrity hash. Also exposed as the docguard_report MCP tool.
  • Score history + score --trend โ€” docguard ci records every run to .docguard/history.jsonl; the trend view shows the sparkline and delta over time.
  • Three machine formats for guard โ€” --format json, --format sarif (GitHub Code Scanning), and --format junit (GitLab, Jenkins, Azure DevOps, CircleCI).
  • MCP server, stdio + team HTTP โ€” guard/score/explain/verify/report/diagnose as read-only agent tools: claude mcp add docguard -- npx docguard-cli mcp.
  • Agent-file family sync โ€” agents --sync treats AGENTS.md as canonical and regenerates CLAUDE.md / .cursor/rules / Copilot / Gemini variants with drift-proof source-hash markers.
  • verify --semantic and verify --instructions โ€” extract documented numbers/limits/enums as agent verification tasks; audit the agent-instruction files themselves for contradictions and stale pointers.
  • docguard agent โ€” one-shot ordered task graph with pre-filled code-truth, collapsing ~10 agent round-trips into one call.

See CHANGELOG.md for the full history.


๐Ÿ“ File Structure

your-project/
โ”œโ”€โ”€ .specify/                        # Spec Kit (if using specify init)
โ”‚   โ”œโ”€โ”€ specs/
โ”‚   โ”‚   โ””โ”€โ”€ 001-feature/
โ”‚   โ”‚       โ”œโ”€โ”€ spec.md              # Requirements (FR-IDs, user stories)
โ”‚   โ”‚       โ”œโ”€โ”€ plan.md              # Implementation plan
โ”‚   โ”‚       โ””โ”€โ”€ tasks.md             # Task breakdown
โ”‚   โ”œโ”€โ”€ memory/
โ”‚   โ”‚   โ””โ”€โ”€ constitution.md          # Project principles
โ”‚   โ””โ”€โ”€ templates/
โ”‚
โ”œโ”€โ”€ docs-canonical/                  # CDD canonical docs (the "blueprint")
โ”‚   โ”œโ”€โ”€ ARCHITECTURE.md              # System design, components
โ”‚   โ”œโ”€โ”€ DATA-MODEL.md                # Database schemas
โ”‚   โ”œโ”€โ”€ SECURITY.md                  # Auth, permissions, secrets
โ”‚   โ”œโ”€โ”€ TEST-SPEC.md                 # Required tests, coverage
โ”‚   โ”œโ”€โ”€ ENVIRONMENT.md               # Environment variables
โ”‚   โ””โ”€โ”€ REQUIREMENTS.md              # Spec-kit aligned FR/SC IDs
โ”‚
โ”œโ”€โ”€ docs-implementation/             # Current state (optional)
โ”‚   โ”œโ”€โ”€ KNOWN-GOTCHAS.md
โ”‚   โ”œโ”€โ”€ TROUBLESHOOTING.md
โ”‚   โ”œโ”€โ”€ RUNBOOKS.md
โ”‚   โ””โ”€โ”€ CURRENT-STATE.md
โ”‚
โ”œโ”€โ”€ AGENTS.md                        # AI agent behavior rules
โ”œโ”€โ”€ CHANGELOG.md                     # Change tracking
โ”œโ”€โ”€ DRIFT-LOG.md                     # Documented deviations
โ”œโ”€โ”€ llms.txt                         # AI-friendly summary
โ””โ”€โ”€ .docguard.json                   # DocGuard configuration

โš™๏ธ Configuration

Create .docguard.json in your project root (auto-generated by docguard init):

{
  "projectName": "my-project",
  "version": "0.4",
  "profile": "standard",
  "projectType": "webapp",
  "validators": {
    "structure": true,
    "docsSync": true,
    "drift": true,
    "changelog": true,
    "testSpec": true,
    "security": true,
    "environment": true,
    "docQuality": true,
    "specKit": true
  }
}

See Configuration Guide for all options.


๐Ÿ”ฌ Research Credits

DocGuard's quality evaluation and documentation generation patterns are informed by peer-reviewed research from the University of Arizona and the Joint Interoperability Test Command (JITC), U.S. Department of Defense:

Lead researcher: Martin Manuel Lopez ยท ORCID 0009-0002-7652-2385

See CONTRIBUTING.md for full citations.


โญ Star History

Star History Chart


๐Ÿ”’ Privacy & Supply Chain

DocGuard is local-first: no telemetry, no analytics, no phone-home โ€” the full (short) policy is in PRIVACY.md. npm releases are published with provenance attestation, so you can verify each tarball was built by GitHub Actions from this repository.

๐Ÿ“„ License

MIT โ€” Free to use, modify, and distribute.


Made with โค๏ธ by Ricardo Accioly

Related MCP Servers

Moxie-Docs-MCPโ˜… Featured

MCP & Agent Skills for Automated Documentation, and codebase conventions + context

๐Ÿ’ป Developer Tools2 views
3KniGHtcZ/codebeamer-mcp

๐Ÿ“‡ โ˜๏ธ ๐ŸŽ ๐ŸชŸ ๐Ÿง - Codebeamer ALM integration for managing work items, trackers, and projects. Provides 17 tools for reading and writing items, associations, references, comments, and risk management data via Codebeamer REST API v3.

๐Ÿ’ป Developer Tools1 views
21st-dev/Magic-MCP

Create crafted UI components inspired by the best 21st.dev design engineers.

๐Ÿ’ป Developer Tools0 views
a-25/ios-mcp-code-quality-server

๐Ÿ“‡ ๐Ÿ  ๐ŸŽ - iOS code quality analysis and test automation server. Provides comprehensive Xcode test execution, SwiftLint integration, and detailed failure analysis. Operates in both CLI and MCP server modes for direct developer usage and AI assistant integration.

๐Ÿ’ป Developer Tools0 views

Engagement

Views
0
Installs
0
Upvotes
0

Views and upvotes are unique per visitor network (hashed IP). Installs count copy actions.

Status

Health: Not checked yet

We have not completed a health check for this listing yet.

No check timestamp yet.

Unclaimed listing (imported or pending owner verification). Claim it โ†’
โ˜… Spotlight Slot

Feature Your MCP Server

Get maximum visibility for your server across our directory, search results, and detail pages.

Spotlight Your Server

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Claim this listing

Promote this listing

Optional paid placement. Free listings stay free forever.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.