docguard-cli 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/PHILOSOPHY.md +150 -0
- package/README.md +309 -0
- package/STANDARD.md +751 -0
- package/cli/commands/agents.mjs +221 -0
- package/cli/commands/audit.mjs +92 -0
- package/cli/commands/badge.mjs +72 -0
- package/cli/commands/ci.mjs +80 -0
- package/cli/commands/diagnose.mjs +273 -0
- package/cli/commands/diff.mjs +360 -0
- package/cli/commands/fix.mjs +610 -0
- package/cli/commands/generate.mjs +842 -0
- package/cli/commands/guard.mjs +158 -0
- package/cli/commands/hooks.mjs +227 -0
- package/cli/commands/init.mjs +249 -0
- package/cli/commands/score.mjs +396 -0
- package/cli/commands/watch.mjs +143 -0
- package/cli/docguard.mjs +458 -0
- package/cli/validators/architecture.mjs +380 -0
- package/cli/validators/changelog.mjs +39 -0
- package/cli/validators/docs-sync.mjs +110 -0
- package/cli/validators/drift.mjs +101 -0
- package/cli/validators/environment.mjs +70 -0
- package/cli/validators/freshness.mjs +224 -0
- package/cli/validators/security.mjs +101 -0
- package/cli/validators/structure.mjs +88 -0
- package/cli/validators/test-spec.mjs +115 -0
- package/docs/ai-integration.md +179 -0
- package/docs/commands.md +239 -0
- package/docs/configuration.md +96 -0
- package/docs/faq.md +155 -0
- package/docs/installation.md +81 -0
- package/docs/profiles.md +103 -0
- package/docs/quickstart.md +79 -0
- package/package.json +57 -0
- package/templates/ADR.md.template +64 -0
- package/templates/AGENTS.md.template +88 -0
- package/templates/ARCHITECTURE.md.template +78 -0
- package/templates/CHANGELOG.md.template +16 -0
- package/templates/CURRENT-STATE.md.template +64 -0
- package/templates/DATA-MODEL.md.template +66 -0
- package/templates/DEPLOYMENT.md.template +66 -0
- package/templates/DRIFT-LOG.md.template +18 -0
- package/templates/ENVIRONMENT.md.template +43 -0
- package/templates/KNOWN-GOTCHAS.md.template +69 -0
- package/templates/ROADMAP.md.template +82 -0
- package/templates/RUNBOOKS.md.template +115 -0
- package/templates/SECURITY.md.template +42 -0
- package/templates/TEST-SPEC.md.template +55 -0
- package/templates/TROUBLESHOOTING.md.template +96 -0
- package/templates/VENDOR-BUGS.md.template +74 -0
- package/templates/ci/github-actions.yml +39 -0
- package/templates/commands/docguard.fix.md +65 -0
- package/templates/commands/docguard.guard.md +40 -0
- package/templates/commands/docguard.init.md +62 -0
- package/templates/commands/docguard.review.md +44 -0
- package/templates/commands/docguard.update.md +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ricardo Accioly
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/PHILOSOPHY.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# The Philosophy of Canonical-Driven Development
|
|
2
|
+
|
|
3
|
+
> Why documentation must come first in the age of AI agents.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The Problem We're Solving
|
|
8
|
+
|
|
9
|
+
In 2026, AI coding agents can write thousands of lines of code in minutes. They can scaffold entire applications, implement complex features, and refactor entire codebases.
|
|
10
|
+
|
|
11
|
+
But they have a fatal flaw: **they don't remember.**
|
|
12
|
+
|
|
13
|
+
Every new session, every new agent, every new conversation starts from zero. The agent reads your code, makes assumptions, and builds on those assumptions. If the assumptions are wrong, the code drifts. If the code drifts long enough, nobody — human or AI — knows what the system was supposed to do in the first place.
|
|
14
|
+
|
|
15
|
+
This is the **documentation crisis of the AI era:**
|
|
16
|
+
|
|
17
|
+
> The faster AI writes code, the faster projects lose their design intent.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## The Insight
|
|
22
|
+
|
|
23
|
+
The solution isn't to write better code. It's to write better **canonical documentation** — and make it machine-enforceable.
|
|
24
|
+
|
|
25
|
+
> **Canonical** (adj.): accepted as being accurate and authoritative; the standard form.
|
|
26
|
+
|
|
27
|
+
When every AI agent starts by reading canonical documentation that describes what the system IS, what it SHOULD do, and where it has DRIFTED — the agent doesn't need to guess. It doesn't need to reverse-engineer intent from code. It has the source of truth, in a format it can understand instantly.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## The Three Pillars of CDD
|
|
32
|
+
|
|
33
|
+
### Pillar 1: Documentation IS the Source of Truth
|
|
34
|
+
|
|
35
|
+
In traditional development, code is the source of truth. Documentation is an afterthought — written after code (if at all), rarely updated, and quickly stale.
|
|
36
|
+
|
|
37
|
+
In CDD, this is inverted:
|
|
38
|
+
|
|
39
|
+
| Traditional | CDD |
|
|
40
|
+
|-------------|-----|
|
|
41
|
+
| Code first, docs maybe | Docs first, code conforms |
|
|
42
|
+
| Docs describe code | Code implements docs |
|
|
43
|
+
| Docs rot silently | Drift is tracked explicitly |
|
|
44
|
+
| Docs are optional | Docs are required and validated |
|
|
45
|
+
|
|
46
|
+
This doesn't mean you write a 500-page specification before writing any code. It means:
|
|
47
|
+
- When starting a project, write `ARCHITECTURE.md` before `index.ts`
|
|
48
|
+
- When adding a feature, update `FEATURES.md` before opening your editor
|
|
49
|
+
- When the code deviates, log it in `DRIFT-LOG.md` instead of pretending the docs are wrong
|
|
50
|
+
|
|
51
|
+
### Pillar 2: Two Tiers, Two Purposes
|
|
52
|
+
|
|
53
|
+
CDD separates documentation into two tiers:
|
|
54
|
+
|
|
55
|
+
**Canonical docs** (`docs-canonical/`) are the blueprint. They represent design intent — what we WANT the system to be. They're updated deliberately, through design decisions, not as a side effect of coding.
|
|
56
|
+
|
|
57
|
+
**Implementation docs** (`docs-implementation/`) are the map. They represent current state — what we HAVE built. They're updated as code changes, reflecting reality.
|
|
58
|
+
|
|
59
|
+
The gap between these two tiers is **drift** — and drift is not a bug, it's a feature. Real projects always have some gap between intent and reality. CDD acknowledges this and provides a structured way to track it (`DRIFT-LOG.md`), instead of the traditional approach of either:
|
|
60
|
+
- Pretending the docs are still accurate (lying)
|
|
61
|
+
- Silently updating docs to match the broken code (losing intent)
|
|
62
|
+
|
|
63
|
+
### Pillar 3: Machine-Enforceable, Not Machine-Generated
|
|
64
|
+
|
|
65
|
+
Many tools generate docs from code. CDD does the opposite: it validates code against docs.
|
|
66
|
+
|
|
67
|
+
This is a fundamental philosophical difference:
|
|
68
|
+
|
|
69
|
+
| Generated Docs (traditional) | Enforced Docs (CDD) |
|
|
70
|
+
|------------------------------|---------------------|
|
|
71
|
+
| Machine reads code → produces docs | Machine reads docs → validates code |
|
|
72
|
+
| Docs always match code (including bugs) | Docs represent intent (bugs are caught as drift) |
|
|
73
|
+
| Docs are disposable artifacts | Docs are authoritative sources |
|
|
74
|
+
| No governance, no warnings | Validators catch misalignment |
|
|
75
|
+
|
|
76
|
+
DocGuard CAN generate docs from existing codebases (for adoption). But the intent is that once generated, those docs become the canonical source — and future code must conform to them.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Why Now?
|
|
81
|
+
|
|
82
|
+
Three forces are converging in 2025-2026 that make CDD necessary:
|
|
83
|
+
|
|
84
|
+
### 1. AI Agents Are Becoming Primary Developers
|
|
85
|
+
|
|
86
|
+
AI agents (Claude, Gemini, Copilot, Cursor) are writing an increasing share of production code. These agents need structured context to work effectively. The better the documentation, the better the output.
|
|
87
|
+
|
|
88
|
+
### 2. Multi-Agent Development Is Real
|
|
89
|
+
|
|
90
|
+
It's common for a single project to be worked on by Claude Code, Copilot, Cursor, and a human — sometimes in the same week. Each agent needs a common source of truth. `AGENTS.md` provides behavioral rules; canonical docs provide design knowledge.
|
|
91
|
+
|
|
92
|
+
### 3. The Documentation Crisis Is Accelerating
|
|
93
|
+
|
|
94
|
+
AI makes it trivially easy to add code. Nobody is making it easy to maintain documentation. The result: projects with 100,000 lines of code and a 50-line README. CDD addresses this by making documentation a first-class, validated artifact.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## CDD and Other Methodologies
|
|
99
|
+
|
|
100
|
+
CDD doesn't replace existing methodologies. It enhances them:
|
|
101
|
+
|
|
102
|
+
### CDD + TDD (Test-Driven Development)
|
|
103
|
+
Write canonical docs first. The TEST-SPEC.md in your canonical docs declares what tests must exist. TDD then drives the implementation of those tests. CDD governs the test policy; TDD governs the test implementation.
|
|
104
|
+
|
|
105
|
+
### CDD + BDD (Behavior-Driven Development)
|
|
106
|
+
Behavior specifications can live in `docs-canonical/FEATURES.md`. BDD's Given/When/Then scenarios become part of the canonical record. DocGuard can validate that corresponding E2E tests exist.
|
|
107
|
+
|
|
108
|
+
### CDD + SDD (Spec-Driven Development)
|
|
109
|
+
SDD tools like GitHub Spec Kit handle the generation phase (spec → code). CDD adds the governance phase (code ↔ spec, continuously). Use Spec Kit for Phase 1-2 of the CDD lifecycle, then DocGuard for Phase 3-4.
|
|
110
|
+
|
|
111
|
+
### CDD + Agile/Scrum
|
|
112
|
+
Canonical docs don't need to be waterfall-length documents. A 30-line `ARCHITECTURE.md` is valid. The key is that it EXISTS, is MAINTAINED, and is VALIDATED. Sprint-by-sprint, canonical docs grow alongside the codebase.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## The CDD Promise
|
|
117
|
+
|
|
118
|
+
If your project follows CDD:
|
|
119
|
+
|
|
120
|
+
1. **Any AI agent can onboard** to your project in seconds — not minutes of code analysis, but seconds of reading structured documentation.
|
|
121
|
+
|
|
122
|
+
2. **Design intent is never lost** — even when the original developer leaves, the canonical docs preserve WHY the system was designed the way it was.
|
|
123
|
+
|
|
124
|
+
3. **Drift is conscious** — every deviation from the plan is documented, justified, and trackable. No silent rot.
|
|
125
|
+
|
|
126
|
+
4. **Quality is enforceable** — DocGuard validators run in CI/CD, catching missing tests, undocumented routes, and unlogged drift before code ships.
|
|
127
|
+
|
|
128
|
+
5. **Documentation stays alive** — because it's validated on every commit, docs can't rot. If code changes, DocGuard catches the misalignment.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Getting Started
|
|
133
|
+
|
|
134
|
+
CDD is designed for progressive adoption:
|
|
135
|
+
|
|
136
|
+
**Day 1**: Create `AGENTS.md` and `docs-canonical/ARCHITECTURE.md`. Two files. That's CDD.
|
|
137
|
+
|
|
138
|
+
**Week 1**: Add `DATA-MODEL.md`, `SECURITY.md`, `TEST-SPEC.md`, `ENVIRONMENT.md`. Run `docguard audit` to see your score.
|
|
139
|
+
|
|
140
|
+
**Month 1**: Add `DRIFT-LOG.md`, `CHANGELOG.md`. Run `docguard guard` in your pre-commit hook. You're now fully CDD-compliant.
|
|
141
|
+
|
|
142
|
+
**Forever**: Every commit is validated. Every drift is logged. Every agent understands your project.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
This philosophy document and the CDD methodology are released under the [MIT License](https://opensource.org/licenses/MIT).
|
|
149
|
+
|
|
150
|
+
CDD is an open methodology. Anyone can adopt, adapt, and contribute to it.
|
package/README.md
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# DocGuard
|
|
2
|
+
|
|
3
|
+
> **AI-native documentation enforcement for Canonical-Driven Development (CDD).**
|
|
4
|
+
> AI diagnoses. AI fixes. AI verifies. Humans review.
|
|
5
|
+
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
[](package.json)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## What is CDD?
|
|
13
|
+
|
|
14
|
+
**Canonical-Driven Development** is a methodology where canonical documentation drives every phase of a project — from initial design through ongoing maintenance. Unlike traditional development where docs are written after code (and quickly rot), CDD treats documentation as the authoritative source that code must conform to.
|
|
15
|
+
|
|
16
|
+
| Traditional | CDD |
|
|
17
|
+
|-------------|-----|
|
|
18
|
+
| Code first, docs maybe | Docs first, code conforms |
|
|
19
|
+
| Docs rot silently | Drift is tracked explicitly |
|
|
20
|
+
| Docs are optional | Docs are required and validated |
|
|
21
|
+
| One agent, one context | Any agent, shared context |
|
|
22
|
+
|
|
23
|
+
**DocGuard** is the CLI tool that enforces CDD — auditing, generating, and guarding your project documentation.
|
|
24
|
+
|
|
25
|
+
📖 **[Read the full philosophy](PHILOSOPHY.md)** | 📋 **[Read the standard](STANDARD.md)** | ⚖️ **[See comparisons](COMPARISONS.md)** | 🗺️ **[Roadmap](ROADMAP.md)**
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# The primary command — AI diagnoses AND fixes everything
|
|
33
|
+
npx docguard diagnose
|
|
34
|
+
|
|
35
|
+
# Generate CDD docs from an existing codebase
|
|
36
|
+
npx docguard generate
|
|
37
|
+
|
|
38
|
+
# Start from scratch (minimal setup for side projects)
|
|
39
|
+
npx docguard init --profile starter
|
|
40
|
+
|
|
41
|
+
# Start from scratch (full enterprise setup)
|
|
42
|
+
npx docguard init
|
|
43
|
+
|
|
44
|
+
# CI gate — pass/fail for pipelines
|
|
45
|
+
npx docguard guard
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
No installation needed. Zero dependencies. Works with Node.js 18+.
|
|
49
|
+
|
|
50
|
+
### The AI Loop
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
diagnose → AI reads prompts → AI fixes docs → guard verifies
|
|
54
|
+
↑ ↓
|
|
55
|
+
└───────────────── issues found? ←──────────────────────┘
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`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.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 13 Commands
|
|
63
|
+
|
|
64
|
+
### 🔮 Generate — Reverse-engineer docs from code
|
|
65
|
+
```
|
|
66
|
+
$ npx docguard generate
|
|
67
|
+
|
|
68
|
+
🔮 DocGuard Generate — my-project
|
|
69
|
+
Scanning codebase to generate canonical documentation...
|
|
70
|
+
|
|
71
|
+
Detected Stack:
|
|
72
|
+
language: TypeScript ^5.0
|
|
73
|
+
framework: Next.js ^14.0
|
|
74
|
+
database: PostgreSQL
|
|
75
|
+
orm: Drizzle 0.33
|
|
76
|
+
testing: Vitest
|
|
77
|
+
hosting: AWS Amplify
|
|
78
|
+
|
|
79
|
+
✅ ARCHITECTURE.md (4 components, 6 tech)
|
|
80
|
+
✅ DATA-MODEL.md (12 entities detected)
|
|
81
|
+
✅ ENVIRONMENT.md (18 env vars detected)
|
|
82
|
+
✅ TEST-SPEC.md (45 tests, 8/10 services mapped)
|
|
83
|
+
✅ SECURITY.md (auth: NextAuth.js)
|
|
84
|
+
✅ AGENTS.md
|
|
85
|
+
✅ CHANGELOG.md
|
|
86
|
+
✅ DRIFT-LOG.md
|
|
87
|
+
|
|
88
|
+
Generated: 8 Skipped: 0
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Detects:** Next.js, React, Vue, Angular, Fastify, Express, Hono, Django, FastAPI, SvelteKit, and more.
|
|
92
|
+
**Scans for:** Routes, models, services, tests, env vars, components, middleware.
|
|
93
|
+
|
|
94
|
+
### 📊 Score — CDD maturity assessment
|
|
95
|
+
```
|
|
96
|
+
$ npx docguard score
|
|
97
|
+
|
|
98
|
+
Category Breakdown
|
|
99
|
+
|
|
100
|
+
structure ████████████████████ 100% (×25) = 25 pts
|
|
101
|
+
docQuality ██████████████████░░ 90% (×20) = 18 pts
|
|
102
|
+
testing █████████░░░░░░░░░░░ 45% (×15) = 7 pts
|
|
103
|
+
security █████████████████░░░ 85% (×10) = 9 pts
|
|
104
|
+
environment ██████████████░░░░░░ 70% (×10) = 7 pts
|
|
105
|
+
drift ████████████████████ 100% (×10) = 10 pts
|
|
106
|
+
changelog ██████████████░░░░░░ 70% (×5) = 4 pts
|
|
107
|
+
architecture █████████████████░░░ 85% (×5) = 4 pts
|
|
108
|
+
|
|
109
|
+
CDD Maturity Score: 83/100 (A)
|
|
110
|
+
Great — Strong CDD compliance
|
|
111
|
+
|
|
112
|
+
Top improvements:
|
|
113
|
+
→ testing: Add tests/ directory and configure TEST-SPEC.md
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 🔍 Diff — Canonical docs vs code comparison
|
|
117
|
+
```
|
|
118
|
+
$ npx docguard diff
|
|
119
|
+
|
|
120
|
+
🛣️ API Routes
|
|
121
|
+
In code but not documented:
|
|
122
|
+
+ src/routes/webhooks.ts
|
|
123
|
+
+ src/routes/admin/settings.ts
|
|
124
|
+
✓ In sync: 12 routes
|
|
125
|
+
|
|
126
|
+
🔧 Environment Variables
|
|
127
|
+
Documented but not found in .env.example:
|
|
128
|
+
− REDIS_URL
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 🤖 Agents — Generate agent-specific configs
|
|
132
|
+
```
|
|
133
|
+
$ npx docguard agents
|
|
134
|
+
|
|
135
|
+
✅ Cursor: .cursor/rules/cdd.mdc
|
|
136
|
+
✅ GitHub Copilot: .github/copilot-instructions.md
|
|
137
|
+
✅ Cline: .clinerules
|
|
138
|
+
✅ Windsurf: .windsurfrules
|
|
139
|
+
✅ Claude Code: CLAUDE.md
|
|
140
|
+
✅ Gemini CLI: .gemini/settings.json
|
|
141
|
+
|
|
142
|
+
Created: 6 Skipped: 0
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 🔍 Audit — What docs exist/missing
|
|
146
|
+
```
|
|
147
|
+
$ npx docguard audit
|
|
148
|
+
|
|
149
|
+
Score: 8/8 required files (100%)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 🏗️ Init — Create CDD docs from templates
|
|
153
|
+
```
|
|
154
|
+
$ npx docguard init
|
|
155
|
+
|
|
156
|
+
Created 9 files (8 docs + .docguard.json)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 🛡️ Guard — Validate project against docs
|
|
160
|
+
```
|
|
161
|
+
$ npx docguard guard
|
|
162
|
+
|
|
163
|
+
✅ Structure 8/8 checks passed
|
|
164
|
+
✅ Doc Sections 10/10 checks passed
|
|
165
|
+
✅ Drift 1/1 checks passed
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## CLI Flags
|
|
171
|
+
|
|
172
|
+
| Flag | Description | Commands |
|
|
173
|
+
|------|-------------|----------|
|
|
174
|
+
| `--dir <path>` | Project directory (default: `.`) | All |
|
|
175
|
+
| `--verbose` | Show detailed output | All |
|
|
176
|
+
| `--format json` | Output as JSON for CI/CD | score, diff |
|
|
177
|
+
| `--fix` | Auto-create missing files | guard |
|
|
178
|
+
| `--force` | Overwrite existing files | generate, agents, init |
|
|
179
|
+
| `--agent <name>` | Target specific agent | agents |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 9 Validators
|
|
184
|
+
|
|
185
|
+
| # | Validator | What It Checks | Default |
|
|
186
|
+
|---|-----------|---------------|---------|
|
|
187
|
+
| 1 | **Structure** | Required CDD files exist | ✅ On |
|
|
188
|
+
| 2 | **Doc Sections** | Canonical docs have required sections | ✅ On |
|
|
189
|
+
| 3 | **Docs-Sync** | Routes/services referenced in docs | ✅ On |
|
|
190
|
+
| 4 | **Drift** | `// DRIFT:` comments logged in DRIFT-LOG.md | ✅ On |
|
|
191
|
+
| 5 | **Changelog** | CHANGELOG.md has [Unreleased] section | ✅ On |
|
|
192
|
+
| 6 | **Test-Spec** | Tests exist per TEST-SPEC.md rules | ✅ On |
|
|
193
|
+
| 7 | **Environment** | Env vars documented, .env.example exists | ✅ On |
|
|
194
|
+
| 8 | **Security** | No hardcoded secrets in source code | ❌ Off |
|
|
195
|
+
| 9 | **Architecture** | Imports follow layer boundaries | ❌ Off |
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 16 Templates
|
|
200
|
+
|
|
201
|
+
Every template includes professional metadata: `docguard:version`, `docguard:status`, badges, and revision history.
|
|
202
|
+
|
|
203
|
+
| Template | Type | Purpose |
|
|
204
|
+
|----------|------|---------|
|
|
205
|
+
| ARCHITECTURE.md | Canonical | System design, components, boundaries |
|
|
206
|
+
| DATA-MODEL.md | Canonical | Schemas, entities, relationships |
|
|
207
|
+
| SECURITY.md | Canonical | Auth, permissions, secrets |
|
|
208
|
+
| TEST-SPEC.md | Canonical | Required tests, coverage |
|
|
209
|
+
| ENVIRONMENT.md | Canonical | Env vars, setup steps |
|
|
210
|
+
| DEPLOYMENT.md | Canonical | Infrastructure, CI/CD, DNS |
|
|
211
|
+
| ADR.md | Canonical | Architecture Decision Records |
|
|
212
|
+
| ROADMAP.md | Canonical | Project phases, feature tracking |
|
|
213
|
+
| KNOWN-GOTCHAS.md | Implementation | Symptom/gotcha/fix entries |
|
|
214
|
+
| TROUBLESHOOTING.md | Implementation | Error diagnosis guides |
|
|
215
|
+
| RUNBOOKS.md | Implementation | Operational procedures |
|
|
216
|
+
| VENDOR-BUGS.md | Implementation | Third-party issue tracker |
|
|
217
|
+
| CURRENT-STATE.md | Implementation | Deployment status, tech debt |
|
|
218
|
+
| AGENTS.md | Agent | AI agent behavior rules |
|
|
219
|
+
| CHANGELOG.md | Tracking | Change log |
|
|
220
|
+
| DRIFT-LOG.md | Tracking | Deviation tracking |
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## CDD File Structure
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
your-project/
|
|
228
|
+
├── docs-canonical/ # Design intent (the "blueprint")
|
|
229
|
+
│ ├── ARCHITECTURE.md # System design, components, boundaries
|
|
230
|
+
│ ├── DATA-MODEL.md # Database schemas, entity relationships
|
|
231
|
+
│ ├── SECURITY.md # Auth, permissions, secrets
|
|
232
|
+
│ ├── TEST-SPEC.md # Required tests, coverage rules
|
|
233
|
+
│ └── ENVIRONMENT.md # Environment variables, setup
|
|
234
|
+
│
|
|
235
|
+
├── docs-implementation/ # Current state (optional)
|
|
236
|
+
│ ├── KNOWN-GOTCHAS.md # Lessons learned
|
|
237
|
+
│ ├── TROUBLESHOOTING.md # Error solutions
|
|
238
|
+
│ ├── RUNBOOKS.md # Operational procedures
|
|
239
|
+
│ └── CURRENT-STATE.md # What's deployed now
|
|
240
|
+
│
|
|
241
|
+
├── AGENTS.md # AI agent behavior rules
|
|
242
|
+
├── CHANGELOG.md # Change tracking
|
|
243
|
+
├── DRIFT-LOG.md # Documented deviations
|
|
244
|
+
└── .docguard.json # DocGuard configuration
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## CI/CD Integration
|
|
250
|
+
|
|
251
|
+
### GitHub Actions
|
|
252
|
+
|
|
253
|
+
```yaml
|
|
254
|
+
name: DocGuard
|
|
255
|
+
on: [pull_request]
|
|
256
|
+
jobs:
|
|
257
|
+
guard:
|
|
258
|
+
runs-on: ubuntu-latest
|
|
259
|
+
steps:
|
|
260
|
+
- uses: actions/checkout@v4
|
|
261
|
+
- uses: actions/setup-node@v4
|
|
262
|
+
with:
|
|
263
|
+
node-version: '20'
|
|
264
|
+
- run: npx docguard guard
|
|
265
|
+
- run: npx docguard score --format json
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Pre-commit Hook
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# .git/hooks/pre-commit
|
|
272
|
+
#!/bin/sh
|
|
273
|
+
npx docguard guard
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Agent Compatibility
|
|
279
|
+
|
|
280
|
+
DocGuard works with **every major AI coding agent**:
|
|
281
|
+
|
|
282
|
+
| Agent | Compatibility | Auto-Generate Config |
|
|
283
|
+
|-------|:---:|:---:|
|
|
284
|
+
| Google Antigravity | ✅ | — |
|
|
285
|
+
| Claude Code | ✅ | `docguard agents --agent claude` |
|
|
286
|
+
| GitHub Copilot | ✅ | `docguard agents --agent copilot` |
|
|
287
|
+
| Cursor | ✅ | `docguard agents --agent cursor` |
|
|
288
|
+
| Windsurf | ✅ | `docguard agents --agent windsurf` |
|
|
289
|
+
| Cline | ✅ | `docguard agents --agent cline` |
|
|
290
|
+
| Gemini CLI | ✅ | `docguard agents --agent gemini` |
|
|
291
|
+
| Kiro (AWS) | ✅ | — |
|
|
292
|
+
|
|
293
|
+
All canonical docs are **plain markdown** — any agent can read them. No vendor lock-in.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Contributing
|
|
298
|
+
|
|
299
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## License
|
|
304
|
+
|
|
305
|
+
[MIT](LICENSE) — Free to use, modify, and distribute.
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
**Made with ❤️ by [Ricardo Accioly](https://github.com/raccioly)**
|