@thedecipherist/mdd 1.0.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 +227 -0
- package/commands/mdd-audit.md +237 -0
- package/commands/mdd-build.md +678 -0
- package/commands/mdd-lifecycle.md +350 -0
- package/commands/mdd-manage.md +340 -0
- package/commands/mdd-ops.md +378 -0
- package/commands/mdd-plan.md +347 -0
- package/commands/mdd.md +152 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +27 -0
- package/dist/cli.js.map +1 -0
- package/dist/install.d.ts +7 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +91 -0
- package/dist/install.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
## BUILD MODE — New Feature Development
|
|
2
|
+
|
|
3
|
+
### Phase 0 — Branch Safety Check
|
|
4
|
+
|
|
5
|
+
Before gathering any context, verify the current branch is compatible with the requested feature.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
BRANCH=$(git branch --show-current)
|
|
9
|
+
AHEAD=$(git log --oneline main..HEAD 2>/dev/null | wc -l | tr -d ' ')
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
**Skip this check entirely if:**
|
|
13
|
+
- Branch is `main` or `master` — auto-branch (end of this file) will create the right branch
|
|
14
|
+
- Branch starts with `fix/mdd-audit-` — it is an audit branch, not a feature branch
|
|
15
|
+
- Branch name contains significant keywords from `$ARGUMENTS` — it is a match
|
|
16
|
+
|
|
17
|
+
**Detect a mismatch:**
|
|
18
|
+
|
|
19
|
+
Derive a slug from `$ARGUMENTS` (e.g., "add payment system" → `payment-system`).
|
|
20
|
+
Strip the branch prefix (`feat/`, `fix/`, `refactor/`, etc.) to get the branch's feature name.
|
|
21
|
+
If the two names share fewer than half of their significant words → mismatch detected.
|
|
22
|
+
|
|
23
|
+
**If a mismatch is detected**, ask the user via AskUserQuestion:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
⚠️ Branch mismatch detected
|
|
27
|
+
|
|
28
|
+
You are currently on: <branch-name>
|
|
29
|
+
Commits ahead of main: <N>
|
|
30
|
+
|
|
31
|
+
The feature you are starting ("<$ARGUMENTS>") does not appear to match this branch.
|
|
32
|
+
|
|
33
|
+
MDD expects one feature per branch. Mixing unrelated features on the same branch
|
|
34
|
+
makes PR review, rollback, and history harder — and breaks the MDD workflow.
|
|
35
|
+
|
|
36
|
+
What would you like to do?
|
|
37
|
+
|
|
38
|
+
(a) Commit, merge, and branch fresh (recommended)
|
|
39
|
+
Stage current changes → commit → merge <branch-name> to main → create feat/<new-slug>
|
|
40
|
+
(b) Continue on this branch anyway
|
|
41
|
+
Work on the new feature here (not recommended — mixes features)
|
|
42
|
+
(c) Abort
|
|
43
|
+
Stop so I can handle git manually
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**If (a) — Commit, merge, and branch fresh:**
|
|
47
|
+
1. `git add -A` — stage all current changes
|
|
48
|
+
2. Use the `/commit` skill to generate a conventional commit message
|
|
49
|
+
3. Commit the staged changes
|
|
50
|
+
4. `git checkout main`
|
|
51
|
+
5. `git merge <branch-name> --no-ff -m "Merge <branch-name>: <feature summary>"`
|
|
52
|
+
6. Ask: "Push `<branch-name>` to origin now? (yes / no)"
|
|
53
|
+
- If yes: `git push origin main`
|
|
54
|
+
7. `git checkout -b feat/<new-feature-slug>`
|
|
55
|
+
8. Report: "✅ Merged and branched to `feat/<new-feature-slug>`. Continuing with your MDD task..."
|
|
56
|
+
9. Proceed to Phase 1.
|
|
57
|
+
|
|
58
|
+
**If (b) — Continue on this branch anyway:**
|
|
59
|
+
- Report: "⚠️ Continuing on `<branch-name>` — consider merging this branch before opening a PR."
|
|
60
|
+
- Proceed to Phase 1.
|
|
61
|
+
|
|
62
|
+
**If (c) — Abort:**
|
|
63
|
+
- Report: "Aborted. Commit your current work, merge `<branch-name>` to main, then re-run `/mdd $ARGUMENTS` on a fresh branch."
|
|
64
|
+
- Stop.
|
|
65
|
+
|
|
66
|
+
### Phase 1 — Understand the Feature
|
|
67
|
+
|
|
68
|
+
Read the user's description: **$ARGUMENTS**
|
|
69
|
+
|
|
70
|
+
Before writing anything, gather context using **3 parallel Explore agents**. Launch all three simultaneously — do not wait for one before starting the others:
|
|
71
|
+
|
|
72
|
+
**Agent A (Rules):** Read `CLAUDE.md` and `project-docs/ARCHITECTURE.md`. Return: key coding rules, quality gates, port assignments, architecture summary, any project-specific conventions relevant to this feature.
|
|
73
|
+
|
|
74
|
+
**Agent B (Features):** Glob `.mdd/docs/*.md` and read each. Return: list of existing feature IDs + titles + status + `depends_on` chains. Flag any features that might relate to `$ARGUMENTS`. Separate task docs (`type: task`) from feature docs — return them as a distinct list. Task docs must NOT appear in the depends_on candidates list presented to the user.
|
|
75
|
+
|
|
76
|
+
**Agent C (Codebase):** Glob `src/**/*` and list files. Return: directory structure, key files per subdirectory, detected tech stack (framework, DB, test runner).
|
|
77
|
+
|
|
78
|
+
**Agent prompt requirements (each must be self-contained):** Include the feature description (`$ARGUMENTS`), the project working directory, and an explicit instruction to return a concise summary — not raw file contents. This prevents context explosion.
|
|
79
|
+
|
|
80
|
+
**After all 3 return:** synthesize into a working context in the main conversation. If any agent fails, silently fall back to direct `Read`/`Glob` for that agent's data — never surface agent failures to the user unless all 3 fail.
|
|
81
|
+
|
|
82
|
+
**Detect task type before asking questions.** If `src/` has fewer than 3 TypeScript/source files AND the feature description contains words like `workflow`, `command`, `config`, `docs`, `tooling`, `hook`, `script`, or `prompt` — mark as a **tooling task** and skip the database and API questions entirely.
|
|
83
|
+
|
|
84
|
+
Then ask the user targeted questions using AskUserQuestion. Ask ALL relevant questions upfront in a single interaction — don't spread them across multiple turns:
|
|
85
|
+
|
|
86
|
+
**Always ask:**
|
|
87
|
+
- "Does this feature depend on any existing features?" (list only feature docs — omit task docs, which are one-off and frozen and not valid dependency targets)
|
|
88
|
+
- "Are there any edge cases or error scenarios you already know about?"
|
|
89
|
+
|
|
90
|
+
**Ask only for non-tooling tasks:**
|
|
91
|
+
- "Does this feature need database storage? If so, what data does it store?"
|
|
92
|
+
- "Does this feature have API endpoints? What operations (create, read, update, delete)?"
|
|
93
|
+
|
|
94
|
+
**Ask if relevant:**
|
|
95
|
+
- "Does this need authentication/authorization?"
|
|
96
|
+
- "Does this need real-time updates (WebSocket)?"
|
|
97
|
+
- "Does this need background processing (queues, cron)?"
|
|
98
|
+
- "Does this integrate with any external services?"
|
|
99
|
+
|
|
100
|
+
Wait for all answers before proceeding.
|
|
101
|
+
|
|
102
|
+
### Phase 2 — Data Flow & Impact Analysis
|
|
103
|
+
|
|
104
|
+
**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.
|
|
105
|
+
|
|
106
|
+
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.
|
|
107
|
+
|
|
108
|
+
#### Step 2a — Identify Touched Files
|
|
109
|
+
|
|
110
|
+
From Phase 1 answers:
|
|
111
|
+
- Which existing features does this depend on? → Read their `source_files` from `.mdd/docs/`
|
|
112
|
+
- Which endpoints or models does this extend? → Grep `src/` for those names
|
|
113
|
+
- Which TypeScript types does this use? → Read `src/types/`
|
|
114
|
+
|
|
115
|
+
Read each identified file. The goal is to **understand data flows**, not audit code quality.
|
|
116
|
+
|
|
117
|
+
#### Step 2b — Trace Each Data Value
|
|
118
|
+
|
|
119
|
+
For every piece of data the new feature will **consume, transform, or display**, document the full chain:
|
|
120
|
+
|
|
121
|
+
1. **Backend origin** — where is this value computed? What formula or logic? Note the file and line number.
|
|
122
|
+
2. **API transport** — what is the exact shape in the API response? Is it typed correctly?
|
|
123
|
+
3. **Frontend consumption** — how does the UI receive and use this value? Is there any transformation between the API response and what is displayed?
|
|
124
|
+
4. **Parallel computations** — is this same concept computed anywhere else in the codebase? Does it use the same logic?
|
|
125
|
+
|
|
126
|
+
Write findings to `.mdd/audits/flow-<feature-slug>-<date>.md` as you go. Do not accumulate in memory.
|
|
127
|
+
|
|
128
|
+
#### Step 2c — Impact Analysis
|
|
129
|
+
|
|
130
|
+
For each endpoint or function the feature will **modify**, grep for all existing usages:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
grep -r "<endpoint-or-function-name>" src/ --include="*.ts" --include="*.tsx" -l
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
List every file that also consumes what this feature changes. These files may break silently after the change.
|
|
137
|
+
|
|
138
|
+
#### Step 2d — Gate
|
|
139
|
+
|
|
140
|
+
Present findings to the user before writing any documentation:
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
🔍 Data Flow Analysis — <feature-name>
|
|
144
|
+
|
|
145
|
+
Values this feature touches:
|
|
146
|
+
<field-name>
|
|
147
|
+
Computed: <file>:<line> — <brief description of logic>
|
|
148
|
+
Transport: <HTTP method> <route> → <TypeScript type>.<field>
|
|
149
|
+
Consumed: <component/file> (<transformation if any>)
|
|
150
|
+
|
|
151
|
+
Consistency issues:
|
|
152
|
+
✅ None found
|
|
153
|
+
— OR —
|
|
154
|
+
⚠️ HIGH: <description of divergence between parallel computations>
|
|
155
|
+
|
|
156
|
+
Impact:
|
|
157
|
+
Endpoints/functions modified: <list>
|
|
158
|
+
Also consumed by: <list of other files/views>
|
|
159
|
+
|
|
160
|
+
Data flow doc: .mdd/audits/flow-<feature-slug>-<date>.md
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Ask the user: **"Proceed with documentation? (yes / adjust scope based on findings / stop)"**
|
|
164
|
+
|
|
165
|
+
**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.
|
|
166
|
+
|
|
167
|
+
### Phase 3 — Write the MDD Documentation
|
|
168
|
+
|
|
169
|
+
Create the feature documentation file at `.mdd/docs/<NN>-<feature-name>.md`.
|
|
170
|
+
|
|
171
|
+
**Auto-number:** Read `.mdd/docs/` directory, find the highest existing number, increment by 1.
|
|
172
|
+
|
|
173
|
+
The doc MUST follow this exact structure:
|
|
174
|
+
|
|
175
|
+
```markdown
|
|
176
|
+
---
|
|
177
|
+
id: <NN>-<feature-name>
|
|
178
|
+
title: <Feature Title>
|
|
179
|
+
edition: <project name or "Both">
|
|
180
|
+
depends_on: [<list of documentation IDs this feature depends on>] ← feature docs only; never include task doc IDs (tasks are one-off and frozen)
|
|
181
|
+
source_files:
|
|
182
|
+
- <files that will be created>
|
|
183
|
+
routes:
|
|
184
|
+
- <API routes if applicable>
|
|
185
|
+
models:
|
|
186
|
+
- <database collections if applicable>
|
|
187
|
+
test_files:
|
|
188
|
+
- <test files that will be created>
|
|
189
|
+
data_flow: <path to .mdd/audits/flow-*.md, or "greenfield" if skipped>
|
|
190
|
+
last_synced: <YYYY-MM-DD>
|
|
191
|
+
status: draft
|
|
192
|
+
phase: <last completed phase name, or "all" when fully built>
|
|
193
|
+
mdd_version: <read from mdd.md frontmatter mdd_version field>
|
|
194
|
+
known_issues: []
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
# <NN> — <Feature Title>
|
|
198
|
+
|
|
199
|
+
## Purpose
|
|
200
|
+
|
|
201
|
+
<2-3 sentences explaining what this feature does and why it exists>
|
|
202
|
+
|
|
203
|
+
## Architecture
|
|
204
|
+
|
|
205
|
+
<How this feature fits into the system. Include a simple diagram if helpful.>
|
|
206
|
+
|
|
207
|
+
## Data Model
|
|
208
|
+
|
|
209
|
+
<Collection/table schema if applicable. Field names, types, constraints, indexes.>
|
|
210
|
+
|
|
211
|
+
## API Endpoints
|
|
212
|
+
|
|
213
|
+
<For each endpoint: method, path, auth required, request body, response shape, error cases.>
|
|
214
|
+
|
|
215
|
+
## Business Rules
|
|
216
|
+
|
|
217
|
+
<Validation rules, state machines, invariants, edge cases.>
|
|
218
|
+
|
|
219
|
+
## Data Flow
|
|
220
|
+
|
|
221
|
+
<For each value this feature consumes or displays: backend computation → API transport → frontend consumption → any UI transformation. "Greenfield" if no existing code was analyzed.>
|
|
222
|
+
|
|
223
|
+
## Dependencies
|
|
224
|
+
|
|
225
|
+
<What this feature requires from other features. List by documentation ID.>
|
|
226
|
+
|
|
227
|
+
## Known Issues
|
|
228
|
+
|
|
229
|
+
<Empty for new features. Will be populated by future audits.>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**CRITICAL:** This documentation is the source of truth. Everything that follows is generated FROM this doc. Take time to make it complete and accurate.
|
|
233
|
+
|
|
234
|
+
**Always set `last_synced` to today's date** when writing or updating a feature doc. This is what SCAN MODE uses to detect drift. Set `status: draft` for new docs; update to `in_progress` when implementation begins, `complete` when Phase 7 is done.
|
|
235
|
+
|
|
236
|
+
**After writing the feature doc**, trigger the `.mdd/.startup.md` rebuild (same logic as in Status Mode — rebuild auto-generated zone, preserve Notes zone) so the Features list stays current.
|
|
237
|
+
|
|
238
|
+
Show the completed doc to the user and ask: **"Does this accurately describe what you want to build? Anything to add or change?"**
|
|
239
|
+
|
|
240
|
+
Wait for confirmation before proceeding.
|
|
241
|
+
|
|
242
|
+
### Phase 4 — Generate Test Skeletons
|
|
243
|
+
|
|
244
|
+
Read the documentation file created in Phase 3. From the endpoints, business rules, and edge cases documented, generate test skeletons.
|
|
245
|
+
|
|
246
|
+
**Skeleton template (unit):**
|
|
247
|
+
```typescript
|
|
248
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
249
|
+
|
|
250
|
+
describe('<Feature Name>', () => {
|
|
251
|
+
// For each endpoint documented:
|
|
252
|
+
describe('<operation>', () => {
|
|
253
|
+
it('should <expected behavior from docs>', async () => {
|
|
254
|
+
// Arrange
|
|
255
|
+
// Act
|
|
256
|
+
// Assert — minimum 3 assertions based on documented response shape
|
|
257
|
+
expect.fail('Not implemented — MDD skeleton');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('should return <error> when <edge case from docs>', async () => {
|
|
261
|
+
expect.fail('Not implemented — MDD skeleton');
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Rules for skeleton generation:**
|
|
268
|
+
- One `describe` block per endpoint or business rule
|
|
269
|
+
- One `it` block per documented behavior (happy path + each error case)
|
|
270
|
+
- Every `it` block has `expect.fail('Not implemented — MDD skeleton')` as placeholder
|
|
271
|
+
- NO implementation yet — just the structure from the docs
|
|
272
|
+
- Include the exact response shapes and status codes from the documentation
|
|
273
|
+
|
|
274
|
+
**Parallelization rule:**
|
|
275
|
+
- If BOTH unit AND E2E tests are needed → launch 2 parallel `general-purpose` agents. Each receives: the full MDD doc content, the skeleton template above, project testing conventions, and the exact output file path. Agent A writes `tests/unit/<feature-name>.test.ts`, Agent B writes `tests/e2e/<feature-name>.spec.ts`. These are different files — no write conflict is possible.
|
|
276
|
+
- If only unit tests needed → generate directly in the main conversation (no agent overhead for a single file).
|
|
277
|
+
|
|
278
|
+
**E2E skeleton template (if applicable):**
|
|
279
|
+
```typescript
|
|
280
|
+
import { test, expect } from '@playwright/test';
|
|
281
|
+
|
|
282
|
+
test.describe('<Feature Name>', () => {
|
|
283
|
+
test('should <expected user flow from docs>', async ({ page }) => {
|
|
284
|
+
// Navigate
|
|
285
|
+
// Interact
|
|
286
|
+
// Assert
|
|
287
|
+
test.fail(); // Not implemented — MDD skeleton
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Tell the user:
|
|
293
|
+
```
|
|
294
|
+
📋 Test skeletons created:
|
|
295
|
+
- tests/unit/<feature-name>.test.ts (<N> test cases)
|
|
296
|
+
- tests/e2e/<feature-name>.spec.ts (<N> test cases) [if applicable]
|
|
297
|
+
|
|
298
|
+
These tests will FAIL until implementation is complete.
|
|
299
|
+
That's the point — they're the finish line.
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
### Phase 4b — Red Gate (mandatory)
|
|
305
|
+
|
|
306
|
+
**No skip condition.** This phase runs after every skeleton generation, every time.
|
|
307
|
+
|
|
308
|
+
Run ONLY the new test file(s) — not the full suite:
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
pnpm test:unit -- <path/to/new-test-file>
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
If E2E skeletons were generated, also run:
|
|
315
|
+
```bash
|
|
316
|
+
pnpm test:e2e:chromium -- <path/to/new-e2e-file>
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**For each test result:**
|
|
320
|
+
|
|
321
|
+
- **FAIL (expected):** ✓ — skeleton confirmed red
|
|
322
|
+
- **PASS (unexpected):** investigate immediately before proceeding
|
|
323
|
+
- No real assertion (empty `it` body, or `expect.fail` was removed)? Fix the skeleton to add proper assertion — do NOT adjust the test to pass, write the assertion correctly.
|
|
324
|
+
- Pre-existing code already satisfies the test? Adjust the skeleton to test the new behavior specifically, and document the overlap in the MDD doc's `known_issues`.
|
|
325
|
+
- Test file itself has a syntax error that's causing a false skip? Fix the syntax.
|
|
326
|
+
|
|
327
|
+
**Gate:** ALL tests must fail before proceeding to Phase 5. Block until confirmed red.
|
|
328
|
+
|
|
329
|
+
Report to the user:
|
|
330
|
+
```
|
|
331
|
+
🔴 Red Gate: <N>/<N> failing (expected)
|
|
332
|
+
All skeletons confirmed RED — ready to implement.
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
If any test passes unexpectedly and the fix isn't trivial, ask the user:
|
|
336
|
+
```
|
|
337
|
+
⚠️ Red Gate: <N>/<N> failing, <N> passing unexpectedly.
|
|
338
|
+
Test(s) passing: <test name(s)>
|
|
339
|
+
Diagnosis: <what's happening>
|
|
340
|
+
Proposed fix: <skeleton adjustment>
|
|
341
|
+
Proceed with fix? (yes / adjust differently / stop)
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Phase 5 — Present the Build Plan
|
|
345
|
+
|
|
346
|
+
**Auto-detect feature size** before choosing plan format:
|
|
347
|
+
|
|
348
|
+
- **Simple** — fewer than 3 new files, no API routes, no database: use flat steps (block overhead not warranted)
|
|
349
|
+
- **Medium or Large** — anything else: use block structure
|
|
350
|
+
|
|
351
|
+
#### Block structure (medium/large features)
|
|
352
|
+
|
|
353
|
+
Each block is a unit of work that satisfies three criteria:
|
|
354
|
+
1. **Runnable end-state** — after the block completes, code compiles, tests pass, no half-open interfaces
|
|
355
|
+
2. **Commit-worthy scope** — the block has a clear "why" that justifies a standalone conventional commit
|
|
356
|
+
3. **Own verification** — a concrete command that proves the block is done
|
|
357
|
+
|
|
358
|
+
**Block template:**
|
|
359
|
+
```
|
|
360
|
+
Block N (Name) [small | medium | large]
|
|
361
|
+
End-state: <what is compilable and runnable when this block finishes>
|
|
362
|
+
Commit scope: <conventional commit one-liner, e.g. "feat: add order types and DB schema">
|
|
363
|
+
Verify: <exact command — e.g. pnpm typecheck or pnpm test:unit -- --grep "orders">
|
|
364
|
+
Handoff: <what the next block expects to exist when this one finishes>
|
|
365
|
+
Runs in: main conversation | parallel agents (N)
|
|
366
|
+
|
|
367
|
+
Steps:
|
|
368
|
+
1. <specific file action — e.g. Create src/types/orders.ts — Order, OrderStatus, OrderLine>
|
|
369
|
+
2. <specific file action>
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
**Large block rule:** Must include `Justification: <why this block cannot be split>`. A valid justification is a shared type contract that forces backend + frontend into one atomic change. If the justification doesn't hold, auto-suggest the split before the user confirms.
|
|
373
|
+
|
|
374
|
+
**Parallelization annotation:**
|
|
375
|
+
Before assigning `Runs in: parallel agents`, verify both gates:
|
|
376
|
+
1. **File declaration gate:** List every file each parallel agent will write. If any file appears in more than one agent's list → mark as `Runs in: main conversation`. No exceptions.
|
|
377
|
+
2. **Type dependency gate:** If Block X creates types that Block Y's code imports → Block X must run first (Block Y gets `Depends on Block X`, sequential).
|
|
378
|
+
|
|
379
|
+
If both gates pass and the blocks are in the same dependency layer → mark as `Runs in: parallel agents (2)`.
|
|
380
|
+
|
|
381
|
+
**Dependency layers** (used to sequence blocks):
|
|
382
|
+
```
|
|
383
|
+
Layer 1 (no dependencies): Types, shared interfaces
|
|
384
|
+
Layer 2 (depends on Layer 1): Services, components, handlers
|
|
385
|
+
Layer 3 (depends on Layer 2): Route wiring, integration points
|
|
386
|
+
Layer 4 (depends on all): Test implementation, final wiring
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
**Build plan display:**
|
|
390
|
+
```
|
|
391
|
+
🔨 MDD Build Plan for: <Feature Name>
|
|
392
|
+
|
|
393
|
+
Documentation: .mdd/docs/<NN>-<feature-name>.md ✅
|
|
394
|
+
Test skeletons: <N> tests across <N> files ✅
|
|
395
|
+
Red Gate: <N>/<N> confirmed red ✅
|
|
396
|
+
|
|
397
|
+
Block 1 (Foundation) [small] → main conversation
|
|
398
|
+
End-state: Shared types compile clean
|
|
399
|
+
Commit scope: feat: add <feature> types and interfaces
|
|
400
|
+
Verify: pnpm typecheck
|
|
401
|
+
Handoff: User, Order, OrderStatus exported from src/types/orders.ts
|
|
402
|
+
|
|
403
|
+
Block 2 (Services) [medium] → parallel agents (2)
|
|
404
|
+
Backend sub-block: src/handlers/orders.ts, src/adapters/orders.ts
|
|
405
|
+
Frontend sub-block: src/components/OrderList.tsx, src/hooks/useOrders.ts
|
|
406
|
+
File overlap: NONE — safe to parallelize
|
|
407
|
+
Each agent receives: Block 1 output + full MDD doc + project conventions
|
|
408
|
+
|
|
409
|
+
Block 3 (Wiring) [small] → main conversation
|
|
410
|
+
End-state: Route registered, feature reachable at /api/v1/orders
|
|
411
|
+
Commit scope: feat: wire orders route into server
|
|
412
|
+
Verify: pnpm test:unit -- --grep "orders"
|
|
413
|
+
Handoff: POST /api/v1/orders returns 201
|
|
414
|
+
|
|
415
|
+
Block 4 (Tests) [small] → main conversation
|
|
416
|
+
End-state: All <N> skeletons passing, no regressions
|
|
417
|
+
Commit scope: test: implement orders feature test suite
|
|
418
|
+
Verify: pnpm test:unit
|
|
419
|
+
|
|
420
|
+
Total blocks: <N> (<N> sequential, <N> parallel batch)
|
|
421
|
+
Total new files: <N>
|
|
422
|
+
Tests to satisfy: <N>
|
|
423
|
+
|
|
424
|
+
Ready to build? (yes / modify plan / stop here)
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
**Step naming is MANDATORY** — every block has a unique name the user can reference when asking for changes.
|
|
428
|
+
|
|
429
|
+
**Flat step format (simple features only):**
|
|
430
|
+
```
|
|
431
|
+
🔨 MDD Build Plan for: <Feature Name>
|
|
432
|
+
|
|
433
|
+
Documentation: .mdd/docs/<NN>-<feature-name>.md ✅
|
|
434
|
+
Test skeletons: <N> tests ✅ Red Gate: <N>/<N> red ✅
|
|
435
|
+
|
|
436
|
+
Steps:
|
|
437
|
+
Step 1 (<name>): <what will be created>
|
|
438
|
+
Step 2 (<name>): <what will be created>
|
|
439
|
+
|
|
440
|
+
Tests to satisfy: <N>
|
|
441
|
+
|
|
442
|
+
Ready to build? (yes / modify plan / stop here)
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
Wait for user confirmation.
|
|
446
|
+
|
|
447
|
+
### Phase 6 — Implement (Test-Driven)
|
|
448
|
+
|
|
449
|
+
#### Step 6a — Layered execution
|
|
450
|
+
|
|
451
|
+
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.
|
|
452
|
+
|
|
453
|
+
**For parallel blocks:**
|
|
454
|
+
|
|
455
|
+
1. Verify file declaration gate one final time (list every file each agent writes — any overlap → fall back to sequential)
|
|
456
|
+
2. Launch both agents simultaneously. Each agent prompt must be **completely self-contained** and include:
|
|
457
|
+
- The full MDD doc content (embedded, not referenced by path)
|
|
458
|
+
- The specific block description and steps
|
|
459
|
+
- ALL output from Layer 1 (types files — embed the file contents, do not reference paths)
|
|
460
|
+
- Project coding conventions from CLAUDE.md
|
|
461
|
+
- Exact output file paths
|
|
462
|
+
- Explicit instruction: write the implementation only, do not run tests or typecheck
|
|
463
|
+
3. Collect both outputs
|
|
464
|
+
4. Run `pnpm typecheck` before proceeding to the next layer
|
|
465
|
+
5. If typecheck fails after a parallel batch: diagnose which agent's output is the cause before retrying. Fix in main conversation — do not re-launch agents blindly.
|
|
466
|
+
|
|
467
|
+
**For sequential blocks:** read the MDD doc, read the relevant test skeletons, implement, run the Green Gate loop below.
|
|
468
|
+
|
|
469
|
+
#### Step 6b — Green Gate loop (per block)
|
|
470
|
+
|
|
471
|
+
After each block's implementation (sequential or parallel), run the Green Gate:
|
|
472
|
+
|
|
473
|
+
```
|
|
474
|
+
Green Gate — Block N (Name)
|
|
475
|
+
|
|
476
|
+
Iteration 1–5:
|
|
477
|
+
Run: pnpm test:unit -- --grep "<feature>" AND pnpm typecheck
|
|
478
|
+
|
|
479
|
+
If ALL green:
|
|
480
|
+
→ proceed to regression check
|
|
481
|
+
|
|
482
|
+
If failing:
|
|
483
|
+
DIAGNOSE (required before any fix):
|
|
484
|
+
- What is the exact error message, file, and line?
|
|
485
|
+
- Which implementation assumption was wrong?
|
|
486
|
+
- Is this a known pattern? (check CLAUDE.md, project conventions)
|
|
487
|
+
- What is the ONE targeted fix?
|
|
488
|
+
|
|
489
|
+
FIX — implementation only:
|
|
490
|
+
- Tests are NEVER modified.
|
|
491
|
+
- If a test seems wrong → re-read the MDD doc first.
|
|
492
|
+
- If the doc seems wrong → STOP and ask the user before changing anything.
|
|
493
|
+
|
|
494
|
+
REPORT ONE LINE per iteration:
|
|
495
|
+
"Iteration N — Root cause: <X> / Fix applied: <Y>"
|
|
496
|
+
|
|
497
|
+
Iteration 5 exhausted, still failing:
|
|
498
|
+
STOP immediately. Do not attempt iteration 6.
|
|
499
|
+
Report to user:
|
|
500
|
+
"5 iterations reached. Still failing:
|
|
501
|
+
- <test name>: <diagnosis summary>
|
|
502
|
+
- <test name>: <diagnosis summary>
|
|
503
|
+
Options:
|
|
504
|
+
(a) continue debugging — I'll keep trying
|
|
505
|
+
(b) narrow scope — remove or defer these cases
|
|
506
|
+
(c) pause and review together"
|
|
507
|
+
Wait for user input.
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
**Regression check (after each block goes green):**
|
|
511
|
+
|
|
512
|
+
```bash
|
|
513
|
+
pnpm test:unit # full suite, including pre-existing tests
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Any regression failure is treated as a new failure for the SAME block — it counts against the remaining iteration budget. This prevents regressions from being silently deprioritized.
|
|
517
|
+
|
|
518
|
+
**Progress reporting:**
|
|
519
|
+
```
|
|
520
|
+
Block 1 (Foundation): ✅ — src/types/orders.ts created, typecheck clean
|
|
521
|
+
Block 2 (Services): 🔄 parallel agents running...
|
|
522
|
+
Block 2 (Services): ✅ — 8/8 tests passing, no regressions
|
|
523
|
+
Block 3 (Wiring): 🔄 in progress...
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
### Phase 7 — Verify + Report
|
|
527
|
+
|
|
528
|
+
#### Phase 7a — Quality Gates
|
|
529
|
+
|
|
530
|
+
```bash
|
|
531
|
+
pnpm typecheck # must pass — no errors
|
|
532
|
+
pnpm test:unit # all tests must pass (pre-existing + new)
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
These must both pass before proceeding to Phase 7b. If either fails here, return to Phase 6 (Green Gate) to fix.
|
|
536
|
+
|
|
537
|
+
#### Phase 7b — Integration Verification
|
|
538
|
+
|
|
539
|
+
Quality gates passing does not mean the feature works. This phase verifies actual behavior against the real runtime environment.
|
|
540
|
+
|
|
541
|
+
**Detect feature type** from MDD doc frontmatter (`routes`, `models`, source file paths, feature description):
|
|
542
|
+
|
|
543
|
+
**Backend feature** (has routes or handler files):
|
|
544
|
+
```
|
|
545
|
+
□ Start the server if not running
|
|
546
|
+
□ Trigger the full happy-path request — real HTTP call, real DB, not mocked
|
|
547
|
+
□ Watch backend logs during the run:
|
|
548
|
+
Any unexpected error, warning, or rate anomaly → investigate immediately
|
|
549
|
+
□ Verify: response shape matches documented response shape
|
|
550
|
+
□ Verify: response status code matches documented status code
|
|
551
|
+
□ Verify: DB state changed as expected (run a direct query to confirm)
|
|
552
|
+
□ Test at least one documented error case (bad input, missing auth, etc.)
|
|
553
|
+
□ Verify: error response matches documented error response
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
**Frontend feature** (has component or UI files):
|
|
557
|
+
```
|
|
558
|
+
□ Open the target page in the browser
|
|
559
|
+
□ Verify expected data is visible — "page loaded" is NOT sufficient
|
|
560
|
+
□ Click through the documented user flow step by step
|
|
561
|
+
□ Open network tab: confirm expected API calls are made
|
|
562
|
+
□ Open network tab: confirm expected responses are received
|
|
563
|
+
□ Check browser console: no errors or warnings from this feature's code
|
|
564
|
+
□ Test an error state (bad input, empty state, etc.) — verify it renders correctly
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
**Database feature** (has schema or model changes):
|
|
568
|
+
```
|
|
569
|
+
□ Write: verify rows/documents actually written — direct DB query, not insert return value
|
|
570
|
+
□ Read: verify reads return the expected data shape
|
|
571
|
+
□ Constraints: test invalid data produces the documented error (not a silent failure)
|
|
572
|
+
□ Performance: run EXPLAIN on primary query patterns — no full-table scans on large collections
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
**Tooling feature** (command, script, hook, or workflow):
|
|
576
|
+
```
|
|
577
|
+
□ Run against a real scenario — not contrived minimal input
|
|
578
|
+
□ Verify output exactly matches documented behavior (check actual output against doc)
|
|
579
|
+
□ Test documented error cases — verify each produces the documented error message
|
|
580
|
+
□ Confirm no unintended side effects on unrelated files or state
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
**Ownership Default — applies to ALL feature types:**
|
|
584
|
+
|
|
585
|
+
```
|
|
586
|
+
Any external failure (API unreachable, DB missing test data, service slow, key not set)
|
|
587
|
+
is a HYPOTHESIS — not an accepted fact — until empirically disproven.
|
|
588
|
+
|
|
589
|
+
Required procedure before accepting any external blocker as real:
|
|
590
|
+
Step 1: Read backend logs in full — what did the server actually receive and return?
|
|
591
|
+
Step 2: Run a minimal probe — the smallest possible request or script targeting the real interface
|
|
592
|
+
Step 3: Form a specific, falsifiable hypothesis — "The failure is at X because Y shows Z"
|
|
593
|
+
|
|
594
|
+
Default stance: "My code is wrong until proven otherwise."
|
|
595
|
+
This takes ~1 minute and eliminates the entire class of wrong-attribution bugs
|
|
596
|
+
where the agent patches the wrong thing because it accepted an external excuse too quickly.
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
#### Phase 7c — Completion Signal
|
|
600
|
+
|
|
601
|
+
**If integration verified:**
|
|
602
|
+
```
|
|
603
|
+
✅ MDD Complete: <Feature Name>
|
|
604
|
+
|
|
605
|
+
Documentation: .mdd/docs/<NN>-<feature-name>.md
|
|
606
|
+
Data flow doc: .mdd/audits/flow-<feature-slug>-<date>.md (or "greenfield")
|
|
607
|
+
Files created: <list>
|
|
608
|
+
Blocks: <N>/<N> complete
|
|
609
|
+
Tests: <N>/<N> passing
|
|
610
|
+
Integration: verified (<feature type> — real environment)
|
|
611
|
+
Typecheck: clean
|
|
612
|
+
|
|
613
|
+
Update doc: status → complete, phase → all, last_synced → <today>, mdd_version → <current from mdd.md frontmatter>
|
|
614
|
+
|
|
615
|
+
New patterns established: <any new rules worth adding to CLAUDE.md>
|
|
616
|
+
|
|
617
|
+
Branch: feat/<feature-name>
|
|
618
|
+
Ready for review — run `git diff main...HEAD` to see all changes.
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
**If integration NOT verified (external condition blocked it):**
|
|
622
|
+
```
|
|
623
|
+
⏸️ MDD Blocked: <Feature Name>
|
|
624
|
+
|
|
625
|
+
Blocked on: <exact condition — e.g. "STRIPE_API_KEY not set in .env">
|
|
626
|
+
Evidence: <what was run and what it returned>
|
|
627
|
+
Diagnosis: <specific hypothesis about the cause>
|
|
628
|
+
Next step: <concrete action to unblock — e.g. "Add STRIPE_API_KEY to .env, then re-run Phase 7b">
|
|
629
|
+
|
|
630
|
+
Code is complete. All <N> tests pass. Typecheck clean.
|
|
631
|
+
Feature is NOT marked done until Phase 7b passes.
|
|
632
|
+
Update doc: status → in_progress, phase → integration-pending, mdd_version → <current from mdd.md frontmatter>
|
|
633
|
+
|
|
634
|
+
When unblocked: resume at Phase 7b only. No re-implementation needed.
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
3. **Update documentation** — add any `known_issues` discovered during implementation
|
|
638
|
+
4. **Update CLAUDE.md** if new patterns were established
|
|
639
|
+
|
|
640
|
+
#### Phase 7d — Commit & Merge
|
|
641
|
+
|
|
642
|
+
**This phase runs after every completed MDD run (integration verified).** It does NOT run when blocked (Phase 7b failed).
|
|
643
|
+
|
|
644
|
+
Run `git diff main...HEAD --stat` and show the user a compact summary of all changes on the branch.
|
|
645
|
+
|
|
646
|
+
Then ask the user via AskUserQuestion:
|
|
647
|
+
|
|
648
|
+
```
|
|
649
|
+
🚀 Ready to ship?
|
|
650
|
+
|
|
651
|
+
Branch: feat/<feature-name>
|
|
652
|
+
Changes: <N files changed, N insertions, N deletions> (from git diff --stat)
|
|
653
|
+
|
|
654
|
+
(a) Commit & merge to main — stage all changes, commit, merge, return to main
|
|
655
|
+
(b) Commit only — stage and commit on this branch, stay here
|
|
656
|
+
(c) Skip — I'll handle git manually
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
**If (a) Commit & merge:**
|
|
660
|
+
1. Stage all changes: `git add -A`
|
|
661
|
+
2. Commit using the `/commit` skill (which generates a conventional commit message from context)
|
|
662
|
+
3. Switch to main: `git checkout main`
|
|
663
|
+
4. Merge: `git merge feat/<feature-name> --no-ff -m "Merge feat/<feature-name>: <feature title>"`
|
|
664
|
+
5. Ask: "✅ Merged to main. Push to origin now? (yes / no)"
|
|
665
|
+
- If yes: `git push origin main`
|
|
666
|
+
- If no: report "Branch `feat/<feature-name>` preserved. Run `git push` when ready."
|
|
667
|
+
|
|
668
|
+
**If (b) Commit only:**
|
|
669
|
+
1. Stage all changes: `git add -A`
|
|
670
|
+
2. Commit using the `/commit` skill
|
|
671
|
+
3. Ask: "✅ Committed on `feat/<feature-name>`. Push this branch to origin? (yes / no)"
|
|
672
|
+
- If yes: `git push origin feat/<feature-name>`
|
|
673
|
+
- If no: report "Run `git push` when ready."
|
|
674
|
+
|
|
675
|
+
**If (c) Skip:**
|
|
676
|
+
Report: "Skipped. Branch `feat/<feature-name>` — run `/commit` and then merge when ready."
|
|
677
|
+
|
|
678
|
+
---
|