The enforcement tool for Canonical-Driven Development (CDD). Audit, generate, and guard your project documentation. Zero dependencies.
Project description
๐ก๏ธ DocGuard
The enforcement layer for Spec-Driven Development. Validate. Score. Enforce. Ship documentation that AI agents can actually use.
Table of Contents
- What is DocGuard?
- Quick Start
- Spec Kit Integration
- Commands
- Validators
- Templates
- AI Agent Support
- Slash Commands
- Examples
- Testing
- CI/CD Integration
- File Structure
- Configuration
- Research Credits
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 Development | Canonical-Driven Development |
|---|---|
| Code first, docs maybe | Docs first, code conforms |
| Docs rot silently | Drift is tracked and enforced |
| Docs are optional | Docs are required and validated |
| One AI agent, one context | Any 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 ยท ๐บ๏ธ Roadmap
Architecture
graph TD
CLI["CLI Entry<br/>docguard.mjs"] --> Commands["Commands (15)"]
Commands --> guard["guard"]
Commands --> generate["generate"]
Commands --> score["score"]
Commands --> diagnose["diagnose"]
Commands --> setup["setup wizard"]
Commands --> other["diff ยท init ยท fix ยท trace<br/>agents ยท hooks ยท badge ยท ci ยท watch"]
guard --> Validators["Validators (19)"]
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)
โก Quick Start
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.
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. Zero human intervention required.
๐ฑ 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) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
| Phase | Tool | What happens |
|---|---|---|
| 1. Initialize | specify init |
Creates .specify/ directory and templates |
| 2. Write specs | /speckit.specify |
AI creates spec.md with FR-IDs, user stories |
| 3. Validate | docguard guard |
Checks spec quality (mandatory sections, FR/SC IDs) |
| 4. Plan | /speckit.plan |
AI creates plan.md with technical context |
| 5. Validate | docguard guard |
Checks plan quality (sections, structure) |
| 6. Tasks | /speckit.tasks |
AI creates tasks.md with phased breakdown |
| 7. Validate | docguard guard |
Checks task quality (phases, T-IDs) |
| 8. Implement | /speckit.implement |
AI writes code |
| 9. Enforce | docguard guard |
Final 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.mdor 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.guard, /docguard.review, /docguard.fix, /docguard.score) into your AI agent's command palette.
Usage
DocGuard ships 13 commands:
| Command | Purpose |
|---|---|
diagnose |
Primary โ identify every issue + generate AI fix prompts |
guard |
Validate project against canonical docs (CI gate) |
generate |
Reverse-engineer docs from existing codebase |
init |
Initialize CDD docs from templates (interactive) |
score |
CDD maturity score (0โ100) with weighted breakdown |
fix --doc <name> |
Generate AI prompt for a specific document |
diff |
Compare canonical docs vs actual code artifacts |
agents |
Generate agent-specific config files |
trace |
Requirements traceability matrix |
ci |
CI/CD pipeline check with threshold |
watch |
Live watch mode with auto-fix |
hooks |
Install git hooks (pre-commit, pre-push) |
llms |
Generate llms.txt (AI-friendly project summary) |
CLI Flags
| Flag | Description | Commands |
|---|---|---|
--dir <path> |
Project directory (default: .) |
All |
--verbose |
Show detailed output | All |
--format json |
Machine-readable output for CI/CD | score, guard, diff |
--force |
Overwrite existing files (creates .bak backups) |
generate, agents, init |
--profile <name> |
Starter, standard, or enterprise | init |
--agent <name> |
Target specific AI agent | agents |
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 19 automated validators on every guard check:
| # | Validator | What It Checks | Default |
|---|---|---|---|
| 1 | Structure | Required CDD files exist | โ On |
| 2 | Doc Sections | Canonical docs have required sections | โ On |
| 3 | Docs-Sync | Routes/services referenced in docs + OpenAPI cross-check | โ On |
| 4 | Drift | // DRIFT: comments logged in DRIFT-LOG.md |
โ On |
| 5 | Changelog | CHANGELOG.md has [Unreleased] section | โ On |
| 6 | Test-Spec | Tests exist per TEST-SPEC.md rules | โ On |
| 7 | Environment | Env vars documented, .env.example exists | โ On |
| 8 | Security | No hardcoded secrets in source code | โ On |
| 9 | Architecture | Imports follow layer boundaries | โ On |
| 10 | Freshness | Docs not stale relative to code changes | โ On |
| 11 | Traceability | Requirement IDs (FR, SC, NFR, US, AC, T) trace to tests | โ On |
| 12 | Docs-Diff | Code artifacts match documented entities | โ On |
| 13 | Metadata-Sync | Version refs consistent across docs | โ On |
| 14 | Docs-Coverage | Code features referenced in documentation | โ On |
| 15 | Metrics-Consistency | Hardcoded numbers match actual counts | โ On |
| 16 | Doc-Quality | Writing quality (readability, passive voice, atomicity) | โ On |
| 17 | TODO-Tracking | Untracked TODOs/FIXMEs and skipped tests | โ On |
| 18 | Schema-Sync | Database models documented in DATA-MODEL.md | โ On |
| 19 | Spec-Kit | Spec quality validation (FR-IDs, mandatory sections, phased tasks) | โ On |
๐ Templates
DocGuard ships 18 professional templates with metadata, badges, and revision history:
| Template | Type | Purpose |
|---|---|---|
| ARCHITECTURE.md | Canonical | System design, components, layer boundaries |
| DATA-MODEL.md | Canonical | Schemas, entities, relationships |
| SECURITY.md | Canonical | Auth, permissions, secrets management |
| TEST-SPEC.md | Canonical | Test strategy, coverage requirements |
| ENVIRONMENT.md | Canonical | Environment variables, deployment config |
| REQUIREMENTS.md | Canonical | Spec-kit aligned FR/SC IDs, user stories |
| DEPLOYMENT.md | Canonical | Infrastructure, CI/CD, DNS |
| ADR.md | Canonical | Architecture Decision Records |
| ROADMAP.md | Canonical | Project phases, feature tracking |
| KNOWN-GOTCHAS.md | Implementation | Symptom โ gotcha โ fix entries |
| TROUBLESHOOTING.md | Implementation | Error diagnosis guides |
| RUNBOOKS.md | Implementation | Operational procedures |
| VENDOR-BUGS.md | Implementation | Third-party issue tracker |
| CURRENT-STATE.md | Implementation | Deployment status, tech debt |
| AGENTS.md | Agent | AI agent behavior rules |
| CHANGELOG.md | Tracking | Change log |
| DRIFT-LOG.md | Tracking | Deviation tracking |
| llms.txt | Generated | AI-friendly project summary (llmstxt.org) |
๐ค AI Agent Support
DocGuard works with every major AI coding agent. All canonical docs are plain markdown โ no vendor lock-in.
| Agent | Compatibility | Auto-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) | โ | โ |
โก Slash Commands
DocGuard provides AI agent slash commands for integrated workflows. Installed automatically via docguard init or specify extension add docguard:
| Command | What It Does |
|---|---|
/docguard.guard |
Run quality validation โ check all 19 validators |
/docguard.review |
Analyze doc quality and suggest improvements |
/docguard.fix |
Generate targeted fix prompts for specific issues |
/docguard.score |
Show CDD maturity score with category breakdown |
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.
| Skill | Lines | What It Does |
|---|---|---|
docguard-guard |
155 | 6-step quality gate with severity triage (CRITICALโLOW), structured reporting, remediation |
docguard-fix |
195 | 7-step research workflow with per-document codebase research and 3-iteration validation loops |
docguard-review |
170 | Read-only semantic cross-document analysis with 6 analysis passes and quality scoring |
docguard-score |
165 | CDD maturity assessment with ROI-based improvement roadmap and grade progression |
Workflow Hooks
DocGuard integrates into the spec-kit workflow as an automated quality gate:
| Hook | When | Behavior |
|---|---|---|
after_implement |
After /speckit.implement |
Mandatory โ always runs DocGuard guard |
before_tasks |
Before /speckit.tasks |
Optional โ reviews doc consistency |
after_tasks |
After /speckit.tasks |
Optional โ shows CDD maturity score |
Orchestration Scripts
For advanced users and CI/CD pipelines, DocGuard includes bash scripts with --json output:
| Script | Purpose |
|---|---|
docguard-check-docs.sh |
Discover project docs, return JSON inventory with metadata |
docguard-suggest-fix.sh |
Run guard, parse results, output prioritized fixes |
docguard-init-doc.sh |
Initialize canonical doc with metadata header |
๐ Examples
Three real-world projects to see DocGuard in action:
| Example | Scenario | What You'll See |
|---|---|---|
| 01-express-api | Node.js API with zero docs | Cold-start: generate โ instant coverage |
| 02-python-flask | Python app with drifted docs | Drift detection: catch when docs lie |
| 03-spec-kit-project | Full CDD + Spec Kit | Gold 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.js | OS | Status |
|---|---|---|
| 18 | ubuntu-latest | โ |
| 20 | ubuntu-latest | โ |
| 22 | ubuntu-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.
โ๏ธ CI/CD Integration
GitHub Actions
name: DocGuard CDD Check
on: [pull_request]
jobs:
docguard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npx docguard-cli guard
- run: npx docguard-cli score --format json
Pre-commit Hook
npx docguard-cli hooks --type pre-commit
GitHub Marketplace
- uses: raccioly/docguard@v0.9.7
with:
command: guard
fail-on-warning: true
๐ 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:
- AITPG โ AI-driven Test Plan Generator using Multi-Agent Debate and RAG (Lopez et al., IEEE TSE 2026)
- TRACE โ Telecom Root Cause Analysis through Calibrated Explainability (Lopez et al., IEEE TMLCN 2026)
Lead researcher: Martin Manuel Lopez ยท ORCID 0009-0002-7652-2385
See CONTRIBUTING.md for full citations.
๐ License
MIT โ Free to use, modify, and distribute.
Made with โค๏ธ by Ricardo Accioly
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docguard_cli-0.9.11.tar.gz.
File metadata
- Download URL: docguard_cli-0.9.11.tar.gz
- Upload date:
- Size: 331.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76f27b7e0511107ec37227aa7dea41daf631fe114a4fc39eb8b445f08be12aef
|
|
| MD5 |
2383151b1225ff90a8b28cebd779c9e6
|
|
| BLAKE2b-256 |
e690c80f9ca45cd8b43b328c338a010f5c49bcabff8ef5d5b76559edb451162d
|
File details
Details for the file docguard_cli-0.9.11-py3-none-any.whl.
File metadata
- Download URL: docguard_cli-0.9.11-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e064dd26067151ea2ba78dd1bb69f5465dc4a4a940729657759b117d74b75baa
|
|
| MD5 |
a037098f6f37cb6095519eff210f9c2c
|
|
| BLAKE2b-256 |
fe485a0737b2b9d6fce2cc331401f2222ef00e791ef721ed5357df8e845bc935
|