@thedecipherist/mdd 1.7.1 → 1.8.0

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 CHANGED
@@ -943,6 +943,7 @@ All MDD artifacts live in one place:
943
943
  │ ├── agent-N-config.md
944
944
  │ └── agent-N-notes.md
945
945
  ├── .startup.md # Auto-generated session context (read by Claude on start)
946
+ ├── settings.json # Stack config — auto-populated by discovery, committed to git
946
947
  └── connections.md # Pre-computed relationship map (path tree + Mermaid graph)
947
948
  ```
948
949
 
@@ -982,6 +983,91 @@ The auto-generated section above the `---` is rebuilt each time. The Notes secti
982
983
 
983
984
  ---
984
985
 
986
+ ## Stack Settings
987
+
988
+ MDD creates `.mdd/settings.json` on first run. It controls which rule files load during audit and build phases, whether stack detection runs automatically, and a few other session behaviours.
989
+
990
+ ```json
991
+ {
992
+ "autoDiscovery": true,
993
+ "stack": {
994
+ "language": ["typescript"],
995
+ "runtime": ["node"],
996
+ "frameworks": ["express"],
997
+ "orm": ["prisma"],
998
+ "auth": ["jwt"]
999
+ },
1000
+ "overrides": {},
1001
+ "phaseLogging": true,
1002
+ "securityScan": false
1003
+ }
1004
+ ```
1005
+
1006
+ **`autoDiscovery: true` (default)** - MDD scans your manifest files once at session start and writes the detected stack into `settings.json`. It checks `package.json`, `go.mod`, `pyproject.toml`, and `composer.json`. The `stack` field is owned by discovery when this is on; `overrides` is always yours to edit.
1007
+
1008
+ **`autoDiscovery: false`** - MDD reads `settings.json` as-is. You control the stack manually. Useful when your dependencies don't reflect the full picture (custom implementations, monorepos, unusual setups).
1009
+
1010
+ **`overrides`** - Merged on top of `stack` at phase time. Add anything discovery misses - custom auth implementations, internal frameworks, or anything else that needs stack-specific rules.
1011
+
1012
+ **`phaseLogging: true` (default)** - Controls whether MDD writes phase timing data via `mdd-log-phase.sh`. Set to `false` to suppress all phase log output.
1013
+
1014
+ **`securityScan: false` (default)** - Enables the security rule generator. See the section below.
1015
+
1016
+ ### Stack-Specific Rule Files
1017
+
1018
+ Once MDD knows your stack, it loads matching rule files at the start of each audit and build phase. These files live in `~/.claude/mdd/` alongside the other mode files and are installed with `mdd install`.
1019
+
1020
+ ```
1021
+ mdd-rules-typescript.md # TypeScript-specific audit criteria and build checklists
1022
+ mdd-rules-express.md # Express error handling, middleware, route validation rules
1023
+ mdd-rules-jwt.md # JWT decode safety, expiry checks, secret validation
1024
+ mdd-rules-prisma.md # Prisma query safety, transaction patterns, migration checks
1025
+ ```
1026
+
1027
+ Rules are additive - they append criteria to the existing phase rather than replacing anything. If a rule file doesn't exist for a stack entry, MDD warns once and continues. A misconfigured or missing `settings.json` never halts a session.
1028
+
1029
+ ### Security Rule Generator
1030
+
1031
+ When `securityScan: true`, MDD runs a vulnerability scan against your declared stack and generates new audit rules for any patterns not already covered.
1032
+
1033
+ ```bash
1034
+ # Runs automatically during /mdd audit when securityScan: true
1035
+ # Or run directly:
1036
+ /mdd security-rules
1037
+ ```
1038
+
1039
+ **How it works:**
1040
+
1041
+ 1. Scans your dependencies using free tools - `npm audit` for Node projects, `osv-scanner` for multi-language, Snyk CLI free tier if installed. No API keys required.
1042
+ 2. Reads all existing `mdd-rules-{stack}.md` files and extracts the current rule set.
1043
+ 3. For each vulnerability found: checks whether the attack vector is already covered by an existing rule.
1044
+ 4. If a gap exists: generates a new rule targeting the vulnerability *class*, not just the specific CVE. A rule about "prototype pollution via unvalidated query parameters" will catch future variants, not just the package version that triggered it.
1045
+ 5. Appends new rules to the relevant `mdd-rules-{stack}.md` file with the source CVE as a reference.
1046
+
1047
+ ```
1048
+ Security rule generator - 2026-05-20
1049
+
1050
+ Sources: npm audit, osv-scanner
1051
+ Findings reviewed: 12
1052
+ Already covered by existing rules: 9
1053
+ Gaps found: 3
1054
+
1055
+ New rules generated:
1056
+ mdd-rules-express.md +2 rules
1057
+ - [P2] Prototype pollution via req.query or req.body merge — use structuredClone() or
1058
+ a safe merge utility. Reference: CVE-2024-29041
1059
+ - [P2] res.redirect() called with user-supplied path without allowlist validation.
1060
+ Reference: CVE-2024-43796
1061
+
1062
+ mdd-rules-jwt.md +1 rule
1063
+ - [P2] jwt.decode() used instead of jwt.verify() — decode skips signature check.
1064
+ Reference: CVE-2022-21449 (class)
1065
+ ```
1066
+
1067
+ The gap check uses semantic comparison, not string matching, so rules generated in a previous run are not duplicated even if they use different wording. Each generated rule includes the CVE ID so you can trace where it came from and review or remove it if needed.
1068
+
1069
+ ---
1070
+
985
1071
  ## MDD Versioning
986
1072
 
987
1073
  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.
@@ -2,20 +2,30 @@
2
2
 
3
3
  Triggered when arguments start with `audit`.
4
4
 
5
- ## Phase Logging
5
+ ### Stack Rule Loading (runs before Phase A1)
6
6
 
7
- At the **start** of every phase (before any action) and the **end** of every phase (after all actions), run the command below. Substitute `PHASE` with the phase identifier (e.g., `Phase A1`, `Phase A2`) and `EVENT` with `start` or `end`:
7
+ After Step 0c in `mdd.md` sets `$MDD_STACK` and `$MDD_DIR`, load any matching stack rule files. This runs silently no output unless a problem occurs.
8
8
 
9
- ```bash
10
- bash -c 'D=$(date +%Y-%m-%d); T=$(date +%H:%M:%S); K=$(compressmcp --status 2>/dev/null | grep -oE "[0-9]+K/[0-9]+K" | head -1 || echo "-"); mkdir -p ~/.claude/mdd; printf "| %s | mdd-audit | PHASE | EVENT | %s | %s |\n" "$D" "$T" "$K" >> ~/.claude/mdd/log.md' 2>/dev/null || true
9
+ ```
10
+ For each entry in $MDD_STACK:
11
+ If $MDD_DIR/mdd-rules-{entry}.md exists:
12
+ Read the file — append all rules found to the active audit criteria for this session
13
+ Else:
14
+ Emit one line: ⚠ No rule file for '{entry}' — skipping
15
+ Continue (never halt)
11
16
  ```
12
17
 
13
- Log file: `~/.claude/mdd/log.md`
18
+ Stack rules are **additive only** — they extend the P1/P2/P3/P4 criteria lists used in Phase A3. They never replace or gate core audit behaviour.
14
19
 
15
- ---
20
+ If `$MDD_SECURITY_SCAN` is `true`, run the security rule generator before loading rules:
21
+ **Read `$MDD_DIR/mdd-security-rules.md` and follow its SECURITY RULES MODE instructions.** New rules it writes to `mdd-rules-{stack}.md` files will be picked up by the loading step above.
16
22
 
17
23
  ### Phase A1 — Scope
18
24
 
25
+ ```bash
26
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A1" start "$AUDIT_TARGET"
27
+ ```
28
+
19
29
  **Stale job detection (runs first):** Check `.mdd/jobs/` for any existing `audit-*/` folder.
20
30
  - If found: check whether a corresponding `audits/report-<date>.md` exists.
21
31
  - If yes: job completed but cleanup failed — delete the stale jobs folder and proceed normally.
@@ -106,8 +116,16 @@ Create `.mdd/jobs/audit-<date>/` and write `MANIFEST.md`:
106
116
 
107
117
  ---
108
118
 
119
+
120
+ ```bash
121
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A1" end "$AUDIT_TARGET"
122
+ ```
109
123
  ### Phase A2 — Per-Agent Config Setup
110
124
 
125
+ ```bash
126
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A2" start "$AUDIT_TARGET"
127
+ ```
128
+
111
129
  Main writes a shard file and config file for each agent into the job folder **before spawning anything**.
112
130
 
113
131
  **`shard-N.md`** — flat list of files assigned to this agent, extracted from the manifest. The agent uses this to know its scope without parsing the full manifest.
@@ -217,8 +235,16 @@ This config file contains no source code or findings — only paths and instruct
217
235
 
218
236
  ---
219
237
 
238
+
239
+ ```bash
240
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A2" end "$AUDIT_TARGET"
241
+ ```
220
242
  ### Phase A3 — Parallel Agent Execution
221
243
 
244
+ ```bash
245
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A3" start "$AUDIT_TARGET"
246
+ ```
247
+
222
248
  Main spawns all agents simultaneously. Each agent receives only the path to its config file.
223
249
 
224
250
  **Per-file loop (each agent follows exactly):**
@@ -264,8 +290,16 @@ shows no contracts apply to this file, write "(none)" — never omit the line en
264
290
 
265
291
  ---
266
292
 
293
+
294
+ ```bash
295
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A3" end "$AUDIT_TARGET"
296
+ ```
267
297
  ### Phase A4 — Convergence Check
268
298
 
299
+ ```bash
300
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A4" start "$AUDIT_TARGET"
301
+ ```
302
+
269
303
  After all agents signal completion, main reads `MANIFEST.md` and checks for any `[ ]` or `[~]` entries.
270
304
 
271
305
  - **`[ ]` entries:** agent never reached this file — re-run that agent's shard for remaining files
@@ -276,8 +310,16 @@ Audit does not advance to Phase A5 until every file is `[x]`, `[!]`, or `[e]`.
276
310
 
277
311
  ---
278
312
 
313
+
314
+ ```bash
315
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A4" end "$AUDIT_TARGET"
316
+ ```
279
317
  ### Phase A5 — Merge
280
318
 
319
+ ```bash
320
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A5" start "$AUDIT_TARGET"
321
+ ```
322
+
281
323
  Main merges all agent notes into the canonical output file:
282
324
 
283
325
  1. Read `MANIFEST.md` to get canonical file order
@@ -290,8 +332,16 @@ Merge is in manifest order, not agent completion order. The job folder is not to
290
332
 
291
333
  ---
292
334
 
335
+
336
+ ```bash
337
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A5" end "$AUDIT_TARGET"
338
+ ```
293
339
  ### Phase A6 — Analyze
294
340
 
341
+ ```bash
342
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A6" start "$AUDIT_TARGET"
343
+ ```
344
+
295
345
  Read `audits/notes-<date>.md` as the primary source. Produce `audits/report-<date>.md` — include `mdd_version: <current from mdd.md frontmatter>` as the first line of frontmatter.
296
346
 
297
347
  **Source code access in this phase:** Standard synthesis (items 1-8 below) uses only the notes file. The integration contract verification step that follows may re-read specific source files — that is the only exception, and it is mandatory.
@@ -338,8 +388,16 @@ The manifest is kept permanently in `audits/` — `[x]` vs `[!]` per file shows
338
388
 
339
389
  ---
340
390
 
391
+
392
+ ```bash
393
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A6" end "$AUDIT_TARGET"
394
+ ```
341
395
  ### Phase A7 — Present Findings + Fix
342
396
 
397
+ ```bash
398
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A7" start "$AUDIT_TARGET"
399
+ ```
400
+
343
401
  Show the user:
344
402
  ```
345
403
  🔍 MDD Audit Complete
@@ -385,8 +443,16 @@ Report progress per finding. Update documentation `known_issues` to remove fixed
385
443
 
386
444
  ---
387
445
 
446
+
447
+ ```bash
448
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A7" end "$AUDIT_TARGET"
449
+ ```
388
450
  ### Phase A8 — MDD Self-Review
389
451
 
452
+ ```bash
453
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A8" start "$AUDIT_TARGET"
454
+ ```
455
+
390
456
  Runs at the end of every audit, after fixes (or immediately after A7 if user chose not to fix now).
391
457
 
392
458
  **Opt-in gate — check before doing anything else:**
@@ -461,3 +527,12 @@ When running `/mdd audit <section>` with fewer than 10 resolved files, skip the
461
527
  **Integration context still applies in this mode.** Before starting the per-file loop, build `integration-context.md` into the job folder using the same logic as Phase A2 (read all `.mdd/docs/*.md`, extract contracts and feature-to-file mappings). Read `integration-context.md` at the start of the per-file loop and after every context clear — identical to the multi-agent startup sequence. The mandatory `Contracts:` line in notes applies here too.
462
528
 
463
529
  ---
530
+
531
+
532
+ ```bash
533
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "Phase A8" end "$AUDIT_TARGET"
534
+ ```
535
+
536
+ ```bash
537
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-audit" "-" "complete" "$AUDIT_TARGET"
538
+ ```
@@ -4,22 +4,12 @@
4
4
 
5
5
  The user is reporting a bug in an existing feature. Do NOT create a new feature doc.
6
6
 
7
- ## Phase Logging
8
-
9
- At the **start** of every phase (before any action) and the **end** of every phase (after all actions), run the command below. Substitute `PHASE` with the phase identifier (e.g., `Phase B0`, `Phase B1`) and `EVENT` with `start` or `end`:
7
+ ### Phase B0 — Parse
10
8
 
11
9
  ```bash
12
- bash -c 'D=$(date +%Y-%m-%d); T=$(date +%H:%M:%S); K=$(compressmcp --status 2>/dev/null | grep -oE "[0-9]+K/[0-9]+K" | head -1 || echo "-"); mkdir -p ~/.claude/mdd; printf "| %s | mdd-bug | PHASE | EVENT | %s | %s |\n" "$D" "$T" "$K" >> ~/.claude/mdd/log.md' 2>/dev/null || true
10
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B0" start "$BUG_SLUG"
13
11
  ```
14
12
 
15
- Log file: `~/.claude/mdd/log.md`
16
- Instead: scan existing docs to identify which feature(s) own the broken behavior,
17
- document the bug in those docs, fix it, and mark it complete.
18
-
19
- ---
20
-
21
- ### Phase B0 — Parse
22
-
23
13
  Extract the bug description from `$ARGUMENTS` by stripping the leading `bug ` prefix.
24
14
  Store as `$BUG_DESC`.
25
15
 
@@ -28,8 +18,16 @@ If `$BUG_DESC` is empty after stripping, ask the user:
28
18
 
29
19
  ---
30
20
 
21
+
22
+ ```bash
23
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B0" end "$BUG_SLUG"
24
+ ```
31
25
  ### Phase B1 — Triage
32
26
 
27
+ ```bash
28
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B1" start "$BUG_SLUG"
29
+ ```
30
+
33
31
  Read the frontmatter of every file in `.mdd/docs/` (excluding `archive/` subdirectory).
34
32
  Do **not** read doc bodies during triage — frontmatter only. You need: `id`, `title`, `tags`, `source_files`.
35
33
 
@@ -65,8 +63,16 @@ Run /mdd status to see the full project overview.
65
63
 
66
64
  ---
67
65
 
66
+
67
+ ```bash
68
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B1" end "$BUG_SLUG"
69
+ ```
68
70
  ### Phase B2 — Confirm Related Docs
69
71
 
72
+ ```bash
73
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B2" start "$BUG_SLUG"
74
+ ```
75
+
70
76
  Present the triage results and ask the user to confirm which docs the bug relates to.
71
77
  Always show the full doc list so the user can add docs that scored below the threshold.
72
78
 
@@ -88,8 +94,16 @@ Store the confirmed list as `$RELATED_DOCS`.
88
94
 
89
95
  ---
90
96
 
97
+
98
+ ```bash
99
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B2" end "$BUG_SLUG"
100
+ ```
91
101
  ### Phase B3 — Document the Bug
92
102
 
103
+ ```bash
104
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B3" start "$BUG_SLUG"
105
+ ```
106
+
93
107
  For each doc in `$RELATED_DOCS`:
94
108
 
95
109
  1. Read the full doc file
@@ -135,8 +149,16 @@ Store the bug IDs per doc as `$BUG_IDS` (map of doc-id → B-number) for use in
135
149
 
136
150
  ---
137
151
 
152
+
153
+ ```bash
154
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B3" end "$BUG_SLUG"
155
+ ```
138
156
  ### Phase B4 — Fix
139
157
 
158
+ ```bash
159
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B4" start "$BUG_SLUG"
160
+ ```
161
+
140
162
  Ask the user via AskUserQuestion how to proceed with the fix:
141
163
 
142
164
  ```
@@ -202,8 +224,16 @@ At the end of Phase 7, return here to Phase B5 to mark the bug complete in the d
202
224
 
203
225
  ---
204
226
 
227
+
228
+ ```bash
229
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B4" end "$BUG_SLUG"
230
+ ```
205
231
  ### Phase B5 — Mark Complete
206
232
 
233
+ ```bash
234
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B5" start "$BUG_SLUG"
235
+ ```
236
+
207
237
  After the fix is verified (via either Path A or Path B), update every doc in `$RELATED_DOCS`:
208
238
 
209
239
  For each doc, find the bug entry created in Phase B3 (use `$BUG_IDS` to find the right B-number):
@@ -258,3 +288,12 @@ Options:
258
288
  ```
259
289
 
260
290
  Follow the same commit/merge logic as BUILD MODE Phase 7d.
291
+
292
+
293
+ ```bash
294
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "Phase B5" end "$BUG_SLUG"
295
+ ```
296
+
297
+ ```bash
298
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-bug" "-" "complete" "$BUG_SLUG"
299
+ ```
@@ -1,19 +1,27 @@
1
1
  ## BUILD MODE — New Feature Development
2
2
 
3
- ## Phase Logging
3
+ ### Stack Rule Loading (runs before Phase 0)
4
4
 
5
- At the **start** of every phase (before any action) and the **end** of every phase (after all actions), run the command below. Substitute `PHASE` with the phase identifier (e.g., `Phase 0`, `Phase 1`) and `EVENT` with `start` or `end`:
5
+ After Step 0c in `mdd.md` sets `$MDD_STACK` and `$MDD_DIR`, load any matching stack rule files. This runs silently no output unless a problem occurs.
6
6
 
7
- ```bash
8
- bash -c 'D=$(date +%Y-%m-%d); T=$(date +%H:%M:%S); K=$(compressmcp --status 2>/dev/null | grep -oE "[0-9]+K/[0-9]+K" | head -1 || echo "-"); mkdir -p ~/.claude/mdd; printf "| %s | mdd-build | PHASE | EVENT | %s | %s |\n" "$D" "$T" "$K" >> ~/.claude/mdd/log.md' 2>/dev/null || true
7
+ ```
8
+ For each entry in $MDD_STACK:
9
+ If $MDD_DIR/mdd-rules-{entry}.md exists:
10
+ Read the file — append all build checklist items to Phase 6 implementation steps
11
+ Append any additional audit criteria to Phase 7b verification checks
12
+ Else:
13
+ Emit one line: ⚠ No rule file for '{entry}' — skipping
14
+ Continue (never halt)
9
15
  ```
10
16
 
11
- Log file: `~/.claude/mdd/log.md`
12
-
13
- ---
17
+ Stack rules are **additive only** — they extend Phase 6 checklists and Phase 7b verification. They never replace or gate core build behaviour.
14
18
 
15
19
  ### Phase 0 — Branch Safety Check
16
20
 
21
+ ```bash
22
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 0" start "$FEATURE_SLUG"
23
+ ```
24
+
17
25
  Before gathering any context, verify the current branch is compatible with the requested feature.
18
26
 
19
27
  ```bash
@@ -75,8 +83,16 @@ What would you like to do?
75
83
  - Report: "Aborted. Commit your current work, merge `<branch-name>` to main, then re-run `/mdd $ARGUMENTS` on a fresh branch."
76
84
  - Stop.
77
85
 
86
+
87
+ ```bash
88
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 0" end "$FEATURE_SLUG"
89
+ ```
78
90
  ### Phase 1 — Understand the Feature
79
91
 
92
+ ```bash
93
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 1" start "$FEATURE_SLUG"
94
+ ```
95
+
80
96
  Read the user's description: **$ARGUMENTS**
81
97
 
82
98
  Before writing anything, gather context using **3 parallel Explore agents**. Launch all three simultaneously — do not wait for one before starting the others:
@@ -111,8 +127,16 @@ Then ask the user targeted questions using AskUserQuestion. Ask ALL relevant que
111
127
 
112
128
  Wait for all answers before proceeding.
113
129
 
130
+
131
+ ```bash
132
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 1" end "$FEATURE_SLUG"
133
+ ```
114
134
  ### Phase 2 — Data Flow & Impact Analysis
115
135
 
136
+ ```bash
137
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 2" start "$FEATURE_SLUG"
138
+ ```
139
+
116
140
  **Skip condition:** If `.mdd/docs/` has no existing files AND `src/` has fewer than 5 source files, skip this phase entirely and note: "Greenfield detected — skipping data flow analysis." Then jump to Phase 3.
117
141
 
118
142
  Otherwise, use the answers from Phase 1 (depends_on, endpoints, models) to identify which existing files to read. Do NOT scan blindly — read only what the feature will touch or extend.
@@ -176,8 +200,16 @@ Ask the user: **"Proceed with documentation? (yes / adjust scope based on findin
176
200
 
177
201
  **This gate is mandatory.** Do not proceed to Phase 3 until the user confirms. If consistency issues were found, discuss whether to fix them as part of this feature or track them as pre-existing known issues first.
178
202
 
203
+
204
+ ```bash
205
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 2" end "$FEATURE_SLUG"
206
+ ```
179
207
  ### Phase 3 — Write the MDD Documentation
180
208
 
209
+ ```bash
210
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 3" start "$FEATURE_SLUG"
211
+ ```
212
+
181
213
  Create the feature documentation file at `.mdd/docs/<NN>-<feature-name>.md`.
182
214
 
183
215
  **Auto-number:** Read `.mdd/docs/` directory, find the highest existing number, increment by 1.
@@ -318,8 +350,16 @@ Show the completed doc to the user and ask: **"Does this accurately describe wha
318
350
 
319
351
  Wait for confirmation before proceeding.
320
352
 
353
+
354
+ ```bash
355
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 3" end "$FEATURE_SLUG"
356
+ ```
321
357
  ### Phase 4 — Generate Test Skeletons
322
358
 
359
+ ```bash
360
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 4" start "$FEATURE_SLUG"
361
+ ```
362
+
323
363
  Read the documentation file created in Phase 3. From the endpoints, business rules, and edge cases documented, generate test skeletons.
324
364
 
325
365
  **Skeleton template (unit):**
@@ -382,8 +422,16 @@ That's the point — they're the finish line.
382
422
 
383
423
  ---
384
424
 
425
+
426
+ ```bash
427
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 4" end "$FEATURE_SLUG"
428
+ ```
385
429
  ### Phase 4b — Red Gate (mandatory)
386
430
 
431
+ ```bash
432
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 4b" start "$FEATURE_SLUG"
433
+ ```
434
+
387
435
  **No skip condition.** This phase runs after every skeleton generation, every time.
388
436
 
389
437
  Run ONLY the new test file(s) — not the full suite:
@@ -422,8 +470,16 @@ If any test passes unexpectedly and the fix isn't trivial, ask the user:
422
470
  Proceed with fix? (yes / adjust differently / stop)
423
471
  ```
424
472
 
473
+
474
+ ```bash
475
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 4b" end "$FEATURE_SLUG"
476
+ ```
425
477
  ### Phase 5 — Present the Build Plan
426
478
 
479
+ ```bash
480
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 5" start "$FEATURE_SLUG"
481
+ ```
482
+
427
483
  **Auto-detect feature size** before choosing plan format:
428
484
 
429
485
  - **Simple** — fewer than 3 new files, no API routes, no database: use flat steps (block overhead not warranted)
@@ -525,8 +581,16 @@ Ready to build? (yes / modify plan / stop here)
525
581
 
526
582
  Wait for user confirmation.
527
583
 
584
+
585
+ ```bash
586
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 5" end "$FEATURE_SLUG"
587
+ ```
528
588
  ### Phase 6 — Implement (Test-Driven)
529
589
 
590
+ ```bash
591
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 6" start "$FEATURE_SLUG"
592
+ ```
593
+
530
594
  #### Step 6a — Layered execution
531
595
 
532
596
  Execute blocks in dependency layer order (Layer 1 → 2 → 3 → 4). Within the same layer, blocks marked `Runs in: parallel agents (2)` run simultaneously. Blocks marked `Runs in: main conversation` run sequentially.
@@ -606,8 +670,16 @@ Block 2 (Services): ✅ — 8/8 tests passing, no regressions
606
670
  Block 3 (Wiring): 🔄 in progress...
607
671
  ```
608
672
 
673
+
674
+ ```bash
675
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 6" end "$FEATURE_SLUG"
676
+ ```
609
677
  ### Phase 7 — Verify + Report
610
678
 
679
+ ```bash
680
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 7" start "$FEATURE_SLUG"
681
+ ```
682
+
611
683
  #### Phase 7a — Quality Gates
612
684
 
613
685
  ```bash
@@ -802,3 +874,12 @@ Changes: <N files changed, N insertions, N deletions> (from git diff --stat)
802
874
  Report: "Skipped. Branch `feat/<feature-name>` — run `/commit` and then merge when ready."
803
875
 
804
876
  ---
877
+
878
+
879
+ ```bash
880
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "Phase 7" end "$FEATURE_SLUG"
881
+ ```
882
+
883
+ ```bash
884
+ bash ~/.claude/hooks/mdd-log-phase.sh "mdd-build" "-" "complete" "$FEATURE_SLUG"
885
+ ```