docguard-cli 0.9.4 → 0.9.6

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.
Files changed (36) hide show
  1. package/README.md +281 -203
  2. package/cli/commands/init.mjs +1 -0
  3. package/cli/scanners/speckit.mjs +318 -87
  4. package/cli/validators/metrics-consistency.mjs +2 -1
  5. package/cli/validators/traceability.mjs +17 -9
  6. package/commands/docguard.fix.md +65 -0
  7. package/commands/docguard.guard.md +60 -0
  8. package/commands/docguard.review.md +53 -0
  9. package/commands/docguard.score.md +61 -0
  10. package/docs/installation.md +37 -19
  11. package/docs/quickstart.md +21 -6
  12. package/extensions/spec-kit-docguard/LICENSE +21 -0
  13. package/extensions/spec-kit-docguard/README.md +105 -0
  14. package/extensions/spec-kit-docguard/commands/diagnose.md +43 -0
  15. package/extensions/spec-kit-docguard/commands/generate.md +50 -0
  16. package/extensions/spec-kit-docguard/commands/guard.md +73 -0
  17. package/extensions/spec-kit-docguard/commands/init.md +38 -0
  18. package/extensions/spec-kit-docguard/commands/score.md +53 -0
  19. package/extensions/spec-kit-docguard/commands/trace.md +56 -0
  20. package/extensions/spec-kit-docguard/extension.yml +109 -0
  21. package/extensions/spec-kit-docguard/scripts/bash/common.sh +106 -0
  22. package/extensions/spec-kit-docguard/scripts/bash/docguard-check-docs.sh +153 -0
  23. package/extensions/spec-kit-docguard/scripts/bash/docguard-init-doc.sh +153 -0
  24. package/extensions/spec-kit-docguard/scripts/bash/docguard-suggest-fix.sh +107 -0
  25. package/extensions/spec-kit-docguard/skills/docguard-fix/SKILL.md +218 -0
  26. package/extensions/spec-kit-docguard/skills/docguard-guard/SKILL.md +167 -0
  27. package/extensions/spec-kit-docguard/skills/docguard-review/SKILL.md +182 -0
  28. package/extensions/spec-kit-docguard/skills/docguard-score/SKILL.md +178 -0
  29. package/extensions/spec-kit-docguard/templates/extensions.yml +39 -0
  30. package/package.json +5 -2
  31. package/templates/REQUIREMENTS.md.template +68 -0
  32. package/templates/commands/docguard.fix.md +35 -39
  33. package/templates/commands/docguard.guard.md +26 -13
  34. package/templates/commands/docguard.init.md +35 -28
  35. package/templates/commands/docguard.review.md +33 -23
  36. package/templates/commands/docguard.update.md +15 -4
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env bash
2
+ # DocGuard — Suggest fixes based on guard/diagnose results
3
+ # Runs guard, parses results, outputs prioritized fix suggestions as JSON
4
+ #
5
+ # Usage:
6
+ # ./docguard-suggest-fix.sh [--json] [--top N]
7
+ #
8
+ # JSON output fields:
9
+ # GUARD_PASS — number of passing checks
10
+ # GUARD_TOTAL — total checks
11
+ # FINDINGS — array of {validator, severity, message, fix}
12
+ # TOP_FIX — the single highest-impact fix suggestion
13
+
14
+ set -e
15
+
16
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17
+ source "$SCRIPT_DIR/common.sh"
18
+
19
+ JSON_MODE=false
20
+ TOP_N=5
21
+
22
+ while [ $# -gt 0 ]; do
23
+ case "$1" in
24
+ --json) JSON_MODE=true ;;
25
+ --top)
26
+ shift
27
+ TOP_N="${1:-5}"
28
+ ;;
29
+ --help|-h)
30
+ echo "Usage: $0 [--json] [--top N]"
31
+ echo ""
32
+ echo "Options:"
33
+ echo " --json Output in JSON format"
34
+ echo " --top N Show top N fix suggestions (default: 5)"
35
+ echo " --help Show this help"
36
+ exit 0
37
+ ;;
38
+ *) echo "Unknown option: $1" >&2; exit 1 ;;
39
+ esac
40
+ shift
41
+ done
42
+
43
+ # Find project
44
+ PROJECT_ROOT=$(find_docguard_root "$(pwd)") || {
45
+ echo "Error: No DocGuard project found." >&2
46
+ exit 1
47
+ }
48
+
49
+ CLI_CMD=$(find_docguard_cli "$PROJECT_ROOT") || {
50
+ echo "Error: DocGuard CLI not found." >&2
51
+ exit 1
52
+ }
53
+
54
+ cd "$PROJECT_ROOT"
55
+
56
+ # Run guard and capture output
57
+ GUARD_OUTPUT=$(eval $CLI_CMD guard 2>&1 || true)
58
+
59
+ # Parse pass/total
60
+ GUARD_SUMMARY=$(echo "$GUARD_OUTPUT" | grep -o '[0-9]*/[0-9]* passed' || echo "0/0 passed")
61
+ GUARD_PASS=$(echo "$GUARD_SUMMARY" | sed 's|/.*||')
62
+ GUARD_TOTAL=$(echo "$GUARD_SUMMARY" | sed 's|.*/||; s| .*||')
63
+
64
+ # Extract warnings and failures
65
+ FINDINGS="[]"
66
+ if echo "$GUARD_OUTPUT" | grep -q "⚠\|❌"; then
67
+ # Extract warning/failure lines with validator context
68
+ FINDING_LINES=$(echo "$GUARD_OUTPUT" | grep -A1 "⚠\|❌" | grep "⚠ \|❌ " || true)
69
+
70
+ if [ -n "$FINDING_LINES" ]; then
71
+ FINDINGS="["
72
+ first=true
73
+ count=0
74
+ while IFS= read -r line; do
75
+ [ $count -ge $TOP_N ] && break
76
+ if [ "$first" = true ]; then first=false; else FINDINGS="$FINDINGS,"; fi
77
+
78
+ # Clean the line
79
+ clean_line=$(echo "$line" | sed 's/^[[:space:]]*//' | sed 's/⚠ //' | sed 's/❌ //')
80
+
81
+ # Determine severity
82
+ severity="MEDIUM"
83
+ echo "$line" | grep -q "❌" && severity="CRITICAL"
84
+ echo "$line" | grep -qi "security\|secret" && severity="CRITICAL"
85
+ echo "$line" | grep -qi "structure\|missing" && severity="HIGH"
86
+
87
+ FINDINGS="$FINDINGS{\"message\":\"$(json_escape "$clean_line")\",\"severity\":\"$severity\"}"
88
+ count=$((count + 1))
89
+ done <<< "$FINDING_LINES"
90
+ FINDINGS="$FINDINGS]"
91
+ fi
92
+ fi
93
+
94
+ if $JSON_MODE; then
95
+ echo "{\"guardPass\":$GUARD_PASS,\"guardTotal\":$GUARD_TOTAL,\"findings\":$FINDINGS}"
96
+ else
97
+ echo "Guard: $GUARD_PASS/$GUARD_TOTAL passed"
98
+ echo ""
99
+ if [ "$GUARD_PASS" = "$GUARD_TOTAL" ]; then
100
+ echo "✅ All checks passed! No fixes needed."
101
+ else
102
+ echo "Suggested fixes (top $TOP_N):"
103
+ echo "$GUARD_OUTPUT" | grep "⚠ \|❌ " | head -$TOP_N | while IFS= read -r line; do
104
+ echo " → $(echo "$line" | sed 's/^[[:space:]]*//')"
105
+ done
106
+ fi
107
+ fi
@@ -0,0 +1,218 @@
1
+ ---
2
+ name: docguard-fix
3
+ description: AI-driven documentation repair with structured research workflow, template-aware
4
+ generation, and quality validation loops. Generates or fixes canonical documentation
5
+ by researching the actual codebase, not using placeholders. Iterates until guard passes.
6
+ compatibility: Requires DocGuard CLI installed (npm i -g docguard-cli or npx docguard-cli)
7
+ metadata:
8
+ author: docguard
9
+ version: 0.9.5
10
+ source: extensions/spec-kit-docguard/skills/docguard-fix
11
+ ---
12
+
13
+ # DocGuard Fix Skill
14
+
15
+ ## User Input
16
+
17
+ ```text
18
+ $ARGUMENTS
19
+ ```
20
+
21
+ You **MUST** consider the user input before proceeding (if not empty).
22
+ If user specifies `--doc <name>`, focus on that single document.
23
+ If no arguments, fix ALL issues found by `docguard diagnose`.
24
+
25
+ ## Goal
26
+
27
+ Research the actual codebase to generate or repair canonical documentation that passes DocGuard's 19-validator guard suite. This skill replaces generic templates with real, project-specific content and iterates until quality checks pass.
28
+
29
+ ## Operating Constraints
30
+
31
+ - **NEVER use placeholder content** — every section must reference real files, real modules, real dependencies
32
+ - **ALWAYS back up before overwriting** — use `safeWrite()` pattern or create `.bak` files
33
+ - **Maximum 3 validation iterations** — if still failing after 3 rounds, report remaining issues and stop
34
+ - **Research before writing** — understand the codebase first, then generate documentation
35
+
36
+ ## Execution Flow
37
+
38
+ ### Step 1: Diagnose Current State
39
+
40
+ Run the diagnostic to identify all issues:
41
+
42
+ ```bash
43
+ npx docguard-cli diagnose 2>&1
44
+ ```
45
+
46
+ Parse the output to build an issue inventory:
47
+
48
+ | Issue ID | Severity | Category | File | Description | Autofix? |
49
+ |----------|----------|----------|------|-------------|----------|
50
+ | I001 | ERROR | Structure | SECURITY.md | Missing file | Yes |
51
+ | I002 | WARN | Freshness | ARCHITECTURE.md | 5 commits behind | Yes |
52
+ | ... | ... | ... | ... | ... | ... |
53
+
54
+ If `$ARGUMENTS` contains `--doc <name>`, filter to only issues affecting that document.
55
+
56
+ ### Step 2: Prioritize Fix Order
57
+
58
+ Sort issues by fix dependency and impact:
59
+
60
+ 1. **Structure** first (missing files must exist before checking sections)
61
+ 2. **Doc Sections** second (sections must exist before checking quality)
62
+ 3. **Doc-Quality** third (readability and language improvements)
63
+ 4. **Freshness** fourth (update `last-reviewed` dates)
64
+ 5. **Metadata-Sync** fifth (ensure headers are consistent)
65
+ 6. **Everything else** last
66
+
67
+ ### Step 3: Research the Codebase (Per Document)
68
+
69
+ For each document that needs fixing, execute a **targeted research pass**. Research must be thorough — read actual code, not just filenames.
70
+
71
+ #### For ARCHITECTURE.md:
72
+ 1. Read `package.json` for project name, description, dependencies, scripts
73
+ 2. List top-level directory structure (`ls -la`, focus on `src/`, `lib/`, `cli/`, `app/`)
74
+ 3. Identify entry points — check `main`, `bin`, `exports` in package.json
75
+ 4. For each major directory, read 2-3 representative files to understand purpose
76
+ 5. Map the import graph — which modules import which
77
+ 6. Identify external dependencies and their roles
78
+
79
+ #### For SECURITY.md:
80
+ 1. Check `.gitignore` for security-related patterns (`.env`, secrets, keys)
81
+ 2. Search for auth patterns: `grep -r "auth\|token\|jwt\|session\|password\|secret" src/ lib/ --include="*.js" --include="*.mjs"`
82
+ 3. Check `package.json` for auth dependencies (passport, jwt, bcrypt)
83
+ 4. Look for middleware, guards, or permission checks
84
+ 5. Check for `.env` files (document variable names only, NEVER values)
85
+ 6. Look for CORS, rate limiting, input validation
86
+
87
+ #### For TEST-SPEC.md:
88
+ 1. Read `package.json` scripts for test commands
89
+ 2. Find test files: `find . -name "*.test.*" -o -name "*.spec.*" | head -20`
90
+ 3. Read test configuration (jest.config, vitest.config, etc.)
91
+ 4. Read 2-3 test files to understand patterns
92
+ 5. Check for E2E setup (playwright, cypress)
93
+ 6. Look for CI config that runs tests
94
+
95
+ #### For DATA-MODEL.md:
96
+ 1. Search for schema definitions: `grep -r "Schema\|model\|Table\|Entity\|interface\|type " src/ lib/`
97
+ 2. Check for ORM configs (prisma, sequelize, mongoose, drizzle)
98
+ 3. Look for migration files
99
+ 4. Check for TypeScript interfaces/types defining data shapes
100
+ 5. Look for Zod schemas, JSON schemas, validation files
101
+ 6. If no database: document config file formats
102
+
103
+ #### For ENVIRONMENT.md:
104
+ 1. Read `package.json` for engines, scripts, dependencies
105
+ 2. Check for `.nvmrc`, `.node-version`, `.tool-versions`
106
+ 3. Search for `process.env` usage: `grep -r "process.env" src/ lib/ cli/`
107
+ 4. Check for `.env.example` or `.env.template`
108
+ 5. Check for Docker/docker-compose files
109
+ 6. Look for setup scripts
110
+
111
+ ### Step 4: Generate or Fix Document Content
112
+
113
+ For each document, follow this strict writing protocol:
114
+
115
+ 1. **Load the metadata header template**:
116
+ ```markdown
117
+ # [Document Title]
118
+
119
+ <!-- docguard:version X.X.X -->
120
+ <!-- docguard:status active -->
121
+ <!-- docguard:last-reviewed YYYY-MM-DD -->
122
+ ```
123
+
124
+ 2. **Write each mandatory section** using research findings:
125
+ - Use **actual file paths**, module names, and dependency names
126
+ - Use **markdown tables** for structured data (fields, types, constraints)
127
+ - Use **code blocks** for command examples (with actual working commands)
128
+ - Keep language **positive** (avoid negation — "MUST use" not "MUST NOT avoid")
129
+ - Write at **Flesch-Kincaid grade level 8-10** (clear, professional, not academic)
130
+
131
+ 3. **Validate mandatory sections exist**. Each canonical doc requires:
132
+ - **ARCHITECTURE.md**: System Overview, Component Map, Layer Boundaries, Data Flow, Technology Choices
133
+ - **SECURITY.md**: Auth Mechanism, Secrets Inventory, Secrets Storage, Permissions, Security Boundaries
134
+ - **TEST-SPEC.md**: Test Framework, Test Structure, Test Commands, Critical Flows, Coverage
135
+ - **DATA-MODEL.md**: Data Structures/Schemas, Field Types/Constraints, Relationships, Indexes
136
+ - **ENVIRONMENT.md**: Prerequisites, Setup Steps, Environment Variables
137
+ - **REQUIREMENTS.md**: Functional Requirements (FR-IDs), Non-Functional Requirements
138
+
139
+ 4. **Apply DocGuard quality rules**:
140
+ - Section count ≥ 3 per document
141
+ - No TODO/placeholder text in final output
142
+ - Positive language (IEEE 830 §4.3 compliance)
143
+ - Each section has substantive content (not just a heading)
144
+
145
+ ### Step 5: Format Compliance
146
+
147
+ Ensure every generated document follows CDD format rules:
148
+
149
+ - **Metadata header**: Must include `docguard:version`, `docguard:status`, `docguard:last-reviewed`
150
+ - **Heading hierarchy**: Single `# H1`, then `## H2` sections, then `### H3` subsections
151
+ - **Tables**: Use markdown tables for structured data (pipes aligned, header separators with 3+ dashes)
152
+ - **Code blocks**: Use fenced blocks with language identifier for all commands/code
153
+ - **Line length**: Keep lines under 120 characters for readability
154
+ - **No trailing whitespace**
155
+
156
+ ### Step 6: Validation Loop (Max 3 Iterations)
157
+
158
+ After writing/fixing each document:
159
+
160
+ 1. **Run guard on the specific validator**:
161
+ ```bash
162
+ npx docguard-cli guard 2>&1
163
+ ```
164
+
165
+ 2. **Parse results** for the affected validators
166
+ 3. **If still failing**:
167
+ - Identify exactly which checks are still failing
168
+ - Apply targeted fixes (not a full rewrite)
169
+ - Re-run guard
170
+ 4. **If passing after iteration**: Move to next document
171
+ 5. **If still failing after 3 iterations**: Report remaining issues with specific error details
172
+
173
+ ### Step 7: Completion Report
174
+
175
+ After all fixes are applied, output:
176
+
177
+ ```markdown
178
+ ## DocGuard Fix Report
179
+
180
+ ### Documents Fixed
181
+ | Document | Action | Checks Before | Checks After | Status |
182
+ |----------|--------|:------------:|:------------:|--------|
183
+ | SECURITY.md | Created | 0/2 | 2/2 | ✅ |
184
+ | ARCHITECTURE.md | Updated sections | 6/8 | 8/8 | ✅ |
185
+
186
+ ### Guard Score
187
+ - **Before**: [X]/[Y] checks passed
188
+ - **After**: [X]/[Y] checks passed
189
+ - **Improvement**: +[N] checks
190
+
191
+ ### Remaining Issues (if any)
192
+ - [Issue description] — [Why it couldn't be auto-fixed]
193
+
194
+ ### Suggested Next Steps
195
+ - Run `/docguard.guard` to verify full compliance
196
+ - Review generated content for accuracy
197
+ - Commit with: `docs: fix CDD documentation [list of docs fixed]`
198
+ ```
199
+
200
+ ## Behavior Rules
201
+
202
+ - **Research FIRST, write SECOND** — never generate content without reading the codebase
203
+ - **Be specific to THIS project** — don't add generic boilerplate for features the project doesn't have
204
+ - **Back up before overwriting** — if file exists, create `.bak` first or use `safeWrite()`
205
+ - **Respect existing content** — when updating, preserve user-written sections and only add/fix missing parts
206
+ - **Log deviations** — if you deviate from canonical expectations, add `// DRIFT: reason` in DRIFT-LOG.md
207
+ - **Never include secrets** — document variable/secret NAMES only, never actual values
208
+
209
+ ## Integration with Spec Kit
210
+
211
+ If `.specify/` directory exists:
212
+ - Check `constitution.md` for project principles before generating docs
213
+ - Align documentation language with constitutional requirements
214
+ - If `specs/*/spec.md` exists, cross-reference requirements with TEST-SPEC.md
215
+
216
+ ## Context
217
+
218
+ $ARGUMENTS
@@ -0,0 +1,167 @@
1
+ ---
2
+ name: docguard-guard
3
+ description: Run DocGuard guard validation against Canonical-Driven Development standards.
4
+ Parses output, triages severity, suggests targeted fixes, and optionally chains to
5
+ docguard-fix for automated remediation. Use as a quality gate before commits or after
6
+ implementation phases.
7
+ compatibility: Requires DocGuard CLI installed (npm i -g docguard-cli or npx docguard-cli)
8
+ metadata:
9
+ author: docguard
10
+ version: 0.9.5
11
+ source: extensions/spec-kit-docguard/skills/docguard-guard
12
+ ---
13
+
14
+ # DocGuard Guard Skill
15
+
16
+ ## User Input
17
+
18
+ ```text
19
+ $ARGUMENTS
20
+ ```
21
+
22
+ You **MUST** consider the user input before proceeding (if not empty).
23
+
24
+ ## Goal
25
+
26
+ Execute DocGuard's 19-validator guard suite against the current project, parse structured results, triage findings by severity and impact, and produce an actionable remediation plan. This skill transforms raw CLI output into an AI-digestible quality assessment.
27
+
28
+ ## Pre-Execution Checks
29
+
30
+ 1. **Verify DocGuard is available**:
31
+ - Check if `npx docguard-cli --version` succeeds
32
+ - If not available, check if `node cli/docguard.mjs --help` exists (local dev mode)
33
+ - If neither works: ERROR "DocGuard CLI not found. Install with: npm i -g docguard-cli"
34
+
35
+ 2. **Detect project root**:
36
+ - Look for `.docguard.json`, `docs-canonical/`, or `CHANGELOG.md` as project markers
37
+ - If none found: ERROR "No CDD project detected. Run `docguard init` first."
38
+
39
+ ## Execution Flow
40
+
41
+ ### Step 1: Run Guard with Machine-Readable Output
42
+
43
+ Execute the guard command and capture full output:
44
+
45
+ ```bash
46
+ npx docguard-cli guard 2>&1
47
+ ```
48
+
49
+ If in a DocGuard development environment (cli/docguard.mjs exists), use:
50
+ ```bash
51
+ node cli/docguard.mjs guard 2>&1
52
+ ```
53
+
54
+ ### Step 2: Parse Validator Results
55
+
56
+ Extract from guard output each validator's status. Build an internal results table:
57
+
58
+ | Validator | Priority | Checks Passed | Total Checks | Status |
59
+ |-----------|----------|---------------|--------------|--------|
60
+ | Structure | HIGH | N | M | ✅/⚠️/❌ |
61
+ | Doc Sections | HIGH | N | M | ✅/⚠️/❌ |
62
+ | ... | ... | ... | ... | ... |
63
+
64
+ **Status mapping**:
65
+ - `✅` = All checks passed
66
+ - `⚠️` = Warning (non-blocking, but should fix)
67
+ - `❌` = Failure (blocking — must fix before commit)
68
+
69
+ ### Step 3: Severity Triage
70
+
71
+ Classify every non-passing check using this priority matrix:
72
+
73
+ **CRITICAL (fix immediately)**:
74
+ - Structure failures (missing canonical docs)
75
+ - Security failures (hardcoded secrets, missing SECURITY.md)
76
+ - Test-Spec failures (tests don't match spec)
77
+
78
+ **HIGH (fix before commit)**:
79
+ - Doc Sections failures (missing required sections)
80
+ - Drift detection (undocumented code deviations)
81
+ - Changelog gaps
82
+ - Traceability breaks
83
+
84
+ **MEDIUM (fix this sprint)**:
85
+ - Freshness warnings (stale docs)
86
+ - Docs-Coverage gaps (undocumented config files)
87
+ - Doc-Quality issues (readability, negation language)
88
+ - Metrics-Consistency mismatches
89
+
90
+ **LOW (fix when convenient)**:
91
+ - TODO-Tracking items
92
+ - Schema-Sync gaps
93
+ - Metadata-Sync minor mismatches
94
+ - Spec-Kit warnings (spec structure gaps)
95
+
96
+ ### Step 4: Generate Triage Report
97
+
98
+ Output a structured markdown report:
99
+
100
+ ```markdown
101
+ ## DocGuard Guard Report
102
+
103
+ **Score**: [X]/[Y] checks passed ([percentage]%)
104
+ **Overall Status**: ✅ PASS | ⚠️ WARN | ❌ FAIL
105
+
106
+ ### Summary by Priority
107
+
108
+ | Priority | Count | Validators Affected |
109
+ |----------|-------|-------------------|
110
+ | CRITICAL | N | [list] |
111
+ | HIGH | N | [list] |
112
+ | MEDIUM | N | [list] |
113
+ | LOW | N | [list] |
114
+
115
+ ### Findings
116
+
117
+ #### CRITICAL
118
+ 1. [Validator]: [Specific issue] → **Fix**: [Exact action to take]
119
+
120
+ #### HIGH
121
+ 1. [Validator]: [Specific issue] → **Fix**: [Exact action to take]
122
+
123
+ [... continue for MEDIUM/LOW only if user requests or total findings < 10]
124
+ ```
125
+
126
+ ### Step 5: Remediation Recommendations
127
+
128
+ For each finding, provide a **specific, actionable fix** — not "fix the issue" but the exact file, section, and content to change:
129
+
130
+ - **Missing file**: "Create `docs-canonical/SECURITY.md` with metadata header and these sections: [list]"
131
+ - **Missing section**: "Add `## Threat Model` section to `docs-canonical/SECURITY.md` after line N"
132
+ - **Stale doc**: "Update `<!-- docguard:last-reviewed YYYY-MM-DD -->` in [file] to today's date"
133
+ - **Negation language**: "Replace 'Never store secrets in...' with 'Store secrets exclusively in...'"
134
+ - **Undocumented config**: "Add `.venv` documentation to `docs-canonical/ARCHITECTURE.md` under Developer Tools"
135
+
136
+ ### Step 6: Offer Next Actions
137
+
138
+ Based on the triage results:
139
+
140
+ - **If all PASS**: "All 19 validators passed. Project is CDD-compliant. Ready to commit."
141
+ - **If only MEDIUM/LOW warnings**: "Non-blocking warnings found. Safe to commit, but consider running `/docguard.fix` for automated remediation."
142
+ - **If HIGH or CRITICAL failures**: "Blocking issues found. Fix these before committing. Suggest running `/docguard.fix --doc [most impactful doc]` next."
143
+
144
+ Present the user with options:
145
+ 1. "Fix all automatically" → Suggest: `/docguard.fix`
146
+ 2. "Fix specific doc" → Suggest: `/docguard.fix --doc [name]`
147
+ 3. "Ignore warnings and proceed" → Warn about CDD compliance gap
148
+
149
+ ## Behavior Rules
150
+
151
+ - **ALWAYS run the actual CLI** — never simulate or guess guard results
152
+ - **Parse real output** — don't hallucinate check counts or validator names
153
+ - **Be specific** — every fix recommendation must reference an actual file path
154
+ - **Respect severity** — don't escalate LOW to CRITICAL or vice versa
155
+ - **Track progress** — if user runs guard multiple times, compare before/after
156
+ - If user provides `$ARGUMENTS` like "just structure" or "only security", filter report to those validators
157
+
158
+ ## Integration with Spec Kit
159
+
160
+ If this project has `.specify/` directory (spec-kit enabled):
161
+ - Include Spec-Kit validator results in the triage
162
+ - Cross-reference spec quality issues with `specs/*/spec.md` file paths
163
+ - Suggest `/speckit.analyze` if spec-related findings exceed 3
164
+
165
+ ## Context
166
+
167
+ $ARGUMENTS
@@ -0,0 +1,182 @@
1
+ ---
2
+ name: docguard-review
3
+ description: Cross-document consistency analysis and quality assessment. Performs read-only
4
+ analysis across all canonical docs, identifies drift, coverage gaps, and quality issues.
5
+ Produces a structured report with severity-ranked findings. Modeled after speckit-analyze.
6
+ compatibility: Requires DocGuard CLI installed (npm i -g docguard-cli or npx docguard-cli)
7
+ metadata:
8
+ author: docguard
9
+ version: 0.9.5
10
+ source: extensions/spec-kit-docguard/skills/docguard-review
11
+ ---
12
+
13
+ # DocGuard Review Skill
14
+
15
+ ## User Input
16
+
17
+ ```text
18
+ $ARGUMENTS
19
+ ```
20
+
21
+ You **MUST** consider the user input before proceeding (if not empty).
22
+
23
+ ## Goal
24
+
25
+ Perform a comprehensive, **read-only** analysis of the project's documentation health. Unlike `/docguard.guard` (which runs CLI validators), this skill performs **semantic analysis** — checking whether documentation actually matches the codebase, whether cross-references are consistent, and whether the documentation tells a coherent story.
26
+
27
+ ## Operating Constraints
28
+
29
+ **STRICTLY READ-ONLY**: Do **not** modify any files. Output a structured analysis report only. Offer remediation suggestions that the user must explicitly approve before any changes are made.
30
+
31
+ ## Execution Flow
32
+
33
+ ### Step 1: Gather Documentation Inventory
34
+
35
+ 1. **List all canonical docs**: Read every file in `docs-canonical/`
36
+ 2. **List support files**: Check for `CHANGELOG.md`, `DRIFT-LOG.md`, `AGENTS.md`, `README.md`, `ROADMAP.md`
37
+ 3. **Check for spec-kit artifacts**: If `.specify/` exists, include `specs/*/spec.md`, `specs/*/plan.md`, `specs/*/tasks.md`
38
+ 4. **Build a document map**:
39
+
40
+ | Document | Exists | Last Modified | Size | Metadata Version |
41
+ |----------|--------|---------------|------|-----------------|
42
+ | ARCHITECTURE.md | ✅ | 2026-03-14 | 5.2KB | 0.5.0 |
43
+ | SECURITY.md | ✅ | 2026-03-14 | 3.1KB | 0.5.0 |
44
+ | ... | ... | ... | ... | ... |
45
+
46
+ ### Step 2: Run Quantitative Analysis
47
+
48
+ Execute DocGuard's diagnostic and scoring tools:
49
+
50
+ ```bash
51
+ npx docguard-cli diagnose 2>&1
52
+ npx docguard-cli score 2>&1
53
+ npx docguard-cli guard 2>&1
54
+ ```
55
+
56
+ Record:
57
+ - Guard pass/fail counts per validator
58
+ - CDD maturity score (0-100)
59
+ - ALCOA+ compliance attributes
60
+ - Category breakdown
61
+
62
+ ### Step 3: Semantic Cross-Document Analysis
63
+
64
+ This is the **unique value** of the review skill — analysis that CLI validators cannot do.
65
+
66
+ #### A. Terminology Consistency
67
+ - Extract key technical terms from each document
68
+ - Flag terms used differently across documents (e.g., "validator" vs "checker" vs "rule")
69
+ - Flag abbreviations used without definition
70
+ - Build a de facto glossary
71
+
72
+ #### B. Architecture ↔ Code Alignment
73
+ - Read ARCHITECTURE.md component list
74
+ - Verify each listed component actually exists as a directory/module
75
+ - Flag components that exist in code but are missing from ARCHITECTURE.md
76
+ - Flag components listed in ARCHITECTURE.md that don't exist in code
77
+
78
+ #### C. Data Model ↔ Code Alignment
79
+ - Read DATA-MODEL.md schemas/structures
80
+ - Search codebase for actual data structures
81
+ - Flag schemas documented but not implemented
82
+ - Flag schemas implemented but not documented
83
+
84
+ #### D. Test Coverage ↔ Test-Spec Alignment
85
+ - Read TEST-SPEC.md critical flows
86
+ - Check actual test files exist for each critical flow
87
+ - Flag test scenarios documented but not implemented
88
+ - Flag test files with no corresponding TEST-SPEC.md entry
89
+
90
+ #### E. Security Claims ↔ Implementation
91
+ - Read SECURITY.md auth/secrets claims
92
+ - Verify auth implementation exists in code
93
+ - Check that listed secrets are actually used
94
+ - Flag security-relevant code not mentioned in SECURITY.md
95
+
96
+ #### F. Cross-Reference Integrity
97
+ - Find all internal doc links (`[text](file)` and `See ARCHITECTURE.md`)
98
+ - Verify every referenced file/section actually exists
99
+ - Flag broken cross-references
100
+ - Flag orphaned sections not referenced anywhere
101
+
102
+ ### Step 4: Quality Assessment
103
+
104
+ For each document, evaluate:
105
+
106
+ | Criterion | Weight | Score | Notes |
107
+ |-----------|--------|-------|-------|
108
+ | Completeness | 30% | 0-10 | Are all mandatory sections present? |
109
+ | Accuracy | 30% | 0-10 | Does content match actual codebase? |
110
+ | Clarity | 20% | 0-10 | Readability, specificity, no jargon |
111
+ | Currency | 10% | 0-10 | Is content up-to-date with latest code? |
112
+ | Cross-refs | 10% | 0-10 | Are references valid and bidirectional? |
113
+
114
+ ### Step 5: Severity Classification
115
+
116
+ Classify every finding using this matrix:
117
+
118
+ - **CRITICAL**: Security claim doesn't match implementation, missing mandatory doc, broken architecture reference
119
+ - **HIGH**: Undocumented component, stale content (>5 commits behind), terminology conflict
120
+ - **MEDIUM**: Missing cross-reference, minor coverage gap, readability issue
121
+ - **LOW**: Formatting inconsistency, optional section missing, minor terminology drift
122
+
123
+ ### Step 6: Produce Analysis Report
124
+
125
+ Output a structured markdown report (do NOT write to disk):
126
+
127
+ ```markdown
128
+ ## DocGuard Documentation Review
129
+
130
+ ### Executive Summary
131
+ - **Overall Health**: [A+/A/B/C/D/F] ([score]/100)
132
+ - **Documents Analyzed**: [N]
133
+ - **Findings**: [CRITICAL: N, HIGH: N, MEDIUM: N, LOW: N]
134
+ - **Top Risk**: [Most impactful finding]
135
+
136
+ ### Findings Table
137
+
138
+ | ID | Category | Severity | Location | Summary | Recommendation |
139
+ |----|----------|----------|----------|---------|----------------|
140
+ | R01 | Terminology | HIGH | ARCH:L15, SEC:L22 | "validator" vs "checker" | Standardize on "validator" |
141
+ | R02 | Coverage | MEDIUM | DATA-MODEL.md | Schema X undocumented | Add Schema X to Data Model |
142
+
143
+ ### Per-Document Health
144
+
145
+ | Document | Completeness | Accuracy | Clarity | Currency | Cross-refs | Overall |
146
+ |----------|:----------:|:-------:|:------:|:-------:|:----------:|:-------:|
147
+ | ARCHITECTURE.md | 9/10 | 8/10 | 9/10 | 7/10 | 10/10 | 8.8/10 |
148
+ | SECURITY.md | 8/10 | 9/10 | 8/10 | 9/10 | 7/10 | 8.4/10 |
149
+
150
+ ### Semantic Consistency
151
+ - **Terminology conflicts**: [N found]
152
+ - **Architecture gaps**: [N components undocumented]
153
+ - **Broken cross-refs**: [N found]
154
+ - **Test coverage gaps**: [N critical flows untested]
155
+
156
+ ### Recommendations (Priority Order)
157
+ 1. [Most impactful fix] — estimated effort: [LOW/MEDIUM/HIGH]
158
+ 2. [Second most impactful] — estimated effort: [LOW/MEDIUM/HIGH]
159
+ 3. ...
160
+ ```
161
+
162
+ ### Step 7: Offer Next Actions
163
+
164
+ Based on findings:
165
+ - **If CRITICAL issues**: "Run `/docguard.fix --doc [name]` to resolve blocking issues"
166
+ - **If only LOW/MEDIUM**: "Documentation is healthy. Consider `/docguard.fix` for polish"
167
+ - **If all clean**: "Documentation is excellent. No action needed."
168
+
169
+ Ask: "Would you like me to fix the top N issues? (I'll show you what I plan to change before applying)"
170
+
171
+ ## Behavior Rules
172
+
173
+ - **NEVER modify files** — this is strictly read-only analysis
174
+ - **ALWAYS run real CLI commands** — don't simulate or guess results
175
+ - **Be specific** — cite exact file paths, line numbers, and content
176
+ - **Compare actual code vs docs** — don't just validate formatting
177
+ - **Limit findings to 50** — aggregate overflow in a summary count
178
+ - **Prioritize high-signal findings** — one CRITICAL finding is worth ten LOW findings
179
+
180
+ ## Context
181
+
182
+ $ARGUMENTS