pan-wizard 2.8.1 → 2.9.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/README.md +4 -2
- package/bin/install.js +23 -0
- package/commands/pan/assumptions.md +38 -3
- package/commands/pan/audit-deployment.md +6 -0
- package/commands/pan/debug.md +71 -2
- package/commands/pan/exec-phase.md +90 -0
- package/commands/pan/focus-auto.md +181 -18
- package/commands/pan/focus-design.md +302 -14
- package/commands/pan/focus-doc-audit.md +530 -0
- package/commands/pan/focus-drift-walking.md +525 -0
- package/commands/pan/focus-exec.md +168 -46
- package/commands/pan/focus-plan.md +204 -12
- package/commands/pan/focus-scan.md +17 -5
- package/commands/pan/map-codebase.md +32 -6
- package/commands/pan/milestone-audit.md +23 -0
- package/commands/pan/new-project.md +64 -0
- package/commands/pan/pause.md +42 -1
- package/commands/pan/plan-phase.md +84 -0
- package/commands/pan/profile.md +2 -1
- package/commands/pan/quick.md +15 -0
- package/commands/pan/resume.md +62 -2
- package/commands/pan/verify-phase.md +42 -0
- package/package.json +1 -1
- package/pan-wizard-core/bin/lib/commands.cjs +29 -7
- package/pan-wizard-core/bin/lib/config.cjs +10 -0
- package/pan-wizard-core/bin/lib/constants.cjs +3 -1
- package/pan-wizard-core/bin/lib/core.cjs +168 -21
- package/pan-wizard-core/bin/lib/focus.cjs +5 -0
- package/pan-wizard-core/bin/lib/verify.cjs +283 -4
- package/pan-wizard-core/bin/pan-tools.cjs +11 -2
- package/pan-wizard-core/references/model-profiles.md +191 -62
- package/pan-wizard-core/workflows/help.md +11 -1
- package/pan-wizard-core/workflows/profile.md +8 -1
- package/pan-wizard-core/workflows/settings.md +14 -0
- package/scripts/generate-skills-docs.py +560 -0
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: focus-drift-walking
|
|
3
|
+
group: Focus
|
|
4
|
+
description: Deep documentation-code drift detection, CLAUDE.md alignment, and auto-repair across all project directories
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Bash
|
|
10
|
+
- Grep
|
|
11
|
+
- Glob
|
|
12
|
+
- Agent
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# /pan:focus-drift-walking — Documentation-Code Drift Detection & Alignment
|
|
16
|
+
|
|
17
|
+
Walk every directory in the project, detect drift between documentation and code reality, create missing documentation, repair drifted files, and synchronize the truth hierarchy. $ARGUMENTS
|
|
18
|
+
|
|
19
|
+
**Goal:** Eliminate the #1 cause of AI assistant hallucination — stale documentation. Walk the entire project tree, compare what documentation *claims* against what code *does*, score drift severity, and produce a complete alignment report with optional auto-repair. Every finding is evidence-based with file paths and line numbers.
|
|
20
|
+
|
|
21
|
+
**Methodology:** Combines directory-walking inventory, content fingerprinting, cross-reference validation, semantic drift scoring, and layered truth reconciliation into a single automated pipeline.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## CRITICAL: Project Scope Boundary
|
|
26
|
+
|
|
27
|
+
This command walks the **host project's directories and documentation** — NOT PAN Wizard's own infrastructure.
|
|
28
|
+
|
|
29
|
+
**ALWAYS EXCLUDE these directories from walking:**
|
|
30
|
+
- `.claude/`, `.github/copilot-instructions.md`, `.opencode/`, `.gemini/`, `.codex/` — PAN runtime directories
|
|
31
|
+
- `.planning/` — PAN planning state (read for context, never report as drift)
|
|
32
|
+
- Any `pan-wizard-core/`, `pan-tools`, agent `.md`, or command `.md` files within PAN runtime directories
|
|
33
|
+
- Build output directories: `build/`, `dist/`, `out/`, `target/`, `bin/`, `obj/`, `node_modules/`, `.git/`, `__pycache__/`, `.next/`, `.nuxt/`
|
|
34
|
+
|
|
35
|
+
**ALSO EXCLUDE:** Any directory listed in the project's `.gitignore` that represents generated output.
|
|
36
|
+
|
|
37
|
+
If a drift finding points to a file inside a PAN or build directory — DROP IT.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## MANDATORY: Execute ALL Phases Automatically
|
|
42
|
+
|
|
43
|
+
When `/pan:focus-drift-walking` is invoked, execute ALL phases for the selected mode without stopping. Do NOT ask questions between phases. Do NOT skip phases beyond what the mode specifies. Produce a complete drift report at the end.
|
|
44
|
+
|
|
45
|
+
**Flags:**
|
|
46
|
+
- `--create` — Create missing documentation files in directories that lack them
|
|
47
|
+
- `--audit` — Audit all existing documentation files for drift against code
|
|
48
|
+
- `--repair` — Auto-fix drifted documentation (update counts, paths, versions)
|
|
49
|
+
- `--report` — Dry run: detect and report drift without modifying anything
|
|
50
|
+
- `--dir <path>` — Target a specific directory subtree only
|
|
51
|
+
- `--depth <n>` — Limit walk depth (default: unlimited)
|
|
52
|
+
- `--severity <level>` — Filter report: `critical`, `warning`, `info` (default: all)
|
|
53
|
+
- `--format <type>` — Output format: `markdown` (default), `json`, `checklist`
|
|
54
|
+
- `--quick` — Skip Phase 4 (deep semantic analysis) and Phase 7 (cross-project sync)
|
|
55
|
+
|
|
56
|
+
**Default mode (no flags):** `--audit --report` — full audit with report, no modifications.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Truth Hierarchy
|
|
61
|
+
|
|
62
|
+
Documentation has layers. Drift detection must understand which layer is the source of truth for what:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
Layer 0: CODE (absolute truth)
|
|
66
|
+
│ Source files, config files, build scripts — what the project actually IS
|
|
67
|
+
│
|
|
68
|
+
Layer 1: PROJECT ROOT DOCS (primary documentation)
|
|
69
|
+
│ README.md, CLAUDE.md, package.json, Cargo.toml, CMakeLists.txt
|
|
70
|
+
│ Source of truth for: version, project name, top-level architecture, build commands
|
|
71
|
+
│
|
|
72
|
+
Layer 2: DIRECTORY-LEVEL DOCS (local documentation)
|
|
73
|
+
│ Per-directory README.md, CLAUDE.md, or equivalent
|
|
74
|
+
│ Source of truth for: directory purpose, local conventions, key files
|
|
75
|
+
│
|
|
76
|
+
Layer 3: INLINE DOCS (code-level documentation)
|
|
77
|
+
│ Comments, docstrings, JSDoc, XML docs
|
|
78
|
+
│ Source of truth for: function behavior, parameter semantics
|
|
79
|
+
│
|
|
80
|
+
Layer 4: EXTERNAL DOCS (generated/published documentation)
|
|
81
|
+
docs/, wiki/, guides, API references
|
|
82
|
+
Source of truth for: NOTHING (must be derived from Layers 0-3)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Drift direction rule:** Higher layers NEVER override lower layers. If code says X and docs say Y, the docs are wrong.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Phase 0: Initialization & Project Discovery
|
|
90
|
+
|
|
91
|
+
### 0.1 Detect Project Type
|
|
92
|
+
Automatically detect the project's technology stack and structure:
|
|
93
|
+
|
|
94
|
+
| Signal File | Indicates |
|
|
95
|
+
|------------|-----------|
|
|
96
|
+
| `package.json` | Node.js / JavaScript / TypeScript |
|
|
97
|
+
| `Cargo.toml` | Rust |
|
|
98
|
+
| `CMakeLists.txt` | C / C++ (CMake) |
|
|
99
|
+
| `*.csproj` / `*.sln` | .NET / C# |
|
|
100
|
+
| `go.mod` | Go |
|
|
101
|
+
| `pyproject.toml` / `setup.py` / `requirements.txt` | Python |
|
|
102
|
+
| `pom.xml` / `build.gradle` | Java / Kotlin |
|
|
103
|
+
| `pubspec.yaml` | Dart / Flutter |
|
|
104
|
+
| `Makefile` | Generic build system |
|
|
105
|
+
| `Dockerfile` | Containerized application |
|
|
106
|
+
| `terraform/` / `*.tf` | Infrastructure as Code |
|
|
107
|
+
|
|
108
|
+
Record all detected stacks — projects can be polyglot.
|
|
109
|
+
|
|
110
|
+
### 0.2 Extract Root Truth
|
|
111
|
+
Read the project's root-level documentation and extract canonical facts:
|
|
112
|
+
|
|
113
|
+
**From build/config files:**
|
|
114
|
+
- Project name and version
|
|
115
|
+
- Entry points and main modules
|
|
116
|
+
- Dependencies (count and key ones)
|
|
117
|
+
- Build commands
|
|
118
|
+
- Test commands
|
|
119
|
+
|
|
120
|
+
**From README.md / CLAUDE.md:**
|
|
121
|
+
- Stated architecture and component list
|
|
122
|
+
- Stated feature list
|
|
123
|
+
- Stated test counts
|
|
124
|
+
- Stated build/run instructions
|
|
125
|
+
- Stated directory structure
|
|
126
|
+
|
|
127
|
+
### 0.3 Build Directory Manifest
|
|
128
|
+
Walk the project tree and build a complete manifest:
|
|
129
|
+
|
|
130
|
+
```markdown
|
|
131
|
+
| Directory | Depth | Files | Has Docs | Doc Type | Key Content |
|
|
132
|
+
|-----------|-------|-------|----------|----------|-------------|
|
|
133
|
+
| src/ | 1 | 42 | ✅ | README.md | Application source |
|
|
134
|
+
| src/api/ | 2 | 18 | ❌ | — | API endpoints |
|
|
135
|
+
| tests/ | 1 | 31 | ✅ | README.md | Test suites |
|
|
136
|
+
| ... | | | | | |
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 0.4 Establish Baseline Snapshot
|
|
140
|
+
|
|
141
|
+
```markdown
|
|
142
|
+
| Metric | Value | Source |
|
|
143
|
+
|--------|-------|--------|
|
|
144
|
+
| Project version | X.Y.Z | {config file} |
|
|
145
|
+
| Total source files | N | Directory walk |
|
|
146
|
+
| Total test files | N | Directory walk |
|
|
147
|
+
| Directories with docs | N/M | Directory walk |
|
|
148
|
+
| Documentation coverage | N% | Dirs with docs / total dirs |
|
|
149
|
+
| Root doc files | N | README, CLAUDE, etc. |
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Phase 1: Directory-Level Analysis
|
|
155
|
+
|
|
156
|
+
For each directory in the manifest, perform deep content analysis.
|
|
157
|
+
|
|
158
|
+
### 1.1 Content Fingerprinting
|
|
159
|
+
For each directory, extract:
|
|
160
|
+
|
|
161
|
+
| Artifact | How to Extract |
|
|
162
|
+
|----------|---------------|
|
|
163
|
+
| **Purpose** | Infer from filenames, imports, exports, README |
|
|
164
|
+
| **Key files** | Files with most imports/references, entry points |
|
|
165
|
+
| **Public API** | Exported functions, classes, endpoints, commands |
|
|
166
|
+
| **Dependencies** | Import statements, require calls, use declarations |
|
|
167
|
+
| **Dependents** | What imports/references this directory |
|
|
168
|
+
| **Tech stack** | File extensions, framework imports |
|
|
169
|
+
| **Test coverage** | Corresponding test directory or test files |
|
|
170
|
+
| **Conventions** | Naming patterns, file organization, code style |
|
|
171
|
+
|
|
172
|
+
### 1.2 Documentation Inventory
|
|
173
|
+
For each directory that HAS documentation, catalog:
|
|
174
|
+
|
|
175
|
+
| Field | Extract From Doc |
|
|
176
|
+
|-------|-----------------|
|
|
177
|
+
| Stated purpose | First paragraph / "Purpose" section |
|
|
178
|
+
| Stated key files | "Key Files" table or list |
|
|
179
|
+
| Stated dependencies | "Dependencies" section |
|
|
180
|
+
| Stated conventions | "Conventions" / "Rules" section |
|
|
181
|
+
| Stated build commands | "Build" / "Usage" section |
|
|
182
|
+
| Version references | Any version numbers mentioned |
|
|
183
|
+
| File paths mentioned | All `path/to/file` references |
|
|
184
|
+
| Counts mentioned | Any numeric claims (N files, N tests, N endpoints) |
|
|
185
|
+
|
|
186
|
+
### 1.3 Importance Classification
|
|
187
|
+
Classify each directory for documentation priority:
|
|
188
|
+
|
|
189
|
+
| Tier | Criteria | Documentation Requirement |
|
|
190
|
+
|------|----------|--------------------------|
|
|
191
|
+
| **Tier 1: Core** | Contains primary application logic, public API, or critical infrastructure | MUST have comprehensive docs |
|
|
192
|
+
| **Tier 2: Supporting** | Contains utilities, helpers, internal services, tests | SHOULD have docs |
|
|
193
|
+
| **Tier 3: Config/Infra** | Contains configuration, CI/CD, build scripts | MAY have docs |
|
|
194
|
+
| **Tier 4: Generated/Vendored** | Contains generated code, vendored deps, build output | SKIP — no docs needed |
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Phase 2: Drift Detection Engine
|
|
199
|
+
|
|
200
|
+
For each directory with existing documentation, run ALL drift checks.
|
|
201
|
+
|
|
202
|
+
### 2.1 Structural Drift Checks
|
|
203
|
+
|
|
204
|
+
| Check ID | Check | How |
|
|
205
|
+
|----------|-------|-----|
|
|
206
|
+
| SD-01 | **File existence** | Every file path in docs → verify file exists |
|
|
207
|
+
| SD-02 | **File absence** | Important files in directory → verify mentioned in docs |
|
|
208
|
+
| SD-03 | **Directory structure** | Stated structure → compare to actual `ls` output |
|
|
209
|
+
| SD-04 | **Dead references** | File paths in docs that point to deleted/moved files |
|
|
210
|
+
| SD-05 | **Orphan files** | Key files not mentioned in any documentation |
|
|
211
|
+
|
|
212
|
+
### 2.2 Semantic Drift Checks
|
|
213
|
+
|
|
214
|
+
| Check ID | Check | How |
|
|
215
|
+
|----------|-------|-----|
|
|
216
|
+
| SM-01 | **Purpose drift** | Stated purpose vs. actual content — does the description match? |
|
|
217
|
+
| SM-02 | **API drift** | Documented exports/functions vs. actual code exports |
|
|
218
|
+
| SM-03 | **Dependency drift** | Stated deps vs. actual import/require statements |
|
|
219
|
+
| SM-04 | **Convention drift** | Stated patterns vs. actual code patterns |
|
|
220
|
+
| SM-05 | **Architecture drift** | Stated architecture vs. actual file organization |
|
|
221
|
+
|
|
222
|
+
### 2.3 Numeric Drift Checks
|
|
223
|
+
|
|
224
|
+
| Check ID | Check | How |
|
|
225
|
+
|----------|-------|-----|
|
|
226
|
+
| ND-01 | **Version drift** | Version in docs vs. version in config files |
|
|
227
|
+
| ND-02 | **Count drift** | Stated file/test/endpoint counts vs. actual counts |
|
|
228
|
+
| ND-03 | **Metric drift** | Stated performance/size claims vs. verifiable reality |
|
|
229
|
+
|
|
230
|
+
### 2.4 Command Drift Checks
|
|
231
|
+
|
|
232
|
+
| Check ID | Check | How |
|
|
233
|
+
|----------|-------|-----|
|
|
234
|
+
| CD-01 | **Build command drift** | Documented build commands → attempt to validate syntax |
|
|
235
|
+
| CD-02 | **Test command drift** | Documented test commands → attempt to validate syntax |
|
|
236
|
+
| CD-03 | **CLI usage drift** | Documented CLI flags → verify against actual CLI help/source |
|
|
237
|
+
|
|
238
|
+
### 2.5 Cross-Reference Drift Checks
|
|
239
|
+
|
|
240
|
+
| Check ID | Check | How |
|
|
241
|
+
|----------|-------|-----|
|
|
242
|
+
| XR-01 | **Root alignment** | Sub-directory docs contradict root docs |
|
|
243
|
+
| XR-02 | **Sibling alignment** | Directory A's docs claim about directory B → verify with B |
|
|
244
|
+
| XR-03 | **Circular contradiction** | A says X depends on Y, Y says it doesn't export to A |
|
|
245
|
+
| XR-04 | **Stale link targets** | Internal markdown links → verify targets exist and anchors resolve |
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Phase 3: Drift Severity Scoring
|
|
250
|
+
|
|
251
|
+
### 3.1 Severity Classification
|
|
252
|
+
|
|
253
|
+
| Level | Code | Meaning | Impact |
|
|
254
|
+
|-------|------|---------|--------|
|
|
255
|
+
| **CRITICAL** | `C` | Documentation will cause wrong code generation | AI assistants will hallucinate, developers will write bugs |
|
|
256
|
+
| **HIGH** | `H` | Documentation is significantly misleading | Developers waste significant time following wrong instructions |
|
|
257
|
+
| **MEDIUM** | `M` | Documentation is incomplete or partially wrong | Developers eventually figure it out but waste time |
|
|
258
|
+
| **LOW** | `L` | Documentation is stale but not actively misleading | Cosmetic / completeness issue |
|
|
259
|
+
| **INFO** | `I` | Suggestion for improvement, not actual drift | Nice-to-have |
|
|
260
|
+
|
|
261
|
+
### 3.2 Severity Assignment Rules
|
|
262
|
+
|
|
263
|
+
| Condition | Severity |
|
|
264
|
+
|-----------|----------|
|
|
265
|
+
| Wrong version number for a tool, SDK, or framework | CRITICAL |
|
|
266
|
+
| Wrong build command | CRITICAL |
|
|
267
|
+
| Referenced file does not exist | HIGH |
|
|
268
|
+
| Stated API/export that doesn't exist in code | HIGH |
|
|
269
|
+
| Wrong dependency direction | HIGH |
|
|
270
|
+
| Count off by > 20% | MEDIUM |
|
|
271
|
+
| Missing newly added key file from docs | MEDIUM |
|
|
272
|
+
| Convention described but code uses different pattern | MEDIUM |
|
|
273
|
+
| Count off by < 20% | LOW |
|
|
274
|
+
| Purpose statement is vaguely correct but imprecise | LOW |
|
|
275
|
+
| Missing optional section in docs | INFO |
|
|
276
|
+
|
|
277
|
+
### 3.3 Drift Score Formula
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
Directory Drift Score = Σ(severity_weight × check_count) / total_checks
|
|
281
|
+
|
|
282
|
+
Weights: CRITICAL=10, HIGH=5, MEDIUM=2, LOW=1, INFO=0
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
| Score | Rating | Action |
|
|
286
|
+
|-------|--------|--------|
|
|
287
|
+
| 0 | ALIGNED | No action needed |
|
|
288
|
+
| 0.1 - 1.0 | MINOR DRIFT | Low priority updates |
|
|
289
|
+
| 1.1 - 3.0 | MODERATE DRIFT | Schedule updates this session |
|
|
290
|
+
| 3.1 - 5.0 | SIGNIFICANT DRIFT | Update before next feature work |
|
|
291
|
+
| 5.1+ | SEVERE DRIFT | STOP — update immediately, docs are dangerous |
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Phase 4: Deep Semantic Analysis (skip with --quick)
|
|
296
|
+
|
|
297
|
+
For directories with MODERATE+ drift, perform deeper investigation.
|
|
298
|
+
|
|
299
|
+
### 4.1 Code-to-Doc Alignment Scan
|
|
300
|
+
For each public function/class/endpoint in the directory:
|
|
301
|
+
|
|
302
|
+
1. Read the implementation
|
|
303
|
+
2. Read the corresponding documentation
|
|
304
|
+
3. Compare: parameter names, return types, side effects, error conditions
|
|
305
|
+
4. Flag any semantic mismatch
|
|
306
|
+
|
|
307
|
+
### 4.2 Convention Archaeology
|
|
308
|
+
When docs claim a convention but code doesn't follow it:
|
|
309
|
+
|
|
310
|
+
1. `git log` the directory — did the convention change recently?
|
|
311
|
+
2. Count files following vs. not following the convention
|
|
312
|
+
3. Determine: is the doc wrong, or is the code drifting from convention?
|
|
313
|
+
|
|
314
|
+
### 4.3 Dependency Graph Verification
|
|
315
|
+
Build an actual dependency graph from import statements and compare to documented dependencies:
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
Actual: A → B → C → D
|
|
319
|
+
Stated: A → B → D (missing C in the chain)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Phase 5: Missing Documentation Creation (requires --create)
|
|
325
|
+
|
|
326
|
+
For Tier 1 and Tier 2 directories without documentation:
|
|
327
|
+
|
|
328
|
+
### 5.1 Generic Documentation Template
|
|
329
|
+
|
|
330
|
+
```markdown
|
|
331
|
+
# {Directory Name}
|
|
332
|
+
|
|
333
|
+
> Part of [{Project Name}]({relative path to root README or CLAUDE.md})
|
|
334
|
+
|
|
335
|
+
## Purpose
|
|
336
|
+
{1-3 sentences derived from actual file contents and directory name}
|
|
337
|
+
|
|
338
|
+
## Tech Stack
|
|
339
|
+
| Component | Value |
|
|
340
|
+
|-----------|-------|
|
|
341
|
+
| Language | {detected from file extensions} |
|
|
342
|
+
| Framework | {detected from imports/config} |
|
|
343
|
+
| Build | {detected from build files} |
|
|
344
|
+
|
|
345
|
+
## Key Files
|
|
346
|
+
| File | Purpose |
|
|
347
|
+
|------|---------|
|
|
348
|
+
| {entry point or main file} | {description} |
|
|
349
|
+
| {config file if present} | {description} |
|
|
350
|
+
| {most-imported file} | {description} |
|
|
351
|
+
|
|
352
|
+
## Architecture
|
|
353
|
+
{How code is organized — inferred from file structure and imports}
|
|
354
|
+
|
|
355
|
+
## Dependencies
|
|
356
|
+
- **Depends on:** {extracted from import statements}
|
|
357
|
+
- **Depended on by:** {extracted from reverse import search}
|
|
358
|
+
|
|
359
|
+
## Conventions
|
|
360
|
+
{Observed patterns: naming, file organization, code style}
|
|
361
|
+
|
|
362
|
+
## Build & Test
|
|
363
|
+
{Commands specific to this directory, if any}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### 5.2 Creation Rules
|
|
367
|
+
- NEVER create docs in build output or generated directories
|
|
368
|
+
- NEVER create docs in directories with < 3 source files (too trivial)
|
|
369
|
+
- NEVER include secrets, credentials, or API keys
|
|
370
|
+
- ALWAYS derive content from actual code — never guess
|
|
371
|
+
- ALWAYS include relative path back to root docs
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## Phase 6: Drift Repair (requires --repair)
|
|
376
|
+
|
|
377
|
+
### 6.1 Auto-Fixable Drift
|
|
378
|
+
These can be repaired automatically:
|
|
379
|
+
|
|
380
|
+
| Drift Type | Fix |
|
|
381
|
+
|-----------|-----|
|
|
382
|
+
| Wrong version number | Update to match config file |
|
|
383
|
+
| Wrong file count | Update to match actual count |
|
|
384
|
+
| Dead file reference | Remove reference or update path |
|
|
385
|
+
| Missing key file | Add to "Key Files" table |
|
|
386
|
+
| Wrong test count | Update to match actual count |
|
|
387
|
+
| Stale "last updated" date | Update to today |
|
|
388
|
+
| Broken internal link | Fix path or remove link |
|
|
389
|
+
|
|
390
|
+
### 6.2 Manual-Review Drift
|
|
391
|
+
These are flagged but NOT auto-fixed:
|
|
392
|
+
|
|
393
|
+
| Drift Type | Why |
|
|
394
|
+
|-----------|-----|
|
|
395
|
+
| Purpose statement drift | Subjective — needs human judgment |
|
|
396
|
+
| Architecture description | Complex — may need redesign of docs |
|
|
397
|
+
| Convention changes | Need team consensus on which is right |
|
|
398
|
+
| Dependency direction disputes | Need architectural review |
|
|
399
|
+
| Build command changes | Could break if wrong — verify first |
|
|
400
|
+
|
|
401
|
+
### 6.3 Repair Safety Protocol
|
|
402
|
+
Before modifying any file:
|
|
403
|
+
1. Record the original content of lines being changed
|
|
404
|
+
2. Make only minimal, targeted changes
|
|
405
|
+
3. Never rewrite entire files — patch specific sections
|
|
406
|
+
4. Add a comment or note indicating the drift repair date
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## Phase 7: Cross-Project Synchronization (skip with --quick)
|
|
411
|
+
|
|
412
|
+
### 7.1 Root Document Sync
|
|
413
|
+
After all directories are walked, sync findings back to root documentation:
|
|
414
|
+
|
|
415
|
+
1. **README.md** — Verify component/module counts, feature lists, directory descriptions
|
|
416
|
+
2. **CLAUDE.md** — Verify architecture claims, test counts, build commands, conventions
|
|
417
|
+
3. **CHANGELOG.md** — Verify latest version entry matches actual version
|
|
418
|
+
|
|
419
|
+
### 7.2 Truth Cascade
|
|
420
|
+
When root docs and sub-docs disagree:
|
|
421
|
+
|
|
422
|
+
| Disagreement Type | Resolution |
|
|
423
|
+
|-------------------|-----------|
|
|
424
|
+
| Root says version X, sub says version Y | Root wins — update sub |
|
|
425
|
+
| Root says build cmd X, sub says build cmd Y | Verify which works — update loser |
|
|
426
|
+
| Root says A depends on B, sub-B says no | Check actual imports — update wrong doc |
|
|
427
|
+
| Root lists N modules, actual count is M | Update root to M |
|
|
428
|
+
| Sub has local convention not in root | Keep in sub — local conventions are sub's truth |
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## Phase 8: Report Generation
|
|
433
|
+
|
|
434
|
+
### 8.1 Executive Summary
|
|
435
|
+
|
|
436
|
+
```markdown
|
|
437
|
+
## Drift Walking Report
|
|
438
|
+
|
|
439
|
+
**Project:** {name} v{version}
|
|
440
|
+
**Date:** {date}
|
|
441
|
+
**Directories walked:** {N}
|
|
442
|
+
**Documentation coverage:** {N}% ({dirs with docs} / {total meaningful dirs})
|
|
443
|
+
|
|
444
|
+
### Overall Health
|
|
445
|
+
| Rating | Count | % |
|
|
446
|
+
|--------|-------|---|
|
|
447
|
+
| ALIGNED | N | N% |
|
|
448
|
+
| MINOR DRIFT | N | N% |
|
|
449
|
+
| MODERATE DRIFT | N | N% |
|
|
450
|
+
| SIGNIFICANT DRIFT | N | N% |
|
|
451
|
+
| SEVERE DRIFT | N | N% |
|
|
452
|
+
| NO DOCS (Tier 1-2) | N | N% |
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### 8.2 Directory Detail Table
|
|
456
|
+
|
|
457
|
+
```markdown
|
|
458
|
+
| Directory | Tier | Has Docs | Drift Score | Rating | Top Issue |
|
|
459
|
+
|-----------|------|----------|-------------|--------|-----------|
|
|
460
|
+
| src/core/ | 1 | ✅ | 0.5 | MINOR | Count drift (tests: 42 → 48) |
|
|
461
|
+
| src/api/ | 1 | ❌ | — | NO DOCS | Tier 1 directory needs documentation |
|
|
462
|
+
| src/utils/ | 2 | ✅ | 3.2 | SIGNIFICANT | 4 dead file references |
|
|
463
|
+
| tests/ | 2 | ✅ | 0 | ALIGNED | — |
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### 8.3 Critical Findings (CRITICAL + HIGH severity)
|
|
467
|
+
|
|
468
|
+
```markdown
|
|
469
|
+
### Critical Findings
|
|
470
|
+
|
|
471
|
+
| ID | Directory | Check | Finding | Fix |
|
|
472
|
+
|----|-----------|-------|---------|-----|
|
|
473
|
+
| CF-01 | src/core/ | SD-01 | `handler.ts` referenced but was renamed to `router.ts` | Update reference |
|
|
474
|
+
| CF-02 | README.md | ND-01 | States v2.1.0, actual is v2.3.1 | Update version |
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### 8.4 Repair Log (if --repair was used)
|
|
478
|
+
|
|
479
|
+
```markdown
|
|
480
|
+
### Repairs Made
|
|
481
|
+
|
|
482
|
+
| File | Change | Before | After |
|
|
483
|
+
|------|--------|--------|-------|
|
|
484
|
+
| src/core/README.md | Version update | v2.1.0 | v2.3.1 |
|
|
485
|
+
| src/core/README.md | File count | 12 files | 15 files |
|
|
486
|
+
| README.md | Module count | 8 modules | 10 modules |
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
### 8.5 Recommendations
|
|
490
|
+
|
|
491
|
+
```markdown
|
|
492
|
+
### Recommended Actions (by priority)
|
|
493
|
+
|
|
494
|
+
1. **IMMEDIATE:** Fix {N} CRITICAL findings — these cause wrong AI output
|
|
495
|
+
2. **THIS SESSION:** Fix {N} HIGH findings — these waste developer time
|
|
496
|
+
3. **NEXT SESSION:** Create docs for {N} Tier 1 directories without documentation
|
|
497
|
+
4. **BACKLOG:** Address {N} MEDIUM findings, {N} LOW findings
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
## NEVER DO
|
|
503
|
+
|
|
504
|
+
- Walk build output directories (`build/`, `dist/`, `node_modules/`, `target/`, `obj/`, `__pycache__/`, `.git/`)
|
|
505
|
+
- Report PAN infrastructure files as project drift
|
|
506
|
+
- Auto-fix purpose statements, architecture descriptions, or conventions without `--repair`
|
|
507
|
+
- Create documentation for trivial directories (< 3 source files)
|
|
508
|
+
- Include secrets, credentials, or API keys in any generated documentation
|
|
509
|
+
- Guess at file contents — always read and verify
|
|
510
|
+
- Modify code files — this command only touches documentation files
|
|
511
|
+
- Override root documentation truth based on sub-directory claims (root is source of truth for project-wide facts)
|
|
512
|
+
- Report drift without evidence (file path + line number for every finding)
|
|
513
|
+
|
|
514
|
+
## ALWAYS DO
|
|
515
|
+
|
|
516
|
+
- Read actual source files before claiming drift — evidence-based only
|
|
517
|
+
- Include file paths and line numbers for every finding
|
|
518
|
+
- Score every drifted directory with the drift score formula
|
|
519
|
+
- Sort critical findings first in the report
|
|
520
|
+
- Respect the truth hierarchy (code > root docs > directory docs > inline docs > external docs)
|
|
521
|
+
- Walk ALL directories at the specified depth unless `--dir` constrains scope
|
|
522
|
+
- Report documentation coverage percentage
|
|
523
|
+
- Distinguish between "docs are wrong" and "docs are missing"
|
|
524
|
+
- Provide specific, actionable fix guidance for every finding
|
|
525
|
+
- Record repairs made if `--repair` is active
|