id3-cli 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.ja-JP.md +769 -0
  2. package/README.ko-KR.md +769 -0
  3. package/README.md +769 -0
  4. package/README.tr-TR.md +769 -0
  5. package/README.zh-CN.md +769 -0
  6. package/dist/bin/cli.d.ts +2 -0
  7. package/dist/bin/cli.js +40 -0
  8. package/dist/bin/cli.js.map +1 -0
  9. package/dist/scripts/build-hooks.d.ts +1 -0
  10. package/dist/scripts/build-hooks.js +58 -0
  11. package/dist/scripts/build-hooks.js.map +1 -0
  12. package/dist/src/hooks/auto-audit.d.ts +4 -0
  13. package/dist/src/hooks/auto-audit.js +47 -0
  14. package/dist/src/hooks/auto-audit.js.map +1 -0
  15. package/dist/src/hooks/claude-pretool-entry.d.ts +1 -0
  16. package/dist/src/hooks/claude-pretool-entry.js +36 -0
  17. package/dist/src/hooks/claude-pretool-entry.js.map +1 -0
  18. package/dist/src/hooks/claude-stop-entry.d.ts +1 -0
  19. package/dist/src/hooks/claude-stop-entry.js +7 -0
  20. package/dist/src/hooks/claude-stop-entry.js.map +1 -0
  21. package/dist/src/hooks/post-commit-entry.d.ts +1 -0
  22. package/dist/src/hooks/post-commit-entry.js +7 -0
  23. package/dist/src/hooks/post-commit-entry.js.map +1 -0
  24. package/dist/src/hooks/pre-commit-entry.d.ts +1 -0
  25. package/dist/src/hooks/pre-commit-entry.js +16 -0
  26. package/dist/src/hooks/pre-commit-entry.js.map +1 -0
  27. package/dist/src/hooks/rule-check.d.ts +8 -0
  28. package/dist/src/hooks/rule-check.js +101 -0
  29. package/dist/src/hooks/rule-check.js.map +1 -0
  30. package/dist/src/hooks/schema-drift.d.ts +17 -0
  31. package/dist/src/hooks/schema-drift.js +151 -0
  32. package/dist/src/hooks/schema-drift.js.map +1 -0
  33. package/dist/src/hooks/shared.d.ts +43 -0
  34. package/dist/src/hooks/shared.js +98 -0
  35. package/dist/src/hooks/shared.js.map +1 -0
  36. package/dist/src/init.d.ts +20 -0
  37. package/dist/src/init.js +193 -0
  38. package/dist/src/init.js.map +1 -0
  39. package/dist/src/preview/mockup-generator.d.ts +56 -0
  40. package/dist/src/preview/mockup-generator.js +402 -0
  41. package/dist/src/preview/mockup-generator.js.map +1 -0
  42. package/dist/src/preview/renderer.d.ts +30 -0
  43. package/dist/src/preview/renderer.js +145 -0
  44. package/dist/src/preview/renderer.js.map +1 -0
  45. package/dist/src/preview/server.d.ts +9 -0
  46. package/dist/src/preview/server.js +55 -0
  47. package/dist/src/preview/server.js.map +1 -0
  48. package/dist/src/preview/ui-auditor.d.ts +27 -0
  49. package/dist/src/preview/ui-auditor.js +141 -0
  50. package/dist/src/preview/ui-auditor.js.map +1 -0
  51. package/dist/src/preview/ui-gate.d.ts +66 -0
  52. package/dist/src/preview/ui-gate.js +210 -0
  53. package/dist/src/preview/ui-gate.js.map +1 -0
  54. package/dist/src/utils/ascii.d.ts +7 -0
  55. package/dist/src/utils/ascii.js +41 -0
  56. package/dist/src/utils/ascii.js.map +1 -0
  57. package/dist/src/utils/fs.d.ts +6 -0
  58. package/dist/src/utils/fs.js +39 -0
  59. package/dist/src/utils/fs.js.map +1 -0
  60. package/dist/templates/hooks/iddd-auto-audit.js +121 -0
  61. package/dist/templates/hooks/iddd-schema-drift.js +279 -0
  62. package/dist/templates/hooks/post-commit +121 -0
  63. package/dist/templates/hooks/pre-commit +348 -0
  64. package/package.json +37 -0
  65. package/templates/.agents/skills/.gitkeep +0 -0
  66. package/templates/.claude/hooks/.gitkeep +0 -0
  67. package/templates/.claude/hooks/hook-config.json +34 -0
  68. package/templates/.claude/skills/.gitkeep +0 -0
  69. package/templates/.codex/.gitkeep +0 -0
  70. package/templates/.codex/hooks.json +40 -0
  71. package/templates/.iddd/commit-count +1 -0
  72. package/templates/.iddd/preview/.gitkeep +0 -0
  73. package/templates/AGENTS.md +204 -0
  74. package/templates/CLAUDE.md +215 -0
  75. package/templates/README.md +476 -0
  76. package/templates/docs/.gitkeep +0 -0
  77. package/templates/docs/business-rules.md +14 -0
  78. package/templates/docs/domain-glossary.md +8 -0
  79. package/templates/docs/info-debt.md +17 -0
  80. package/templates/docs/model-changelog.md +12 -0
  81. package/templates/hooks/.gitkeep +0 -0
  82. package/templates/hooks/iddd-auto-audit.js +121 -0
  83. package/templates/hooks/iddd-schema-drift.js +279 -0
  84. package/templates/hooks/post-commit +121 -0
  85. package/templates/hooks/pre-commit +348 -0
  86. package/templates/skills/id3-design-information/SKILL.md +170 -0
  87. package/templates/skills/id3-design-information/references/phase2-procedure.md +241 -0
  88. package/templates/skills/id3-design-ui/.gitkeep +0 -0
  89. package/templates/skills/id3-design-ui/SKILL.md +200 -0
  90. package/templates/skills/id3-design-ui/references/.gitkeep +0 -0
  91. package/templates/skills/id3-design-ui/references/step1-structure-derivation.md +177 -0
  92. package/templates/skills/id3-design-ui/references/step2-visual-contract.md +257 -0
  93. package/templates/skills/id3-design-ui/references/step3-gate-and-mockup.md +177 -0
  94. package/templates/skills/id3-design-ui/references/step4-implementation.md +244 -0
  95. package/templates/skills/id3-identify-entities/SKILL.md +239 -0
  96. package/templates/skills/id3-identify-entities/references/.gitkeep +0 -0
  97. package/templates/skills/id3-identify-entities/references/phase0-brownfield.md +377 -0
  98. package/templates/skills/id3-identify-entities/references/phase1-greenfield.md +319 -0
  99. package/templates/skills/id3-info-audit/.gitkeep +0 -0
  100. package/templates/skills/id3-info-audit/SKILL.md +191 -0
  101. package/templates/skills/id3-preview/.gitkeep +0 -0
  102. package/templates/skills/id3-preview/SKILL.md +168 -0
  103. package/templates/skills/id3-spawn-team/.gitkeep +0 -0
  104. package/templates/skills/id3-spawn-team/SKILL.md +213 -0
  105. package/templates/specs/.gitkeep +0 -0
  106. package/templates/specs/data-model.md +26 -0
  107. package/templates/specs/entity-catalog.md +22 -0
  108. package/templates/specs/ui-design-contract.md +54 -0
  109. package/templates/specs/ui-inventory.md +24 -0
  110. package/templates/specs/ui-structure.md +32 -0
  111. package/templates/src/.gitkeep +0 -0
  112. package/templates/steering/.gitkeep +0 -0
  113. package/templates/steering/data-conventions.md +42 -0
  114. package/templates/steering/product.md +38 -0
@@ -0,0 +1,319 @@
1
+ # Phase 1: Greenfield Structured Interview -- Detailed Procedures
2
+
3
+ This document provides the detailed interview procedures for Phase 1 (greenfield structured interview). The lead agent follows these steps to discover the domain's core information model through conversation with the user.
4
+
5
+ **Important:** This phase is NOT parallelized. The lead agent conducts the interview directly with the user. Domain discovery requires nuanced conversation that cannot be split across agents.
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ Phase 1 uses a structured interview approach to systematically discover all entities, attributes, relationships, and business rules for a new project. The interview follows a deliberate sequence: identify things first, then relationships, then rules, and finally validate against universal patterns.
12
+
13
+ ---
14
+
15
+ ## Step 1: Check Existing Artifacts
16
+
17
+ Before beginning the interview, check if any prior work exists:
18
+
19
+ 1. Read `specs/entity-catalog.md` -- if it contains entity definitions, summarize them
20
+ 2. Read `specs/data-model.md` -- if it contains an ERD, display it
21
+ 3. Read `steering/product.md` -- if the user has filled in the product vision, use it as context
22
+
23
+ If artifacts already exist, confirm with the user: "I found existing entity definitions. Should I build on these or start fresh?"
24
+
25
+ ---
26
+
27
+ ## Step 2: Information Identification Questions
28
+
29
+ The goal is to discover the core "things" (nouns) the system manages.
30
+
31
+ ### Primary Questions
32
+
33
+ Ask these questions in order. Adapt follow-ups based on the user's responses.
34
+
35
+ 1. **Core entities:** "What are the main 'things' (nouns) this system needs to manage?"
36
+ - Listen for concrete nouns: users, orders, products, documents, etc.
37
+ - Probe for hidden entities: "Are there any behind-the-scenes things like settings, configurations, or logs?"
38
+
39
+ 2. **Attributes per entity:** "For each of these things, what information does it contain?"
40
+ - Focus on the essential attributes, not exhaustive lists
41
+ - Ask: "What would you need to see on a detail page for this?"
42
+ - Ask: "What fields would a creation form have?"
43
+
44
+ 3. **Desired outputs:** "What does the user ultimately want to see? What screens, reports, or dashboards are most important?"
45
+ - This captures the "output image" -- the end result the system should produce
46
+ - Outputs often reveal hidden entities (e.g., a "sales report" implies aggregation entities)
47
+ - Follow the "outputs first, inputs later" principle
48
+
49
+ ### Recording During Interview
50
+
51
+ As the user describes entities, immediately draft entries:
52
+
53
+ ```
54
+ Entity: [Name]
55
+ Description: [one sentence from user's words]
56
+ Attributes (initial):
57
+ - [attribute]: [inferred type]
58
+ - [attribute]: [inferred type]
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Step 3: Relationship Questions
64
+
65
+ Discover how entities relate to each other.
66
+
67
+ ### Primary Questions
68
+
69
+ For each pair of entities that might be related:
70
+
71
+ 1. **Existence of relationship:** "How are [Entity A] and [Entity B] related?"
72
+ - Not all entities are related; it's okay if they aren't
73
+
74
+ 2. **Cardinality:** "Can one [Entity A] have multiple [Entity B]s, or is it one-to-one?"
75
+ - Common patterns: 1:1, 1:N, N:M
76
+ - For N:M, ask: "Does the relationship itself carry any information?" (implies a junction entity)
77
+
78
+ 3. **Delete rules:** "If a [Entity A] is deleted, what should happen to its [Entity B]s?"
79
+ - CASCADE: Delete children too
80
+ - SET NULL: Detach children (set FK to null)
81
+ - RESTRICT: Prevent deletion if children exist
82
+ - If the user is unsure, suggest the safest default (RESTRICT) and note it as a design decision for Phase 2
83
+
84
+ 4. **Optionality:** "Must every [Entity B] belong to an [Entity A], or can it exist independently?"
85
+ - This determines whether the FK is nullable
86
+
87
+ ### Recording During Interview
88
+
89
+ ```
90
+ Relationship: [EntityA] -> [EntityB]
91
+ Type: [1:1 | 1:N | N:M]
92
+ Cardinality: [e.g., "one User has many Orders"]
93
+ Delete Rule: [CASCADE | SET NULL | RESTRICT | TBD]
94
+ FK nullable: [yes | no]
95
+ Junction entity (if N:M): [name, if applicable]
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Step 4: Rule Questions
101
+
102
+ Discover business rules, constraints, and behaviors.
103
+
104
+ ### Primary Questions
105
+
106
+ 1. **Mandatory rules:** "Are there any rules this information must always follow?"
107
+ - Required fields beyond the obvious (e.g., "orders must have at least one line item")
108
+ - Value range restrictions (e.g., "quantity must be positive")
109
+ - Uniqueness constraints (e.g., "email must be unique per organization")
110
+
111
+ 2. **State transitions:** "Does anything have a lifecycle or status flow? For example: draft -> published -> archived"
112
+ - For each state machine, capture:
113
+ - Possible states
114
+ - Allowed transitions (which state can go to which)
115
+ - Trigger for each transition (user action, time-based, condition-based)
116
+ - Side effects of transitions (notifications, cascade updates)
117
+
118
+ 3. **Computed/derived values:** "Are there any values that are calculated from other values?"
119
+ - Examples: total price = sum of line items, full name = first + last
120
+ - Capture the formula or derivation logic
121
+ - Determine: stored (materialized) or computed on-the-fly?
122
+
123
+ 4. **Conditional rules:** "Are there rules that apply only in certain situations?"
124
+ - Context-dependent validation
125
+ - Role-based access patterns
126
+ - Time-based constraints
127
+
128
+ ### Recording During Interview
129
+
130
+ ```
131
+ Rule: BR-[number]
132
+ Entity: [related entity]
133
+ Type: Constraint | Derivation | Transition | Validity
134
+ Description: [what the rule says]
135
+ Details: [formula, allowed transitions, conditions, etc.]
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Step 5: Silverston Universal Pattern Checklist
141
+
142
+ After the interview, cross-reference discovered entities against Len Silverston's universal data model patterns. This catches common domain concepts the user may have forgotten to mention.
143
+
144
+ ### Checklist
145
+
146
+ Go through each pattern and ask if it applies:
147
+
148
+ - [ ] **Party** (person, organization, role)
149
+ - "Does the system manage different types of people or organizations? Do they have different roles?"
150
+ - Common sub-patterns: User, Employee, Customer, Organization, Role, Permission
151
+
152
+ - [ ] **Product/Service** (product, service, catalog)
153
+ - "Does the system deal with products, services, or things that can be offered/sold?"
154
+ - Common sub-patterns: Product, Service, Catalog, Category, Pricing, Variant
155
+
156
+ - [ ] **Order/Transaction** (order, transaction, event)
157
+ - "Are there transactions, orders, or events that need to be recorded?"
158
+ - Common sub-patterns: Order, OrderLine, Payment, Invoice, Transaction
159
+
160
+ - [ ] **Classification/Category** (classification, tag, category)
161
+ - "Do any entities need to be categorized, tagged, or classified?"
162
+ - Common sub-patterns: Category, Tag, Label, Type (reference tables)
163
+
164
+ - [ ] **Status/Lifecycle** (status, stage, transition)
165
+ - "Do any entities go through stages or have a status that changes over time?"
166
+ - Already captured in Step 4, but verify completeness
167
+
168
+ - [ ] **Hierarchy** (hierarchy, tree, parent-child)
169
+ - "Are there any tree-like structures? Categories within categories? Organizations within organizations?"
170
+ - Common patterns: self-referencing FK, nested set, materialized path
171
+
172
+ - [ ] **Contact Mechanism** (email, phone, address)
173
+ - "Do you need to store contact information? Multiple emails or phones per person?"
174
+ - Pattern decision: embedded in Party entity vs. separate ContactMechanism entity
175
+
176
+ - [ ] **Document/Content** (document, content, attachment)
177
+ - "Does the system manage documents, files, or rich content?"
178
+ - Storage decision: inline vs. object storage (S3/GCS) -- note for Phase 2
179
+
180
+ ### Gap Analysis
181
+
182
+ For any pattern that reveals a missing entity:
183
+ 1. Explain to the user what was found
184
+ 2. Ask: "Should we include this in the model?"
185
+ 3. If yes, add the entity and repeat Steps 2-4 for it
186
+
187
+ ---
188
+
189
+ ## Artifact Generation
190
+
191
+ ### specs/entity-catalog.md
192
+
193
+ For each entity:
194
+
195
+ ```markdown
196
+ ## Entity: [Name]
197
+ - **Description**: [one sentence in the user's own words]
198
+ - **Attributes**:
199
+ | Name | Type | Required | Constraints | Notes |
200
+ |------|------|----------|-------------|-------|
201
+ | id | UUID | Yes | PK | Primary key |
202
+ | ... | ... | ... | ... | ... |
203
+ - **Relationships**:
204
+ | Target | Type | Cardinality | Delete Rule |
205
+ |--------|------|-------------|-------------|
206
+ | ... | ... | ... | ... |
207
+ - **State Transitions**: [if applicable]
208
+ - [State A] -> [State B]: [trigger/condition]
209
+ - [State B] -> [State C]: [trigger/condition]
210
+ - **Business Rules**: BR-001, BR-003 [reference numbers]
211
+ ```
212
+
213
+ ### specs/data-model.md
214
+
215
+ ```markdown
216
+ ---
217
+ version: "0.1"
218
+ last_verified: "YYYY-MM-DD"
219
+ phase: "Phase 1 Complete"
220
+ entity_count: N
221
+ rule_count: N
222
+ audit_status: "clean"
223
+ ---
224
+
225
+ # Data Model
226
+
227
+ ## ER Diagram
228
+
229
+ \`\`\`mermaid
230
+ erDiagram
231
+ ENTITY_A ||--o{ ENTITY_B : "relationship description"
232
+ ENTITY_A {
233
+ uuid id PK
234
+ string name
235
+ timestamp created_at
236
+ }
237
+ ENTITY_B {
238
+ uuid id PK
239
+ uuid entity_a_id FK
240
+ string title
241
+ }
242
+ \`\`\`
243
+
244
+ ## Index Strategy
245
+
246
+ (To be filled in Phase 2)
247
+
248
+ ## Design Decision Log
249
+
250
+ | Decision ID | Subject | Choice | Reason | Date |
251
+ |-------------|---------|--------|--------|------|
252
+ | (To be filled in Phase 2) | | | | |
253
+ ```
254
+
255
+ ### docs/business-rules.md
256
+
257
+ ```markdown
258
+ ### BR-001: [Rule Name]
259
+ - **Entity**: [related entity]
260
+ - **Type**: Constraint | Derivation | Transition | Validity
261
+ - **Description**: [rule description]
262
+ - **Enforcement Location**: (To be determined in Phase 2)
263
+ - **Implementation**: (To be determined in Phase 2)
264
+ ```
265
+
266
+ ---
267
+
268
+ ## Interview Best Practices
269
+
270
+ 1. **Use the user's language:** Record entities and attributes using the terms the user actually uses. Build the ubiquitous language naturally.
271
+
272
+ 2. **Don't over-engineer:** Phase 1 captures the conceptual model. Detailed data types, indexes, and storage decisions come in Phase 2.
273
+
274
+ 3. **Capture uncertainty:** If the user says "maybe" or "I'm not sure," record it with a note. Don't force premature decisions.
275
+
276
+ 4. **Show progress:** After every 3-4 entities, show the current ERD to the user. Visual feedback keeps the conversation grounded.
277
+
278
+ 5. **Know when to stop:** Phase 1 is complete when:
279
+ - All core entities are identified
280
+ - Major relationships are mapped
281
+ - Key business rules are captured
282
+ - The Silverston checklist has been reviewed
283
+ - The user confirms the model looks right
284
+
285
+ 6. **Update domain glossary:** As new terms emerge, add them to `docs/domain-glossary.md` with clear definitions. This is the ubiquitous language dictionary.
286
+
287
+ ---
288
+
289
+ ## Preview Integration
290
+
291
+ After completing the interview and generating artifacts:
292
+
293
+ 1. Generate the ERD from `specs/data-model.md` Mermaid content
294
+ 2. Write it to `.iddd/preview/erd-phase1.html`
295
+ 3. Start the preview server and display the URL
296
+ 4. Walk the user through the visual ERD for final confirmation
297
+
298
+ ---
299
+
300
+ ## Completion
301
+
302
+ Update version headers in `specs/entity-catalog.md` and `specs/data-model.md`:
303
+ - `version: "0.1"`
304
+ - `phase: "Phase 1 Complete"`
305
+ - `last_verified: "YYYY-MM-DD"`
306
+ - `entity_count` and `rule_count` with actual counts
307
+
308
+ Add an entry to `docs/model-changelog.md`:
309
+
310
+ ```markdown
311
+ ## [0.1] -- YYYY-MM-DD
312
+ ### Phase 1 Complete
313
+ - N entities identified through structured interview
314
+ - M relationships mapped
315
+ - K business rules recorded
316
+ - Silverston checklist reviewed
317
+ ```
318
+
319
+ Output the completion message with entity count, relationship count, and business rule count. Advise the user to proceed to Phase 2 (information design) with "design information" or use `/id3-spawn-team` if they want to compose a downstream Agent Team.
File without changes
@@ -0,0 +1,191 @@
1
+ ---
2
+ name: id3-info-audit
3
+ description: >
4
+ Run a comprehensive information model audit. Compares entity-catalog.md against
5
+ the actual codebase, checks business rule enforcement, UI consistency, version
6
+ headers, and hook bypass history. Produces a visual audit report.
7
+ Trigger: info audit, information audit, model audit, audit entities,
8
+ check consistency, verify model, run audit
9
+ allowed-tools: Read, Glob, Grep, Bash, Write, Edit
10
+ user-invocable: true
11
+ ---
12
+
13
+ # Information Model Audit
14
+
15
+ You are the lead agent performing an IDDD information model audit. This skill systematically compares the declared information model (`specs/entity-catalog.md`) against the actual codebase, business rule enforcement, UI consistency, and operational hygiene. The output is a structured audit report with per-entity verdicts.
16
+
17
+ ## Prerequisites
18
+
19
+ Before starting, verify:
20
+ 1. `specs/entity-catalog.md` exists and contains at least one entity.
21
+ 2. `specs/data-model.md` exists.
22
+
23
+ If prerequisites are not met, respond:
24
+
25
+ > "No information model found. Run 'identify entities' (Phase 0/1) first to create the entity catalog."
26
+
27
+ ---
28
+
29
+ ## Audit Procedure
30
+
31
+ Execute the following 6 steps in order. Do not skip any step.
32
+
33
+ ### Step 1: Entity List Extraction
34
+
35
+ 1. Read `specs/entity-catalog.md` and extract the full list of declared entities.
36
+ 2. For each entity, record: name, attribute count, relationship count, associated business rules (BR-xxx references).
37
+ 3. Read `specs/data-model.md` and cross-reference: every entity in the catalog must appear in the ERD, and vice versa.
38
+ 4. Flag any discrepancies between entity-catalog.md and data-model.md.
39
+
40
+ **Output:** Entity checklist with catalog-ERD consistency status.
41
+
42
+ ### Step 2: Codebase Scan
43
+
44
+ For each declared entity, scan the codebase for its implementation:
45
+
46
+ 1. **Model/schema files:** Search for entity name in ORM definitions, migration files, and schema declarations. Verify:
47
+ - All declared attributes exist in the implementation.
48
+ - Data types match the spec (entity-catalog.md types vs actual implementation types).
49
+ - Constraints match (NOT NULL, UNIQUE, DEFAULT, CHECK).
50
+ - Indexes declared in data-model.md are present.
51
+
52
+ 2. **Unimplemented entities:** Entities in entity-catalog.md with no corresponding code implementation.
53
+
54
+ 3. **Undeclared models:** Code-level models/tables not present in entity-catalog.md (schema drift).
55
+
56
+ 4. **Business rule enforcement:** For each BR-xxx in `docs/business-rules.md`:
57
+ - Check if the rule is enforced at the declared location (DB constraint, application logic, or both).
58
+ - Search for validation patterns (Zod, Yup, Joi, Pydantic, @Valid, etc.) and match against declared rules.
59
+ - Flag rules with no detectable enforcement.
60
+
61
+ **Verdict per entity:**
62
+ - `PASS` -- All attributes, types, constraints, and rules match.
63
+ - `WARN` -- Minor discrepancies (naming convention differences, missing non-critical indexes).
64
+ - `FAIL` -- Missing attributes, wrong types, missing constraints, or unenforced rules.
65
+
66
+ ### Step 3: UI Consistency Check
67
+
68
+ If `specs/output-designs.md` exists, check UI implementations:
69
+
70
+ 1. **Unimplemented screens:** Screen proposals in output-designs.md with no corresponding UI code.
71
+ 2. **Undeclared screens:** UI routes/pages not referenced in output-designs.md.
72
+ 3. **Form field mapping:** For each form in the UI, verify fields correspond to entity attributes. Flag fields that do not map to any declared attribute.
73
+ 4. **Navigation paths:** Verify relationship navigation links match the declared entity relationships.
74
+
75
+ If `specs/output-designs.md` does not exist, skip this step and note it in the report.
76
+
77
+ **Verdict per screen:**
78
+ - `PASS` -- Screen matches output-designs.md proposal.
79
+ - `WARN` -- Minor deviations (styling, layout differences).
80
+ - `FAIL` -- Missing fields, wrong entity mapping, broken navigation.
81
+
82
+ ### Step 4: Version Header Verification
83
+
84
+ Read YAML frontmatter from `specs/entity-catalog.md` and `specs/data-model.md`:
85
+
86
+ 1. Check `last_verified` date. If more than 7 days ago (or empty), flag as stale.
87
+ 2. Check `version` consistency between entity-catalog.md and data-model.md.
88
+ 3. Check `entity_count` matches the actual number of entities in the file.
89
+ 4. Check `rule_count` matches the actual number of rules in business-rules.md.
90
+
91
+ Update frontmatter:
92
+ ```yaml
93
+ last_verified: "YYYY-MM-DD" # today's date
94
+ audit_status: "clean" | "warnings" | "failures"
95
+ entity_count: N # actual count
96
+ rule_count: N # actual count
97
+ ```
98
+
99
+ ### Step 5: Hook Bypass History
100
+
101
+ Check `.iddd/skip-history.log` for hook bypass events:
102
+
103
+ 1. If the file exists, read all entries.
104
+ 2. Count bypasses since the last audit (based on `last_verified` date).
105
+ 3. For each bypass, check if the bypassed check has been subsequently resolved:
106
+ - Schema drift bypasses: was entity-catalog.md updated afterward?
107
+ - Rule check bypasses: was business-rules.md updated afterward?
108
+ 4. Flag unresolved bypasses.
109
+
110
+ If `.iddd/skip-history.log` does not exist or is empty, record "No hook bypasses detected."
111
+
112
+ ### Step 6: Audit Report Generation
113
+
114
+ Compile findings into a structured report.
115
+
116
+ **Console output format:**
117
+
118
+ ```
119
+ ┌─ Information Model Audit Report ─────────────┐
120
+ │ │
121
+ │ Date: YYYY-MM-DD │
122
+ │ Entities: N declared, M implemented │
123
+ │ Rules: K declared, J enforced │
124
+ │ │
125
+ │ Entity Results: │
126
+ │ ✅ User - all checks passed │
127
+ │ ⚠️ Order - missing index on status │
128
+ │ ❌ Notification - not implemented │
129
+ │ │
130
+ │ UI Results: │
131
+ │ ✅ User List - matches spec │
132
+ │ ❌ Order Detail - missing 3 fields │
133
+ │ │
134
+ │ Rule Enforcement: │
135
+ │ ✅ BR-001 through BR-008 - enforced │
136
+ │ ❌ BR-009 - no enforcement found │
137
+ │ │
138
+ │ Hook Bypasses: 2 unresolved │
139
+ │ Version Headers: updated │
140
+ │ │
141
+ │ Overall: ⚠️ WARNINGS (3 warn, 2 fail) │
142
+ │ │
143
+ └───────────────────────────────────────────────┘
144
+ ```
145
+
146
+ **Verdict symbols:**
147
+ - `✅` -- Passed. Entity/screen/rule fully consistent.
148
+ - `⚠️` -- Warning. Minor issues that should be addressed.
149
+ - `❌` -- Failed. Significant discrepancy requiring immediate attention.
150
+
151
+ **Overall verdict:**
152
+ - `CLEAN` -- All checks passed.
153
+ - `WARNINGS` -- Only warnings, no failures.
154
+ - `FAILURES` -- One or more failures detected.
155
+
156
+ ---
157
+
158
+ ## Preview Integration
159
+
160
+ After generating the console report, create a visual audit dashboard:
161
+
162
+ 1. Generate `.iddd/preview/audit-{date}.html` (where `{date}` is today in YYYY-MM-DD format).
163
+ 2. The HTML should include:
164
+ - Summary statistics (entity count, rule count, pass/warn/fail counts).
165
+ - Per-entity card layout with status badge (green/yellow/red).
166
+ - Expandable details for each entity showing specific findings.
167
+ - Business rule coverage visualization.
168
+ - Hook bypass timeline (if any).
169
+ 3. Start the preview server and display the URL:
170
+
171
+ ```
172
+ ┌─ 📊 Audit Report Ready ─────────────────────┐
173
+ │ │
174
+ │ Dashboard: http://localhost:PORT/audit │
175
+ │ File: .iddd/preview/audit-YYYY-MM-DD.html │
176
+ │ │
177
+ └───────────────────────────────────────────────┘
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Completion
183
+
184
+ After the audit is complete:
185
+
186
+ 1. Version headers in entity-catalog.md and data-model.md have been updated (Step 4).
187
+ 2. The audit report is displayed in the console.
188
+ 3. The preview HTML is generated and the server URL is displayed.
189
+ 4. Display a summary message:
190
+
191
+ > "Audit complete. N entities checked: X passed, Y warnings, Z failures. See the dashboard at http://localhost:PORT/audit or open .iddd/preview/audit-{date}.html directly."
File without changes
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: id3-preview
3
+ description: >
4
+ Start the IDDD preview server to view ERD diagrams, UI mockups, and audit
5
+ reports in the browser. Generates HTML from current specs/ files and serves
6
+ existing .iddd/preview/ files.
7
+ Trigger: preview, start preview, show ERD, view model, visual preview,
8
+ open preview, show diagram, render ERD
9
+ allowed-tools: Read, Glob, Grep, Bash, Write, Edit
10
+ user-invocable: true
11
+ ---
12
+
13
+ # IDDD Preview Server
14
+
15
+ You are the lead agent starting the IDDD visual preview system. This skill generates HTML renderings of the information model (ERD, UI mockups, audit reports) and serves them via a local HTTP server for browser-based review.
16
+
17
+ ## What This Skill Does
18
+
19
+ 1. Reads current `specs/` files and generates interactive HTML previews.
20
+ 2. Serves existing files in `.iddd/preview/` alongside newly generated ones.
21
+ 3. Starts a local HTTP server and displays the URL for browser access.
22
+
23
+ ---
24
+
25
+ ## Procedure
26
+
27
+ ### Step 1: Check for Existing Previews
28
+
29
+ Scan `.iddd/preview/` for existing HTML files:
30
+
31
+ ```bash
32
+ ls -la .iddd/preview/*.html 2>/dev/null
33
+ ```
34
+
35
+ List any existing files to the user so they know what is already available.
36
+
37
+ ### Step 2: Generate Previews from Current Specs
38
+
39
+ Generate or regenerate HTML previews based on the current state of spec files.
40
+
41
+ #### ERD Preview
42
+
43
+ If `specs/data-model.md` exists and contains a Mermaid ERD code block:
44
+
45
+ 1. Extract the Mermaid ERD code block from `specs/data-model.md`.
46
+ 2. Generate `.iddd/preview/erd.html` with the following structure:
47
+ - HTML5 document with Mermaid.js loaded from CDN (`https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js`).
48
+ - Mermaid configuration: `startOnLoad: false`, `maxTextSize: 200000` (for large ERDs).
49
+ - Explicit `mermaid.run()` call after DOM load.
50
+ - Dark/light theme toggle button.
51
+ - Entity click handler that displays entity details from `specs/entity-catalog.md` in a side panel.
52
+ - Responsive layout that works on various screen sizes.
53
+
54
+ #### UI Mockup Preview
55
+
56
+ If `specs/output-designs.md` exists and contains screen proposals:
57
+
58
+ 1. Extract screen proposals from `specs/output-designs.md`.
59
+ 2. Generate `.iddd/preview/mockup.html` with:
60
+ - HTML/CSS wireframe rendering of each proposed screen.
61
+ - Navigation links between screens (based on entity relationships).
62
+ - Entity-screen mapping highlights.
63
+ - Each screen clearly labeled with its entity context.
64
+
65
+ #### Audit Preview
66
+
67
+ If any `audit-*.html` file exists in `.iddd/preview/`, it will be served as-is. To generate a new audit report, use `/id3-info-audit` instead.
68
+
69
+ ### Step 3: Start the Preview Server
70
+
71
+ Start a local HTTP server to serve the `.iddd/preview/` directory:
72
+
73
+ ```bash
74
+ node -e "
75
+ const http = require('http');
76
+ const fs = require('fs');
77
+ const path = require('path');
78
+
79
+ const dir = path.resolve('.iddd/preview');
80
+ const mime = { '.html': 'text/html', '.css': 'text/css', '.js': 'application/javascript', '.json': 'application/json', '.png': 'image/png', '.svg': 'image/svg+xml' };
81
+
82
+ const server = http.createServer((req, res) => {
83
+ const url = req.url === '/' ? '/index.html' : req.url;
84
+ const filePath = path.join(dir, url);
85
+ const ext = path.extname(filePath);
86
+ fs.readFile(filePath, (err, data) => {
87
+ if (err) {
88
+ // Try with .html extension
89
+ fs.readFile(filePath + '.html', (err2, data2) => {
90
+ if (err2) {
91
+ res.writeHead(404);
92
+ res.end('Not found');
93
+ } else {
94
+ res.writeHead(200, { 'Content-Type': 'text/html' });
95
+ res.end(data2);
96
+ }
97
+ });
98
+ } else {
99
+ res.writeHead(200, { 'Content-Type': mime[ext] || 'text/plain' });
100
+ res.end(data);
101
+ }
102
+ });
103
+ });
104
+
105
+ server.listen(0, () => {
106
+ const port = server.address().port;
107
+ console.log('Preview server running at http://localhost:' + port);
108
+ });
109
+ "
110
+ ```
111
+
112
+ The server uses `listen(0)` so the OS assigns an available port automatically.
113
+
114
+ ### Step 4: Generate Index Page
115
+
116
+ Create `.iddd/preview/index.html` as a landing page that links to all available previews:
117
+
118
+ ```html
119
+ <!DOCTYPE html>
120
+ <html lang="en">
121
+ <head>
122
+ <meta charset="UTF-8">
123
+ <title>IDDD Preview</title>
124
+ <style>
125
+ body { font-family: system-ui, sans-serif; max-width: 800px; margin: 2rem auto; padding: 0 1rem; }
126
+ h1 { border-bottom: 2px solid #333; padding-bottom: 0.5rem; }
127
+ .card { border: 1px solid #ddd; border-radius: 8px; padding: 1rem; margin: 1rem 0; }
128
+ .card h2 { margin-top: 0; }
129
+ a { color: #0066cc; }
130
+ </style>
131
+ </head>
132
+ <body>
133
+ <h1>IDDD Preview Dashboard</h1>
134
+ <!-- Links to erd.html, mockup.html, audit-*.html -->
135
+ </body>
136
+ </html>
137
+ ```
138
+
139
+ Populate the links dynamically based on which files exist in `.iddd/preview/`.
140
+
141
+ ### Step 5: Display Server URL
142
+
143
+ After the server starts, display the access information:
144
+
145
+ ```
146
+ ┌─ Preview Ready ──────────────────────────────┐
147
+ │ │
148
+ │ Dashboard: http://localhost:PORT │
149
+ │ ERD: http://localhost:PORT/erd │
150
+ │ Mockup: http://localhost:PORT/mockup │
151
+ │ │
152
+ │ Files: .iddd/preview/ │
153
+ │ │
154
+ │ Press Ctrl+C to stop the server. │
155
+ │ │
156
+ └───────────────────────────────────────────────┘
157
+ ```
158
+
159
+ Only show links for files that actually exist.
160
+
161
+ ---
162
+
163
+ ## Notes
164
+
165
+ - **Port assignment:** The server always uses `listen(0)` for automatic port selection. Do not hardcode a port number.
166
+ - **File persistence:** All generated HTML files remain in `.iddd/preview/` after the server stops. Users can open them directly in a browser without the server.
167
+ - **Regeneration:** Running this skill again regenerates previews from the latest specs. Existing audit HTML files are preserved (they are generated by `/id3-info-audit`).
168
+ - **No external dependencies:** The server uses only Node.js built-in modules. Mermaid.js is loaded from CDN in the generated HTML.
File without changes