@thedecipherist/mdd 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +707 -97
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,11 +1,25 @@
1
1
  <p align="center">
2
- <img src="docs/mdd_hero.webp" alt="MDD Manual-Driven Development for Claude Code" width="100%" />
2
+ <img src="docs/mdd_hero.webp" alt="MDD - Manual-Driven Development for Claude Code" width="100%" />
3
3
  </p>
4
4
 
5
- # MDD Manual-Driven Development for Claude Code
5
+ # MDD - Manual-Driven Development for Claude Code
6
6
 
7
7
  > **One command. Twenty-one modes. Complete feature lifecycle from documentation to verified deployment.**
8
8
 
9
+ <p align="center">
10
+ <a href="https://thedecipherist.github.io/mdd">
11
+ <img src="https://img.shields.io/badge/📖_Documentation-thedecipherist.github.io%2Fmdd-00e5cc?style=for-the-badge&labelColor=08090f" alt="Documentation Site" />
12
+ </a>
13
+ &nbsp;
14
+ <a href="https://thedecipherist.github.io/mdd/user-guide.html">
15
+ <img src="https://img.shields.io/badge/📚_User_Guide-Full_Reference-00ff88?style=for-the-badge&labelColor=08090f" alt="User Guide" />
16
+ </a>
17
+ </p>
18
+
19
+ [![npm version](https://img.shields.io/npm/v/@thedecipherist/mdd)](https://www.npmjs.com/package/@thedecipherist/mdd)
20
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
21
+ [![Node.js ≥18](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)
22
+
9
23
  MDD turns Claude Code from a code generator into a structured development partner. Every feature starts with documentation. Every fix starts with an audit. No exceptions.
10
24
 
11
25
  ```bash
@@ -18,23 +32,69 @@ Then in Claude Code:
18
32
  /mdd add user authentication with JWT tokens
19
33
  ```
20
34
 
35
+ 📖 **[Full Documentation Site](https://thedecipherist.github.io/mdd)** · [User Guide](https://thedecipherist.github.io/mdd/user-guide.html) · [GitHub](https://github.com/TheDecipherist/mdd)
36
+
37
+ ---
38
+
39
+ ## Contents
40
+
41
+ - [Why MDD](#why-mdd)
42
+ - [How It Works](#how-it-works)
43
+ - [Installation](#installation)
44
+ - [Quick Start](#quick-start)
45
+ - [All 21 Modes at a Glance](#all-21-modes-at-a-glance)
46
+ - [Build Mode - Feature Development](#build-mode--feature-development)
47
+ - [Audit Mode - Code Review](#audit-mode--code-review)
48
+ - [Status & Notes](#status--notes)
49
+ - [Scan & Update - Drift Detection](#scan--update--drift-detection)
50
+ - [Feature Lifecycle](#feature-lifecycle)
51
+ - [Initiative & Wave Planning](#initiative--wave-planning)
52
+ - [Ops Runbooks](#ops-runbooks)
53
+ - [Feature Doc Format](#feature-doc-format)
54
+ - [The `.mdd/` Directory](#the-mdd-directory)
55
+ - [MDD Versioning](#mdd-versioning)
56
+ - [Real Results: Self-Audit](#real-results-self-audit)
57
+ - [History: From Starter Kit to Standalone Package](#history-from-starter-kit-to-standalone-package)
58
+ - [Companion Tools](#companion-tools)
59
+ - [License](#license)
60
+
21
61
  ---
22
62
 
23
- ## Why MDD?
63
+ ## Why MDD
24
64
 
25
65
  Most people prompt Claude Code like this: *"fix the bug in my auth system."* Claude reads 40 files, burns through context trying to understand your architecture, and produces something that technically compiles but misses the bigger picture.
26
66
 
27
- MDD flips this. You write structured documentation first, then Claude reads **one doc** instead of 40 files. It gets the full picture in 200 tokens instead of 20,000.
67
+ MDD flips this. You write structured documentation first. Then Claude reads **one doc** instead of 40 files - getting the full picture in 200 tokens instead of 20,000.
68
+
69
+ **The core insight:** AI assistants work better when they have a map before they touch the territory. MDD is that map.
28
70
 
29
71
  **The workflow: Document → Audit → Fix → Verify**
30
72
 
31
73
  | Phase | What happens |
32
74
  |-------|-------------|
33
- | 📋 Document | Write feature docs with YAML frontmatter in `.mdd/docs/` |
34
- | 🔍 Audit | Read source code, write incremental notes to disk (survives compaction) |
35
- | 📊 Analyze | Read notes only → produce severity-rated findings report |
36
- | 🔧 Fix | Execute pre-planned fixes with tests |
37
- | ✅ Verify | Tests pass, types check, documentation updated |
75
+ | 📋 Document | Write feature docs with YAML frontmatter in `.mdd/docs/` before a line of code |
76
+ | 🔍 Audit | Read source code incrementally, write findings to disk (survives context compaction) |
77
+ | 📊 Analyze | Read notes only → produce severity-rated findings report with effort estimates |
78
+ | 🔧 Fix | Execute pre-planned fixes with test-driven green gate loop |
79
+ | ✅ Verify | Real HTTP calls, real DB, real browser - not mocked |
80
+
81
+ ---
82
+
83
+ ## How It Works
84
+
85
+ MDD installs 7 Claude command files into `~/.claude/commands/`. The main router (`mdd.md`) reads your arguments and loads **only the mode file needed** - a `/mdd status` loads ~460 tokens instead of the full ~28,000.
86
+
87
+ ```
88
+ mdd.md (~120 lines) Router - Steps 0/0a/0b, mode dispatch, auto-branch
89
+ mdd-build.md (~680 lines) BUILD MODE - Phases 0–7d
90
+ mdd-audit.md (~240 lines) AUDIT MODE - Phases A1–A7
91
+ mdd-manage.md (~340 lines) STATUS + NOTE + SCAN + UPDATE + DEPRECATE
92
+ mdd-lifecycle.md (~350 lines) REVERSE-ENGINEER + GRAPH + UPGRADE
93
+ mdd-plan.md (~350 lines) PLAN-INITIATIVE + PLAN-WAVE + PLAN-EXECUTE + PLAN-SYNC + …
94
+ mdd-ops.md (~380 lines) OPS DOCUMENT + OPS EXECUTE + OPS UPDATE + OPS LIST + COMMANDS
95
+ ```
96
+
97
+ **Lazy loading is the key optimization.** Each invocation pays only for the mode it needs. The full 28,000-token set is always available but never loaded unnecessarily.
38
98
 
39
99
  ---
40
100
 
@@ -45,164 +105,688 @@ npm install -g @thedecipherist/mdd
45
105
  mdd install # copies Claude commands to ~/.claude/commands/
46
106
  ```
47
107
 
108
+ After installation, `/mdd` is available in every Claude Code session globally - no per-project setup needed.
109
+
48
110
  ```bash
49
- mdd update # update to latest version
111
+ mdd update # update to latest installed version
50
112
  mdd install --dir /custom/path # install to a custom directory
51
113
  ```
52
114
 
53
- After running `mdd install`, the `/mdd` command is available in every Claude Code session globally no per-project setup needed.
115
+ **Version safety:** `mdd install` compares `mdd_version` between the installed and available versions before overwriting. If you have a newer version installed, it won't silently downgrade.
54
116
 
55
117
  ---
56
118
 
57
- ## Usage
58
-
59
- ### Build a new feature
119
+ ## Quick Start
60
120
 
61
121
  ```bash
122
+ # 1. Install globally
123
+ npm install -g @thedecipherist/mdd && mdd install
124
+
125
+ # 2. Open a project in Claude Code
126
+ # 3. Run your first /mdd command:
62
127
  /mdd add user authentication with JWT tokens
63
- /mdd build payment integration with Stripe
64
- /mdd create admin dashboard for user management
128
+
129
+ # Claude will:
130
+ # - Ask a few focused questions about your feature
131
+ # - Write a feature doc to .mdd/docs/01-user-auth.md
132
+ # - Generate test skeletons (all red - that's the point)
133
+ # - Present a block-by-block build plan
134
+ # - Implement with a 5-iteration green gate loop
135
+ # - Verify against the real runtime environment
136
+ ```
137
+
138
+ ---
139
+
140
+ ## All 21 Modes at a Glance
141
+
142
+ ```
143
+ /mdd <feature description> Build Mode - Document, plan, and implement
144
+ /mdd audit [section] Audit Mode - Scan code for violations and drift
145
+ /mdd status Overview: docs, tests, audit state, initiatives
146
+ /mdd scan Detect features whose source files changed
147
+ /mdd update <feature-id> Re-sync a feature doc after code changes
148
+ /mdd note "text" Append a timestamped note to .mdd/.startup.md
149
+ /mdd note list Print the Notes section
150
+ /mdd note clear Wipe all notes (asks for confirmation)
151
+ /mdd deprecate <feature-id> Archive a feature and flag all dependents
152
+ /mdd reverse-engineer [path|feature-id] Generate MDD docs from existing source code
153
+ /mdd graph Render the full cross-feature dependency map
154
+ /mdd upgrade Batch-patch missing frontmatter across all docs
155
+ /mdd commands Show the full command reference in Claude
156
+ /mdd plan-initiative Create a new multi-wave initiative
157
+ /mdd plan-wave <wave-slug> Plan a wave within an existing initiative
158
+ /mdd plan-execute <wave-slug> Run the build flow for every feature in a wave
159
+ /mdd plan-sync Reconcile manual edits to initiative/wave files
160
+ /mdd plan-remove-feature <wave> <feature> Remove a feature from a wave
161
+ /mdd plan-cancel-initiative <slug> Cancel an initiative and archive its waves
162
+ /mdd ops <description> Create a deployment runbook
163
+ /mdd ops list Show all runbooks (global and project)
164
+ /mdd runop <slug> Execute a runbook: pre-flight → canary → post-flight
165
+ /mdd update-op <slug> Edit an existing runbook
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Build Mode - Feature Development
171
+
172
+ Build mode is the core of MDD. It runs 7 phases with 3 mandatory gates.
173
+
174
+ **Pipeline:** Understand → Analyze → Document → Test Skeletons → **🔴 Red Gate** → Plan → Implement → **🟢 Green Gate** → Verify → **✅ Integration Gate**
175
+
176
+ ### Phase 0 - Bootstrap & Mode Detection
177
+
178
+ Before anything else, MDD ensures the `.mdd/` directory structure exists (silently, no prompts). It also offers to create an isolated git worktree for parallel `/mdd` sessions, and checks the current branch to auto-create a feature branch.
179
+
180
+ ### Phase 1 - Understand the Feature
181
+
182
+ MDD launches **3 parallel Explore agents** simultaneously to gather context before asking you anything:
183
+
184
+ - **Agent A (Rules):** reads `CLAUDE.md` and `project-docs/ARCHITECTURE.md` - returns coding rules, quality gates, architecture summary
185
+ - **Agent B (Features):** globs `.mdd/docs/*.md` - returns existing feature IDs, titles, statuses, dependency chains
186
+ - **Agent C (Codebase):** globs `src/**/*` - returns directory structure, key files, detected tech stack
187
+
188
+ After all three return, Claude asks you focused questions. For tooling tasks (docs, scripts, hooks) it skips the database and API questions automatically.
189
+
190
+ **Questions always asked:**
191
+ - Does this feature depend on any existing features?
192
+ - Are there edge cases or error scenarios you already know about?
193
+
194
+ **Questions for backend/API tasks:**
195
+ - Does this need database storage?
196
+ - Does this have API endpoints?
197
+ - Does this need authentication/authorization?
198
+ - Does this need real-time updates, background jobs, or external service integrations?
199
+
200
+ ### Phase 2 - Data Flow & Impact Analysis
201
+
202
+ For non-greenfield projects, MDD traces every piece of data the feature will touch:
203
+
204
+ 1. **Backend origin** - where is this value computed? Which file and line?
205
+ 2. **API transport** - exact shape in the API response, TypeScript type
206
+ 3. **Frontend consumption** - how the UI receives and transforms the value
207
+ 4. **Parallel computations** - is the same concept computed elsewhere? Does it use the same logic?
208
+
209
+ Results go to `.mdd/audits/flow-<feature>-<date>.md`. A mandatory gate presents findings to you before documentation is written. **This gate is not skippable** - you must confirm before proceeding.
210
+
211
+ *Automatically skipped on greenfield projects (no existing docs + fewer than 5 source files).*
212
+
213
+ ### Phase 3 - Write the Feature Doc
214
+
215
+ MDD creates `.mdd/docs/<NN>-<feature-name>.md` with this structure:
216
+
217
+ ```markdown
218
+ ---
219
+ id: 01-user-auth
220
+ title: User Authentication
221
+ depends_on: []
222
+ source_files:
223
+ - src/handlers/auth.ts
224
+ - src/hooks/useAuth.ts
225
+ routes:
226
+ - POST /api/v1/auth/login
227
+ - POST /api/v1/auth/logout
228
+ models:
229
+ - users
230
+ test_files:
231
+ - tests/unit/auth.test.ts
232
+ data_flow: .mdd/audits/flow-user-auth-2026-05-07.md
233
+ last_synced: 2026-05-07
234
+ status: draft
235
+ phase: documentation
236
+ mdd_version: 8
237
+ known_issues: []
238
+ ---
239
+
240
+ # 01 - User Authentication
241
+
242
+ ## Purpose
243
+ ## Architecture
244
+ ## Data Model
245
+ ## API Endpoints
246
+ ## Business Rules
247
+ ## Data Flow
248
+ ## Dependencies
249
+ ## Known Issues
250
+ ```
251
+
252
+ **The doc is the source of truth.** Everything that follows - tests, build plan, implementation - is generated from this document.
253
+
254
+ ### Phase 4 - Test Skeletons
255
+
256
+ From the documented endpoints, business rules, and edge cases, MDD generates test skeletons:
257
+
258
+ ```typescript
259
+ describe('User Authentication', () => {
260
+ describe('POST /api/v1/auth/login', () => {
261
+ it('should return 200 and JWT token on valid credentials', async () => {
262
+ // Arrange
263
+ // Act
264
+ // Assert - minimum 3 assertions
265
+ expect.fail('Not implemented - MDD skeleton');
266
+ });
267
+
268
+ it('should return 401 on invalid password', async () => {
269
+ expect.fail('Not implemented - MDD skeleton');
270
+ });
271
+ });
272
+ });
273
+ ```
274
+
275
+ For features needing both unit and E2E tests, two parallel agents write both files simultaneously.
276
+
277
+ ### Phase 4b - Red Gate (mandatory)
278
+
279
+ Runs the new test files immediately after generation. **All tests must fail** before implementation begins. An unexpected pass means either the assertion is wrong or pre-existing code already satisfies it - both must be diagnosed before proceeding.
280
+
281
+ ```
282
+ 🔴 Red Gate: 12/12 failing (expected)
283
+ All skeletons confirmed RED - ready to implement.
284
+ ```
285
+
286
+ ### Phase 5 - Build Plan
287
+
288
+ MDD presents a commit-worthy, layered build plan. Each block has:
289
+
290
+ - **End-state** - what is runnable when this block finishes
291
+ - **Commit scope** - a conventional commit one-liner
292
+ - **Verify** - exact command to prove the block is done
293
+ - **Handoff** - what the next block expects to exist
294
+
295
+ Blocks in the same dependency layer can be marked `Runs in: parallel agents` - MDD enforces a file-declaration gate (no two agents can write the same file) and a type-dependency gate before allowing parallelism.
296
+
297
+ ### Phase 6 - Implement (Green Gate Loop)
298
+
299
+ For each block, MDD implements and runs the Green Gate:
300
+
301
+ ```
302
+ Iteration 1–5:
303
+ Run: pnpm test:unit -- --grep "<feature>" AND pnpm typecheck
304
+
305
+ If ALL green → proceed to regression check
306
+ If failing:
307
+ DIAGNOSE (required before any fix):
308
+ - What is the exact error message, file, and line?
309
+ - Which implementation assumption was wrong?
310
+ - What is the ONE targeted fix?
311
+ FIX - implementation only (tests are NEVER modified)
312
+ REPORT: "Iteration N - Root cause: X / Fix applied: Y"
313
+
314
+ Iteration 5 exhausted, still failing:
315
+ STOP. Do not attempt iteration 6.
316
+ Present options: (a) continue debugging, (b) narrow scope, (c) pause and review
317
+ ```
318
+
319
+ After each block goes green, the full test suite runs to catch regressions.
320
+
321
+ ### Phase 7 - Verify + Report
322
+
323
+ **Integration gate** - quality gates alone aren't enough. MDD verifies actual behavior:
324
+
325
+ - **Backend features:** real HTTP calls, real DB queries, response shape matches doc
326
+ - **Frontend features:** browser open, network tab inspection, console error check
327
+ - **Database features:** direct DB query confirmation, EXPLAIN on primary patterns
328
+ - **Tooling features:** run against real scenario, verify output matches doc
329
+
330
+ The ownership default: *"My code is wrong until proven otherwise."* Before accepting any external blocker, MDD runs a minimal probe and forms a specific falsifiable hypothesis.
331
+
332
+ On completion, MDD offers to commit and merge:
333
+ - **Commit & merge** - stages, commits with a conventional message, merges to main
334
+ - **Commit only** - commits on the feature branch, offers to push
335
+ - **Skip** - leaves git state for manual handling
336
+
337
+ ---
338
+
339
+ ## Audit Mode - Code Review
340
+
341
+ Audit mode scales with file count, running 1–8 parallel agents depending on scope:
342
+
343
+ | Files in scope | Agents |
344
+ |---|---|
345
+ | < 10 | 1 (single-agent mode) |
346
+ | 10–25 | 2 |
347
+ | 26–50 | 3 |
348
+ | 51–100 | 5 |
349
+ | 100+ | 8 (default ceiling, overridable via `MDD_MAX_AGENTS`) |
350
+
351
+ ### The Manifest System
352
+
353
+ Before spawning a single agent, MDD writes a manifest to `.mdd/jobs/audit-<date>/MANIFEST.md`:
354
+
355
+ ```
356
+ ## Shard 1 (Agent 1) - files 1-15
357
+ [ ] src/handlers/auth.ts
358
+ [ ] src/handlers/users.ts
359
+ ...
360
+
361
+ ## Shard 2 (Agent 2) - files 16-30
362
+ [ ] src/handlers/billing.ts
363
+ ```
364
+
365
+ State transitions: `[ ] pending → [~] in progress → [x] complete → [!] has findings → [e] error`
366
+
367
+ **Why this matters:** If Claude's context is compacted mid-audit, the manifest survives. Each agent reads its config file on startup, finds the first `[ ]` in its shard, and resumes exactly where it left off. No findings are lost.
368
+
369
+ ### Per-Agent Config
370
+
371
+ Each agent receives a self-contained config file (not the source code):
372
+
373
+ ```
374
+ # Agent 1 Audit Config
375
+ Shard file: .mdd/jobs/audit-<date>/shard-1.md
376
+ Notes file: .mdd/jobs/audit-<date>/agent-1-notes.md
377
+ Manifest: .mdd/jobs/audit-<date>/MANIFEST.md
378
+
379
+ Startup Sequence:
380
+ 1. Read this config file
381
+ 2. Read shard-1.md to know your file list
382
+ 3. Read MANIFEST.md - find the first [ ] entry in Shard 1
383
+ 4. Read the last 20 lines of agent-1-notes.md for continuity
384
+ 5. Begin the per-file loop
385
+ ```
386
+
387
+ ### Per-File Loop
388
+
389
+ Each agent follows this exact loop for every file:
390
+
391
+ 1. Mark file as `[~]` in MANIFEST (write to disk first - before reading)
392
+ 2. Read the source file fully
393
+ 3. Analyze against audit criteria
394
+ 4. Append to `agent-N-notes.md`
395
+ 5. Mark file as `[x]` or `[!]` in MANIFEST
396
+ 6. **Clear context** - every file gets a fresh context window
397
+
398
+ **Context clear is mandatory.** The notes file and manifest are the memory. Every file gets maximum analysis budget.
399
+
400
+ ### Audit Phases
401
+
402
+ - **A1 - Scope:** reads all `.mdd/docs/`, `.mdd/ops/`, resolves source files, detects interrupted audits
403
+ - **A2 - Config Setup:** writes shard files and config files for each agent before spawning
404
+ - **A3 - Parallel Execution:** all agents run simultaneously
405
+ - **A4 - Convergence:** main checks for any `[ ]` or `[~]` entries, re-runs stale shards
406
+ - **A5 - Merge:** merges all agent notes into `audits/notes-<date>.md` in manifest order
407
+ - **A6 - Analyze:** reads notes only (not source again) → produces `audits/report-<date>.md`
408
+ - **A7 - Present & Fix:** shows findings by severity, offers to fix all / P1+P2 only / review first
409
+
410
+ ### Audit Report Format
411
+
412
+ ```
413
+ 🔍 MDD Audit Complete
414
+
415
+ Findings: 20 total (3 P1 Critical, 5 P2 High, 8 P3 Medium, 4 P4 Low)
416
+ Report: .mdd/audits/report-2026-05-07.md
417
+
418
+ Top issues:
419
+ 1. Raw database connection in src/handlers/billing.ts (P1 - use StrictDB)
420
+ 2. JWT secret hardcoded in src/middleware/auth.ts (P1 - use env var)
421
+ 3. No rate limiting on /api/v1/auth/login (P2)
422
+
423
+ Estimated fix time: 6 hours (traditional) → 45 minutes (MDD)
65
424
  ```
66
425
 
67
- Claude interviews you about requirements, writes structured documentation, generates test skeletons (red gate), presents a block-by-block build plan, implements with a 5-iteration green gate loop, then verifies against the real runtime environment.
426
+ ### Resuming an Interrupted Audit
68
427
 
69
- ### Audit existing code
428
+ If an audit is interrupted (context limit, manual stop), re-running `/mdd audit` detects the stale job:
429
+
430
+ ```
431
+ Found interrupted audit from 2026-05-07.
432
+ MANIFEST shows 23/57 files complete.
433
+
434
+ [R] Resume - continue from where it left off
435
+ [D] Discard - delete and start fresh
436
+ ```
437
+
438
+ ---
439
+
440
+ ## Status & Notes
441
+
442
+ ### `/mdd status`
443
+
444
+ Gives a complete project snapshot:
445
+
446
+ ```
447
+ 📊 MDD Status
448
+
449
+ Feature docs: 9 files in .mdd/docs/
450
+ Ops runbooks: 2 files in .mdd/ops/
451
+ Last audit: 2026-05-01 (20 findings, 17 fixed, 3 open)
452
+ Test coverage: 125 unit tests, 8 E2E tests
453
+ Known issues: 3 tracked across 2 features
454
+ Quality gates: 0 files over 300 lines
455
+
456
+ Initiatives: 1 total (1 active)
457
+ Active waves: auth-system-wave-2 [1/2 features complete]
458
+
459
+ MDD version: v8 - all files up to date
460
+
461
+ Drift check:
462
+ 8 features in sync
463
+ 1 feature possibly drifted ← run /mdd scan for details
464
+ ```
465
+
466
+ After collecting status, `/mdd status` rebuilds `.mdd/.startup.md` - the session context file that gets loaded at the start of every Claude Code session, keeping Claude oriented without requiring a full codebase read.
467
+
468
+ ### `/mdd note`
469
+
470
+ Three subcommands for maintaining a running log in `.mdd/.startup.md`:
471
+
472
+ ```bash
473
+ /mdd note "switched from PostgreSQL to SQLite for dev"
474
+ /mdd note list # print all notes
475
+ /mdd note clear # wipe notes (asks for confirmation)
476
+ ```
477
+
478
+ Notes are timestamped and survive session resets.
479
+
480
+ ---
481
+
482
+ ## Scan & Update - Drift Detection
483
+
484
+ ### `/mdd scan`
485
+
486
+ Detects which features have drifted since their last MDD session. Uses a single Explore agent to run all git checks in parallel, then classifies each feature:
487
+
488
+ | Classification | Meaning |
489
+ |---|---|
490
+ | ✅ in_sync | `last_synced` exists, all files exist, no commits after sync date |
491
+ | ⚠️ drifted | Commits found after `last_synced` - doc may be stale |
492
+ | ❌ broken | One or more `source_files` not found on disk |
493
+ | ❓ untracked | No `last_synced` field in frontmatter |
494
+
495
+ ```
496
+ 🔍 MDD Scan - Drift Report
497
+
498
+ ✅ 01-project-scaffolding - in sync (last synced: 2026-04-15)
499
+ ⚠️ 04-content-builder - DRIFTED (3 commits since 2026-04-01)
500
+ Latest: "fix: markdown heading parser"
501
+ ❌ 07-github-pages - broken reference (docs/index.html not found)
502
+
503
+ Recommended actions:
504
+ /mdd update 04 - re-sync content-builder doc with code
505
+ /mdd update 07 - fix broken file reference
506
+ ```
507
+
508
+ ### `/mdd update <feature-id>`
509
+
510
+ Re-syncs a feature doc after its code has changed:
511
+
512
+ 1. Reads the current source files
513
+ 2. Diffs doc vs code (new functions, removed endpoints, changed business rules)
514
+ 3. Presents a change summary and asks for confirmation
515
+ 4. Rewrites only the affected sections (preserves `known_issues`, `depends_on`)
516
+ 5. Generates test skeletons for any new documented behaviors
517
+ 6. Updates `last_synced` to today
70
518
 
71
519
  ```bash
72
- /mdd audit # full codebase audit
73
- /mdd audit database # audit a specific section
74
- /mdd audit authentication # audit just auth-related code
520
+ /mdd update 04 # by number
521
+ /mdd update 04-content-builder # by full slug
522
+ ```
523
+
524
+ ---
525
+
526
+ ## Feature Lifecycle
527
+
528
+ ### `/mdd deprecate <feature-id>`
529
+
530
+ Archives a feature cleanly and flags all dependents:
531
+
532
+ 1. Shows a deprecation summary including which other features depend on this one
533
+ 2. Moves the doc to `.mdd/docs/archive/`
534
+ 3. Adds a `known_issues` warning to each dependent doc
535
+ 4. Asks separately about deleting source files and test files - never auto-deletes
536
+
537
+ ### `/mdd reverse-engineer [path|feature-id]`
538
+
539
+ Generates MDD documentation from existing undocumented code:
540
+
541
+ - **No argument:** scans `src/` for files not registered in any `.mdd/docs/*.md`
542
+ - **File path:** generates a doc for that specific file
543
+ - **Feature ID:** regenerates an existing doc - shows a before/after comparison
544
+
545
+ For 4+ files, uses parallel Explore agents to read in batches. Always discloses limitations upfront:
546
+
547
+ ```
548
+ ⚠️ Reverse-engineer limitations:
549
+ - "Purpose" section is inferred - review business intent carefully
550
+ - Implicit constraints (SLAs, compliance, product decisions) are not captured
551
+ - Confirm accuracy before treating this doc as the source of truth
552
+ ```
553
+
554
+ ### `/mdd graph`
555
+
556
+ Renders the full cross-feature dependency map and detects issues:
557
+
558
+ - **Broken dependency:** depends on a deprecated/archived feature
559
+ - **Risky dependency:** a `complete` feature depends on a `draft` or `in_progress` one
560
+ - **Orphan:** a feature with no dependents and no dependencies
561
+ - **Task dependency:** a feature incorrectly lists a one-off task doc in `depends_on`
562
+
563
+ ```
564
+ 📊 MDD Dependency Graph
565
+
566
+ 06-command-system ──────────────────► 01-project-scaffolding
567
+ 09-integrations ────────────────────► 06-command-system
568
+ 04-content-builder ─────────────────► 03-database-layer
569
+
570
+ Issues:
571
+ ⚠️ 09-integrations depends on 06-command-system (status: in_progress) - risky
572
+ ❌ 05-testing-framework depends on 10-old-auth (deprecated) - broken
75
573
  ```
76
574
 
77
- Scales across parallel agents (1–8 depending on file count). Notes written to disk every file so findings survive context compaction. Produces a severity-rated report (P1 Critical → P4 Low) with effort estimates.
575
+ Saved to `.mdd/audits/graph-<date>.md`.
576
+
577
+ ### `/mdd upgrade`
578
+
579
+ Batch-patches missing frontmatter fields (`last_synced`, `status`, `phase`) across all `.mdd/docs/*.md` files. Safe to run multiple times - already-present fields are never overwritten.
580
+
581
+ Infers sensible defaults from git history, existing field values, and archive status. Shows a plan before writing anything.
582
+
583
+ ---
584
+
585
+ ## Initiative & Wave Planning
586
+
587
+ For large features that span multiple weeks or deployment cycles, MDD provides a structured planning system.
78
588
 
79
- ### Day-to-day operations
589
+ ### Initiatives
590
+
591
+ An initiative is a named goal decomposed into waves. Each wave has a "demo-state" - something concrete that a user can do when the wave is complete.
80
592
 
81
593
  ```bash
82
- /mdd status # overview: docs, tests, audit state, drift
83
- /mdd scan # detect features whose source files changed since last session
84
- /mdd update 04 # re-sync a feature doc after code changes
85
- /mdd note "switched to PostgreSQL" # append a timestamped note to session context
86
- /mdd commands # show this reference table in Claude
594
+ /mdd plan-initiative # creates a new initiative with named waves
87
595
  ```
88
596
 
89
- ### Feature lifecycle
597
+ This writes `.mdd/initiatives/<slug>.md` with a hash-locked frontmatter. If you manually edit the file, MDD detects the hash mismatch on the next operation and requires you to run `/mdd plan-sync` first.
598
+
599
+ ### Waves
600
+
601
+ Each wave is a set of features that collectively deliver the demo-state.
90
602
 
91
603
  ```bash
92
- /mdd reverse-engineer src/handlers/payments.ts # generate docs from undocumented code
93
- /mdd graph # dependency map with broken/risky dep warnings
94
- /mdd deprecate 03 # retire a feature cleanly, flag dependents
95
- /mdd upgrade # batch-patch missing frontmatter across all docs
604
+ /mdd plan-wave auth-system-wave-1 # plan a wave's features and dependencies
96
605
  ```
97
606
 
98
- ### Initiative & wave planning
607
+ Before planning a wave, MDD enforces:
608
+ - **Open questions gate:** all product questions must be resolved before wave planning
609
+ - **Depends-on gate:** the wave's dependency (another wave) must be `complete` first
610
+ - **Feature ordering check:** internal feature dependencies within the wave are validated
611
+
612
+ ### Execution
99
613
 
100
614
  ```bash
101
- /mdd plan-initiative "auth system" # create a multi-wave initiative
102
- /mdd plan-wave auth-system "Auth Foundation" # plan a wave with a demo state
103
- /mdd plan-execute auth-system-wave-1 # implement all features in a wave
104
- /mdd plan-sync auth-system # re-stamp waves after initiative changes
105
- /mdd plan-remove-feature auth-system-wave-1 auth-signup
106
- /mdd plan-cancel-initiative auth-system
615
+ /mdd plan-execute auth-system-wave-1 # run full MDD build for each feature in order
107
616
  ```
108
617
 
109
- ### Ops runbooks
618
+ Two modes:
619
+ - **Automated** - minimal interruptions, pauses only on 5-iteration failures or integration failures
620
+ - **Interactive** - full MDD gates on every feature, full plan confirmations
621
+
622
+ Features are executed in dependency order, skipping already-`complete` ones. If interrupted, re-running resumes from the first `active` or `planned` feature.
623
+
624
+ ### Sync, Remove, Cancel
110
625
 
111
626
  ```bash
112
- /mdd ops deploy swarmk to dokploy # create a deployment runbook
113
- /mdd ops list # list all runbooks (global + project)
114
- /mdd runop swarmk-dokploy # execute: pre-flight canary primary → post-flight
115
- /mdd update-op swarmk-dokploy # edit an existing runbook
627
+ /mdd plan-sync # reconcile manual edits via hash comparison
628
+ /mdd plan-remove-feature <wave> <feature> # remove a feature from a wave
629
+ /mdd plan-cancel-initiative <slug> # cancel initiative, archive waves, flag feature docs
116
630
  ```
117
631
 
118
632
  ---
119
633
 
120
- ## What Gets Installed
634
+ ## Ops Runbooks
635
+
636
+ Deployment runbooks for reproducing infrastructure operations reliably.
121
637
 
122
- `mdd install` copies 7 files to `~/.claude/commands/`:
638
+ ### Creating a Runbook
123
639
 
124
- | File | Contents | Lines |
125
- |------|----------|-------|
126
- | `mdd.md` | Router — Steps 0/0a/0b, mode dispatch, auto-branch | ~120 |
127
- | `mdd-build.md` | BUILD MODE — Phases 0–7d (branch check, understand, data flow, docs, test skeletons, red gate, plan, implement, verify, commit) | ~680 |
128
- | `mdd-audit.md` | AUDIT MODE Phases A1–A7 (scope, agent config, parallel execution, convergence, merge, analyze, fix) | ~240 |
129
- | `mdd-manage.md` | STATUS + NOTE + SCAN + UPDATE + DEPRECATE modes | ~340 |
130
- | `mdd-lifecycle.md` | REVERSE-ENGINEER + GRAPH + UPGRADE modes | ~350 |
131
- | `mdd-plan.md` | PLAN-INITIATIVE + PLAN-WAVE + PLAN-EXECUTE + PLAN-SYNC + PLAN-REMOVE-FEATURE + PLAN-CANCEL-INITIATIVE modes | ~350 |
132
- | `mdd-ops.md` | OPS DOCUMENT + OPS EXECUTE + OPS UPDATE + OPS LIST + COMMANDS modes | ~380 |
640
+ ```bash
641
+ /mdd ops deploy swarmk to dokploy
642
+ ```
643
+
644
+ MDD asks: project-local (`.mdd/ops/`) or global (`~/.claude/ops/`)? Global runbooks are reusable across all projects. A collision check prevents project runbooks from shadowing global ones.
645
+
646
+ The runbook format includes:
647
+ - **Services** - each service with its Docker image, port, and health check command
648
+ - **Regions** - deployment targets with `deploy_order` and `role` (canary/primary)
649
+ - **Deployment strategy** - sequential or parallel, gate type (`health_check` / `manual` / `none`), `on_gate_failure` behavior
650
+ - **Credentials** - env var names only (never values)
651
+ - **MCP servers** - any MCP tools required during deployment
652
+
653
+ ### Executing a Runbook
654
+
655
+ ```bash
656
+ /mdd runop swarmk-dokploy
657
+ ```
658
+
659
+ Execution flow:
660
+ 1. **Pre-flight health check** - runs each service's health check across all regions, displays a status table
661
+ 2. **Deploy region by region** (in `deploy_order`):
662
+ - Deploy unhealthy services
663
+ - Run the region gate (health check / manual confirm / automatic)
664
+ - On gate failure: `stop` / `skip_region` / `rollback` per config
665
+ 3. **Post-flight health check** - full cross-region before/after table
666
+ 4. **Summary** - pass/fail per region, steps executed, `last_synced` updated in runbook
667
+
668
+ ```bash
669
+ /mdd ops list # show all runbooks (global + project) with last-run status
670
+ /mdd update-op <slug> # edit a runbook, re-ask all questions with current values pre-filled
671
+ ```
672
+
673
+ ---
133
674
 
134
- The router loads only the mode file needed for each invocation — a `/mdd status` loads ~460 tokens instead of the full ~28,000. The full set is available but never loaded unnecessarily.
675
+ ## Feature Doc Format
676
+
677
+ Every `.mdd/docs/<NN>-<feature-name>.md` file uses this YAML frontmatter:
678
+
679
+ | Field | Purpose |
680
+ |-------|---------|
681
+ | `id` | Auto-numbered slug (e.g., `01-user-auth`) |
682
+ | `title` | Human-readable title |
683
+ | `edition` | Project name or `Both` |
684
+ | `depends_on` | List of feature doc IDs this feature requires |
685
+ | `source_files` | Files that will be created or modified |
686
+ | `routes` | API routes (e.g., `POST /api/v1/auth/login`) |
687
+ | `models` | Database collections/tables used |
688
+ | `test_files` | Test files for this feature |
689
+ | `data_flow` | Path to flow analysis doc, or `greenfield` |
690
+ | `last_synced` | Date of last doc-to-code sync (drives drift detection in `/mdd scan`) |
691
+ | `status` | `draft` → `in_progress` → `complete` → `deprecated` |
692
+ | `phase` | Last completed phase name |
693
+ | `mdd_version` | Version of MDD that created/last updated this doc |
694
+ | `known_issues` | Issues discovered during audits or implementation |
695
+
696
+ **`depends_on` rules:**
697
+ - Feature docs only - never list task docs (one-off, frozen, no ongoing contract)
698
+ - IDs must reference existing docs - `/mdd graph` detects broken references
699
+ - Only add, never remove without discussion - removing breaks the dependency chain
135
700
 
136
701
  ---
137
702
 
138
703
  ## The `.mdd/` Directory
139
704
 
140
- All MDD artifacts live in a single dotfile directory:
705
+ All MDD artifacts live in one place:
141
706
 
142
707
  ```
143
708
  .mdd/
144
709
  ├── docs/ # Feature documentation (one .md per feature)
145
710
  │ ├── 01-<feature-name>.md # auto-numbered, YAML frontmatter
146
- │ └── archive/ # Deprecated feature docs
711
+ │ └── archive/ # Deprecated or cancelled feature docs
147
712
  ├── initiatives/ # Initiative files (/mdd plan-initiative)
148
- ├── waves/ # Wave files (/mdd plan-wave)
149
- ├── ops/ # Ops runbooks (/mdd ops)
150
- ├── audits/ # Audit artifacts (gitignored)
713
+ ├── waves/ # Wave execution files (/mdd plan-wave)
714
+ ├── ops/ # Project-scoped deployment runbooks
715
+ ├── audits/ # ⚠️ gitignored - regenerated by /mdd audit
151
716
  │ ├── flow-<feature>-<date>.md # Data flow analysis (Phase 2)
152
- │ ├── notes-<date>.md # Raw reading notes (Audit Phase A2)
153
- │ ├── report-<date>.md # Severity-rated findings (Audit Phase A3)
717
+ │ ├── notes-<date>.md # Raw reading notes (Audit Phase A5)
718
+ │ ├── report-<date>.md # Severity-rated findings (Audit Phase A6)
154
719
  │ ├── scan-<date>.md # Drift report (/mdd scan)
155
- └── graph-<date>.md # Dependency graph (/mdd graph)
156
- ├── jobs/ # Active audit jobs (gitignored, auto-deleted)
157
- └── .startup.md # Auto-generated session context
720
+ ├── graph-<date>.md # Dependency graph (/mdd graph)
721
+ │ └── MANIFEST-<date>.md # Permanent audit manifest (which files had findings)
722
+ ├── jobs/ # ⚠️ gitignored - auto-deleted when audit completes
723
+ │ └── audit-<date>/ # Active audit job (agents write here during audit)
724
+ │ ├── MANIFEST.md
725
+ │ ├── shard-N.md
726
+ │ ├── agent-N-config.md
727
+ │ └── agent-N-notes.md
728
+ └── .startup.md # Auto-generated session context (read by Claude on start)
158
729
  ```
159
730
 
160
- `.mdd/audits/` and `.mdd/jobs/` are automatically added to `.gitignore` on first run.
731
+ `.mdd/audits/` and `.mdd/jobs/` are automatically added to `.gitignore` on first run. Everything else in `.mdd/` is committed - it's your project's knowledge base.
161
732
 
162
- ---
163
-
164
- ## Build Mode in Detail
733
+ ### The `.startup.md` File
165
734
 
166
- Build mode runs 7 phases with 3 mandatory gates:
735
+ This file is the session context that orients Claude at the start of every conversation. MDD rebuilds it automatically after every `status`, `audit`, or `note` command:
167
736
 
168
- **Pipeline:** Understand → Analyze → Document → Test Skeletons → **Red Gate** → Plan → Implement → **Green Gate** → Verify → **Integration Gate**
737
+ ```markdown
738
+ ## Project Snapshot
739
+ Generated: 2026-05-07 | Branch: feat/user-auth
169
740
 
170
- - **Phase 1** gathers context using 3 parallel Explore agents (rules, existing features, codebase structure)
171
- - **Phase 2** is a mandatory Data Flow & Impact Analysis gate — traces every data value end-to-end before writing a line of docs; automatically skipped on greenfield projects
172
- - **Red Gate** runs every test skeleton to confirm it actually fails before implementation begins
173
- - Build plan uses commit-worthy blocks with runnable end-states, verification commands, and handoff contracts; independent blocks annotated for parallel execution
174
- - **Green Gate** implements each block with a 5-iteration diagnosis-first loop — states root cause before each fix; stops at 5 and escalates rather than continuing blindly
175
- - **Integration Gate** verifies real behavior (real HTTP calls, real DB, real browser) before marking complete
741
+ ## Stack
742
+ Framework: Express + React | DB: PostgreSQL | Host: Dokploy
176
743
 
177
- ---
744
+ ## Features Documented
745
+ 01-project-scaffolding (complete)
746
+ 02-user-auth (in_progress)
747
+ ...
178
748
 
179
- ## Audit Mode in Detail
749
+ ## Last Audit
750
+ 2026-05-01 - 20 findings, 17 fixed, 3 open
180
751
 
181
- Audit mode scales with file count (1–8 parallel agents):
752
+ ## Rules Summary
753
+ [key rules from CLAUDE.md]
182
754
 
183
- | Files in scope | Agents |
184
- |---|---|
185
- | < 10 | 1 (single-agent mode) |
186
- | 10–25 | 2 |
187
- | 26–50 | 3 |
188
- | 51–100 | 5 |
189
- | 100+ | 8 |
755
+ ---
756
+ ## Notes
757
+ - [2026-05-07] switched from JWT lib to jose for better ESM support
758
+ ```
190
759
 
191
- Each agent gets a shard of files and a config file. Agents clear context between every file — every file gets a full context window with maximum analysis budget. Notes are written to disk so findings survive compaction. The manifest tracks `[ ] pending → [~] in progress → [x] complete → [!] findings → [e] error` for every file.
760
+ The auto-generated section above the `---` is rebuilt each time. The Notes section below is append-only and preserved.
192
761
 
193
762
  ---
194
763
 
195
764
  ## MDD Versioning
196
765
 
197
- Every feature doc, wave, and initiative created by MDD is stamped with `mdd_version: N` in its frontmatter. `/mdd status` shows a breakdown of which docs are on which version. `mdd install` compares `mdd_version` between the installed and available versions before overwriting — no silent overwrites.
766
+ Every file created by MDD is stamped with `mdd_version: N` in its frontmatter. This tracks which version of the workflow created or last updated each doc.
198
767
 
199
- The current MDD version is `8` (bumped with each release to this package).
768
+ ```bash
769
+ mdd install # compares versions before overwriting - no silent upgrades
770
+ /mdd status # shows version breakdown across all docs
771
+ ```
772
+
773
+ Current MDD version: **8**
774
+
775
+ `/mdd status` version output:
776
+ ```
777
+ MDD version: v8 (current)
778
+ v8: 9 files - up to date
779
+ v7: 2 files - run /mdd upgrade to refresh these docs
780
+ v0 (unversioned): 1 file - created before versioning was introduced
781
+ ```
782
+
783
+ Run `/mdd upgrade` after updating MDD to batch-patch older docs.
200
784
 
201
785
  ---
202
786
 
203
787
  ## Real Results: Self-Audit
204
788
 
205
- The [Claude Code Mastery Starter Kit](https://github.com/TheDecipherist/claude-code-mastery-project-starter-kit) used MDD to audit itself:
789
+ The [Claude Code Mastery Starter Kit](https://github.com/TheDecipherist/claude-code-mastery-project-starter-kit) used MDD to audit itself. Real numbers, no cherry-picking:
206
790
 
207
791
  | Audit Step | Time | Output |
208
792
  |------------|------|--------|
@@ -212,16 +796,42 @@ The [Claude Code Mastery Starter Kit](https://github.com/TheDecipherist/claude-c
212
796
  | A5: Fix All | 10 min 53s | 17/20 fixed, 125 tests written |
213
797
  | **Total** | **~48 min** | **20 findings, 125 tests from zero** |
214
798
 
799
+ **P1 findings fixed:**
800
+ - 3 raw database connections replaced with StrictDB
801
+ - 2 hardcoded secrets moved to environment variables
802
+ - 1 missing input validation on a public endpoint
803
+
804
+ ---
805
+
806
+ ## History: From Starter Kit to Standalone Package
807
+
808
+ MDD started as one component of the **[Claude Code Mastery Project Starter Kit](https://github.com/TheDecipherist/claude-code-mastery-project-starter-kit)** - a full project scaffolding tool with 27 slash commands, 9 hooks, TypeScript-first quality gates, agents, skills, and the StrictDB database layer.
809
+
810
+ Within the starter kit, the entire MDD workflow lived in a single `mdd.md` file (~28,000 tokens) that was loaded in full on every invocation. This worked, but it meant every `/mdd status` call burned the entire command budget even though it only needed the status logic.
811
+
812
+ **Two things changed:**
813
+
814
+ 1. **Split into 7 files** - the monolithic `mdd.md` was broken into a router + 6 mode files. The router loads only the file needed for each invocation. A `/mdd status` now costs ~460 tokens instead of 28,000. The full capability is always available, but never loaded unnecessarily.
815
+
816
+ 2. **Extracted as a standalone npm package** - MDD now lives at `@thedecipherist/mdd` and installs into Claude Code with a single `mdd install`. You don't need the starter kit to use MDD. You don't need to clone a repo, configure anything, or adapt a boilerplate. Just `npm install -g @thedecipherist/mdd && mdd install` and you're done.
817
+
818
+ **The starter kit still exists** and is still maintained. It provides the broader scaffolding for TypeScript projects: CLAUDE.md templates, hooks configuration, StrictDB integration, custom agents, and skills. MDD is one part of that ecosystem. But now you can use MDD on its own - in any project, any tech stack, any language - without adopting the full kit.
819
+
820
+ **What this means in practice:**
821
+ - If you have an existing project → `npm install -g @thedecipherist/mdd && mdd install` and start running `/mdd` commands
822
+ - If you want the full starter kit experience → clone the starter kit and MDD is included
823
+ - If you're already on the starter kit → upgrade to the standalone MDD package for the optimized split-file version
824
+
215
825
  ---
216
826
 
217
827
  ## Companion Tools
218
828
 
219
- - **[mdd-tui](https://github.com/TheDecipherist/mdd-tui)** Terminal dashboard for browsing your `.mdd/` workspace (docs, audits, graph, ops runbooks) in a live TUI. Install: `npm install -g @thedecipherist/mdd-tui`
220
- - **[Claude Code Mastery Starter Kit](https://github.com/TheDecipherist/claude-code-mastery-project-starter-kit)** Full project scaffolding with hooks, rules, skills, and agents. MDD is one component of the kit.
221
- - **[strictdb](https://www.npmjs.com/package/strictdb)** Database wrapper with guardrails used across starter kit projects
829
+ - **[mdd-tui](https://github.com/TheDecipherist/mdd-tui)** - Terminal dashboard for browsing your `.mdd/` workspace (docs, audits, graph, ops runbooks) in a live TUI. `npm install -g @thedecipherist/mdd-tui`
830
+ - **[Claude Code Mastery Starter Kit](https://github.com/TheDecipherist/claude-code-mastery-project-starter-kit)** - Full project scaffolding: hooks, CLAUDE.md templates, TypeScript rules, agents, skills, StrictDB. MDD originated here.
831
+ - **[strictdb](https://www.npmjs.com/package/strictdb)** - Database wrapper with guardrails used across starter kit projects
222
832
 
223
833
  ---
224
834
 
225
835
  ## License
226
836
 
227
- MIT [TheDecipherist](https://github.com/TheDecipherist)
837
+ MIT - [TheDecipherist](https://github.com/TheDecipherist)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thedecipherist/mdd",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MDD — Manual-Driven Development workflow for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {