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.
- package/README.ja-JP.md +769 -0
- package/README.ko-KR.md +769 -0
- package/README.md +769 -0
- package/README.tr-TR.md +769 -0
- package/README.zh-CN.md +769 -0
- package/dist/bin/cli.d.ts +2 -0
- package/dist/bin/cli.js +40 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/scripts/build-hooks.d.ts +1 -0
- package/dist/scripts/build-hooks.js +58 -0
- package/dist/scripts/build-hooks.js.map +1 -0
- package/dist/src/hooks/auto-audit.d.ts +4 -0
- package/dist/src/hooks/auto-audit.js +47 -0
- package/dist/src/hooks/auto-audit.js.map +1 -0
- package/dist/src/hooks/claude-pretool-entry.d.ts +1 -0
- package/dist/src/hooks/claude-pretool-entry.js +36 -0
- package/dist/src/hooks/claude-pretool-entry.js.map +1 -0
- package/dist/src/hooks/claude-stop-entry.d.ts +1 -0
- package/dist/src/hooks/claude-stop-entry.js +7 -0
- package/dist/src/hooks/claude-stop-entry.js.map +1 -0
- package/dist/src/hooks/post-commit-entry.d.ts +1 -0
- package/dist/src/hooks/post-commit-entry.js +7 -0
- package/dist/src/hooks/post-commit-entry.js.map +1 -0
- package/dist/src/hooks/pre-commit-entry.d.ts +1 -0
- package/dist/src/hooks/pre-commit-entry.js +16 -0
- package/dist/src/hooks/pre-commit-entry.js.map +1 -0
- package/dist/src/hooks/rule-check.d.ts +8 -0
- package/dist/src/hooks/rule-check.js +101 -0
- package/dist/src/hooks/rule-check.js.map +1 -0
- package/dist/src/hooks/schema-drift.d.ts +17 -0
- package/dist/src/hooks/schema-drift.js +151 -0
- package/dist/src/hooks/schema-drift.js.map +1 -0
- package/dist/src/hooks/shared.d.ts +43 -0
- package/dist/src/hooks/shared.js +98 -0
- package/dist/src/hooks/shared.js.map +1 -0
- package/dist/src/init.d.ts +20 -0
- package/dist/src/init.js +193 -0
- package/dist/src/init.js.map +1 -0
- package/dist/src/preview/mockup-generator.d.ts +56 -0
- package/dist/src/preview/mockup-generator.js +402 -0
- package/dist/src/preview/mockup-generator.js.map +1 -0
- package/dist/src/preview/renderer.d.ts +30 -0
- package/dist/src/preview/renderer.js +145 -0
- package/dist/src/preview/renderer.js.map +1 -0
- package/dist/src/preview/server.d.ts +9 -0
- package/dist/src/preview/server.js +55 -0
- package/dist/src/preview/server.js.map +1 -0
- package/dist/src/preview/ui-auditor.d.ts +27 -0
- package/dist/src/preview/ui-auditor.js +141 -0
- package/dist/src/preview/ui-auditor.js.map +1 -0
- package/dist/src/preview/ui-gate.d.ts +66 -0
- package/dist/src/preview/ui-gate.js +210 -0
- package/dist/src/preview/ui-gate.js.map +1 -0
- package/dist/src/utils/ascii.d.ts +7 -0
- package/dist/src/utils/ascii.js +41 -0
- package/dist/src/utils/ascii.js.map +1 -0
- package/dist/src/utils/fs.d.ts +6 -0
- package/dist/src/utils/fs.js +39 -0
- package/dist/src/utils/fs.js.map +1 -0
- package/dist/templates/hooks/iddd-auto-audit.js +121 -0
- package/dist/templates/hooks/iddd-schema-drift.js +279 -0
- package/dist/templates/hooks/post-commit +121 -0
- package/dist/templates/hooks/pre-commit +348 -0
- package/package.json +37 -0
- package/templates/.agents/skills/.gitkeep +0 -0
- package/templates/.claude/hooks/.gitkeep +0 -0
- package/templates/.claude/hooks/hook-config.json +34 -0
- package/templates/.claude/skills/.gitkeep +0 -0
- package/templates/.codex/.gitkeep +0 -0
- package/templates/.codex/hooks.json +40 -0
- package/templates/.iddd/commit-count +1 -0
- package/templates/.iddd/preview/.gitkeep +0 -0
- package/templates/AGENTS.md +204 -0
- package/templates/CLAUDE.md +215 -0
- package/templates/README.md +476 -0
- package/templates/docs/.gitkeep +0 -0
- package/templates/docs/business-rules.md +14 -0
- package/templates/docs/domain-glossary.md +8 -0
- package/templates/docs/info-debt.md +17 -0
- package/templates/docs/model-changelog.md +12 -0
- package/templates/hooks/.gitkeep +0 -0
- package/templates/hooks/iddd-auto-audit.js +121 -0
- package/templates/hooks/iddd-schema-drift.js +279 -0
- package/templates/hooks/post-commit +121 -0
- package/templates/hooks/pre-commit +348 -0
- package/templates/skills/id3-design-information/SKILL.md +170 -0
- package/templates/skills/id3-design-information/references/phase2-procedure.md +241 -0
- package/templates/skills/id3-design-ui/.gitkeep +0 -0
- package/templates/skills/id3-design-ui/SKILL.md +200 -0
- package/templates/skills/id3-design-ui/references/.gitkeep +0 -0
- package/templates/skills/id3-design-ui/references/step1-structure-derivation.md +177 -0
- package/templates/skills/id3-design-ui/references/step2-visual-contract.md +257 -0
- package/templates/skills/id3-design-ui/references/step3-gate-and-mockup.md +177 -0
- package/templates/skills/id3-design-ui/references/step4-implementation.md +244 -0
- package/templates/skills/id3-identify-entities/SKILL.md +239 -0
- package/templates/skills/id3-identify-entities/references/.gitkeep +0 -0
- package/templates/skills/id3-identify-entities/references/phase0-brownfield.md +377 -0
- package/templates/skills/id3-identify-entities/references/phase1-greenfield.md +319 -0
- package/templates/skills/id3-info-audit/.gitkeep +0 -0
- package/templates/skills/id3-info-audit/SKILL.md +191 -0
- package/templates/skills/id3-preview/.gitkeep +0 -0
- package/templates/skills/id3-preview/SKILL.md +168 -0
- package/templates/skills/id3-spawn-team/.gitkeep +0 -0
- package/templates/skills/id3-spawn-team/SKILL.md +213 -0
- package/templates/specs/.gitkeep +0 -0
- package/templates/specs/data-model.md +26 -0
- package/templates/specs/entity-catalog.md +22 -0
- package/templates/specs/ui-design-contract.md +54 -0
- package/templates/specs/ui-inventory.md +24 -0
- package/templates/specs/ui-structure.md +32 -0
- package/templates/src/.gitkeep +0 -0
- package/templates/steering/.gitkeep +0 -0
- package/templates/steering/data-conventions.md +42 -0
- package/templates/steering/product.md +38 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: id3-identify-entities
|
|
3
|
+
description: >
|
|
4
|
+
Identify domain entities from existing code (brownfield) or through structured
|
|
5
|
+
interview (greenfield). This is the IDDD workflow entry point.
|
|
6
|
+
Trigger: identify entities, information analysis, domain analysis, new project,
|
|
7
|
+
information design, entity identification
|
|
8
|
+
allowed-tools: Read, Glob, Grep, Bash, Write, Edit
|
|
9
|
+
user-invocable: true
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Phase 0/1: Entity Identification
|
|
13
|
+
|
|
14
|
+
You are the lead agent performing IDDD (Information Design-Driven Development) entity identification. This skill is the entry point for the IDDD workflow. It automatically determines whether the project is brownfield (existing code) or greenfield (new project) and routes to the appropriate phase.
|
|
15
|
+
|
|
16
|
+
IDDD starts from "what information exists?" rather than "what features should we build?" The information model is the generative center from which all development artifacts (requirements, API contracts, screen designs, business rules) are derived.
|
|
17
|
+
|
|
18
|
+
## Auto-Detection Logic
|
|
19
|
+
|
|
20
|
+
Before starting, scan the project root for existing database/ORM artifacts.
|
|
21
|
+
|
|
22
|
+
**Check for these files/directories:**
|
|
23
|
+
- `prisma/schema.prisma` or any `*.prisma` file
|
|
24
|
+
- `drizzle/` directory or `drizzle.config.*`
|
|
25
|
+
- `migrations/` directory
|
|
26
|
+
- `**/models.py` (Django)
|
|
27
|
+
- `**/entities/*.ts` or `**/entities/*.java` (TypeORM, JPA)
|
|
28
|
+
- `schema.sql` or `*.sql` migration files
|
|
29
|
+
- `sequelize/` configuration directory
|
|
30
|
+
- Any other ORM/DB schema files
|
|
31
|
+
|
|
32
|
+
**If ANY of the above exist --> Phase 0 (Brownfield Reverse-Extraction)**
|
|
33
|
+
**If NONE exist --> Phase 1 (Greenfield Structured Interview)**
|
|
34
|
+
|
|
35
|
+
Announce the detection result to the user before proceeding: "Detected [brownfield/greenfield] project. Entering Phase [0/1]."
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Phase 0: Brownfield Reverse-Extraction (Summary)
|
|
40
|
+
|
|
41
|
+
Extract the implicit information model from existing code into explicit IDDD artifacts. The goal is to make the invisible visible -- every entity, relationship, and business rule that currently lives only in code becomes a documented, trackable artifact.
|
|
42
|
+
|
|
43
|
+
### 4-Layer Hierarchical Investigation
|
|
44
|
+
|
|
45
|
+
Investigate these information layers in order, from highest confidence to lowest:
|
|
46
|
+
|
|
47
|
+
| Layer | Source | What to Investigate | Confidence |
|
|
48
|
+
|-------|--------|---------------------|------------|
|
|
49
|
+
| L1 | DB Schema | Tables, columns, foreign keys, indexes, constraints | Highest |
|
|
50
|
+
| L2 | ORM/Model definitions | Virtual fields, derived attributes, soft delete, state transitions, lifecycle hooks | High |
|
|
51
|
+
| L3 | API contracts | Endpoints, DTOs, request/response schemas, validation logic, authorization rules | Medium |
|
|
52
|
+
| L4 | Frontend | Routes, pages, components, form fields, data fetching patterns | Reference |
|
|
53
|
+
|
|
54
|
+
**Investigation order matters.** Start with L1 to establish the ground truth, then augment with each subsequent layer. Each layer may reveal information not present in previous layers.
|
|
55
|
+
|
|
56
|
+
### L4 UI Inventory Extraction
|
|
57
|
+
|
|
58
|
+
Layer 4 investigation is not merely a reference check. Systematically capture the current UI structure into `specs/ui-inventory.md`:
|
|
59
|
+
|
|
60
|
+
- **Route/page structure**: Extract from file-based routing (Next.js `app/`, `pages/`), React Router, Vue Router, etc. Capture full page list with URL patterns.
|
|
61
|
+
- **Screen-entity mapping**: Determine which entities each page displays by examining API calls, data fetching hooks, and component props.
|
|
62
|
+
- **UI pattern classification**: Classify each screen as list view, detail view, create/edit form, dashboard/aggregate view, or relationship navigation.
|
|
63
|
+
- **Component-entity relationships**: Map reusable UI components to the entities/attributes they represent.
|
|
64
|
+
- **Form field-attribute mapping**: Map input form fields to their corresponding entity attributes. Note any fields that don't correspond to known attributes.
|
|
65
|
+
|
|
66
|
+
### Discovery Classification
|
|
67
|
+
|
|
68
|
+
After investigating all layers, classify each discovered element:
|
|
69
|
+
|
|
70
|
+
- **Match** -- Consistently represented across all relevant layers --> Confirmed information model skeleton. Record directly in entity-catalog.md with high confidence.
|
|
71
|
+
- **Mismatch** -- Represented differently across layers (e.g., column in DB but never exposed in API, different naming conventions, validation in API but no DB constraint) --> Record in `docs/info-debt.md` with layers involved, what each layer says, and recommended resolution.
|
|
72
|
+
- **Missing** -- Exists only in code logic (if statements, comments, error messages) but not formalized anywhere --> Extract and make explicit as business rules in `docs/business-rules.md`.
|
|
73
|
+
|
|
74
|
+
### Verification Interview
|
|
75
|
+
|
|
76
|
+
After completing reverse-extraction, present the consolidated results to the user:
|
|
77
|
+
1. Entity summary with source layers and confidence levels
|
|
78
|
+
2. Mermaid ERD showing all discovered relationships
|
|
79
|
+
3. Info-debt items requiring resolution guidance
|
|
80
|
+
4. Implicit rules extracted from code logic for confirmation
|
|
81
|
+
|
|
82
|
+
**Key question:** "Does this information model accurately reflect your current codebase? Are there any entities, relationships, or rules that are missing or incorrect?"
|
|
83
|
+
|
|
84
|
+
Incorporate user corrections and additions before finalizing artifacts.
|
|
85
|
+
|
|
86
|
+
**For detailed layer-by-layer investigation procedures, see:** `references/phase0-brownfield.md`
|
|
87
|
+
|
|
88
|
+
### Phase 0 Artifacts
|
|
89
|
+
|
|
90
|
+
Generate these files:
|
|
91
|
+
- `specs/entity-catalog.md` -- Each entity annotated with source (L1: DB schema, L2: ORM only, L3: API only, L4: UI only, or Multiple)
|
|
92
|
+
- `specs/data-model.md` -- Mermaid ERD with all relationships, columns, and types
|
|
93
|
+
- `specs/ui-inventory.md` -- Current UI structure inventory (screen list, screen-entity mapping matrix, UI pattern classification, unmapped entities/screens)
|
|
94
|
+
- `docs/business-rules.md` -- Each rule with enforcement location (DB constraint, ORM hook, API validation, etc.) and source layer
|
|
95
|
+
- `docs/info-debt.md` -- Cross-layer mismatches, missing constraints, unused schema elements, each with severity and recommended resolution
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Phase 1: Greenfield Structured Interview (Summary)
|
|
100
|
+
|
|
101
|
+
Discover the domain's core information through conversation with the user. This phase is NOT parallelized -- the lead agent conducts the interview directly. Domain discovery requires nuanced conversation that cannot be split across agents.
|
|
102
|
+
|
|
103
|
+
### Interview Steps
|
|
104
|
+
|
|
105
|
+
1. **Check existing artifacts**: Read `specs/entity-catalog.md`, `specs/data-model.md`, and `steering/product.md` if they exist. Build on prior work if present.
|
|
106
|
+
|
|
107
|
+
2. **Information identification questions**:
|
|
108
|
+
- "What are the main 'things' (nouns) this system needs to manage?"
|
|
109
|
+
- "For each thing, what information does it contain?"
|
|
110
|
+
- "What does the user ultimately want to see? What screens, reports, or dashboards are most important?" (output image -- outputs first, inputs later)
|
|
111
|
+
|
|
112
|
+
3. **Relationship questions**:
|
|
113
|
+
- "How are these things related to each other?"
|
|
114
|
+
- "Can one [A] have multiple [B]s, or is it one-to-one?"
|
|
115
|
+
- "If [A] is deleted, what should happen to its [B]s?" (CASCADE, SET NULL, RESTRICT)
|
|
116
|
+
- "Must every [B] belong to an [A], or can it exist independently?" (FK nullability)
|
|
117
|
+
|
|
118
|
+
4. **Rule questions**:
|
|
119
|
+
- "Are there rules this information must always follow?" (mandatory constraints)
|
|
120
|
+
- "Does anything have a lifecycle or status flow?" (state transitions)
|
|
121
|
+
- "Are any values calculated from other values?" (derived/computed attributes)
|
|
122
|
+
|
|
123
|
+
5. **Silverston Universal Pattern Checklist** -- Cross-reference discovered entities against these patterns to catch gaps:
|
|
124
|
+
- [ ] Party (person, organization, role)
|
|
125
|
+
- [ ] Product/Service (product, service, catalog)
|
|
126
|
+
- [ ] Order/Transaction (order, transaction, event)
|
|
127
|
+
- [ ] Classification/Category (classification, tag, category)
|
|
128
|
+
- [ ] Status/Lifecycle (status, stage, transition)
|
|
129
|
+
- [ ] Hierarchy (hierarchy, tree, parent-child)
|
|
130
|
+
- [ ] Contact Mechanism (email, phone, address)
|
|
131
|
+
- [ ] Document/Content (document, content, attachment)
|
|
132
|
+
|
|
133
|
+
For any universal pattern that reveals a missing entity, explain the pattern to the user and ask whether to include it. If yes, run through Steps 2-4 for the new entity.
|
|
134
|
+
|
|
135
|
+
### Interview Best Practices
|
|
136
|
+
|
|
137
|
+
- Use the user's own language. Record entities and attributes in terms the user actually uses. Build the ubiquitous language naturally and record it in `docs/domain-glossary.md`.
|
|
138
|
+
- Don't over-engineer. Phase 1 captures the conceptual model. Data types, indexes, and storage decisions come in Phase 2.
|
|
139
|
+
- Capture uncertainty. If the user says "maybe" or "I'm not sure," record it with a note rather than forcing premature decisions.
|
|
140
|
+
- Show progress. After every 3-4 entities, show the current ERD. Visual feedback keeps the conversation grounded.
|
|
141
|
+
|
|
142
|
+
**For detailed interview procedures and artifact format, see:** `references/phase1-greenfield.md`
|
|
143
|
+
|
|
144
|
+
### Phase 1 Artifacts
|
|
145
|
+
|
|
146
|
+
Generate these files:
|
|
147
|
+
- `specs/entity-catalog.md` -- Entity definitions with attributes, relationships, state transitions, and business rule references
|
|
148
|
+
- `specs/data-model.md` -- Mermaid ERD with entity columns and relationship annotations
|
|
149
|
+
- `docs/business-rules.md` -- Discovered business rules numbered BR-001 and up
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Verification Checklist (Both Phases)
|
|
154
|
+
|
|
155
|
+
Before completing either phase, verify ALL of the following:
|
|
156
|
+
- [ ] All core entities identified
|
|
157
|
+
- [ ] Each entity has attributes defined (PK + core attributes minimum)
|
|
158
|
+
- [ ] All relationships and cardinalities specified
|
|
159
|
+
- [ ] Delete rules (CASCADE, SET NULL, RESTRICT) defined for each relationship
|
|
160
|
+
- [ ] Business rules recorded in `docs/business-rules.md`
|
|
161
|
+
- [ ] Output image captured (what the user ultimately wants to see)
|
|
162
|
+
- [ ] Domain terms added to `docs/domain-glossary.md`
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Preview Integration
|
|
167
|
+
|
|
168
|
+
After completing either phase:
|
|
169
|
+
1. Generate ERD preview HTML at `.iddd/preview/erd-phase0.html` (brownfield) or `.iddd/preview/erd-phase1.html` (greenfield) using Mermaid rendering
|
|
170
|
+
2. Start the preview server and display the URL so the user can review the ERD in their browser
|
|
171
|
+
3. Walk the user through the visual ERD for final confirmation before marking the phase complete
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Version Header Update
|
|
176
|
+
|
|
177
|
+
Upon completion, update YAML frontmatter in `specs/entity-catalog.md` and `specs/data-model.md`:
|
|
178
|
+
|
|
179
|
+
```yaml
|
|
180
|
+
---
|
|
181
|
+
version: "0.1"
|
|
182
|
+
last_verified: "YYYY-MM-DD"
|
|
183
|
+
phase: "Phase 0 Complete" # or "Phase 1 Complete"
|
|
184
|
+
entity_count: N
|
|
185
|
+
rule_count: N
|
|
186
|
+
audit_status: "clean"
|
|
187
|
+
---
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Add an initial entry to `docs/model-changelog.md`:
|
|
191
|
+
|
|
192
|
+
```markdown
|
|
193
|
+
## [0.1] -- YYYY-MM-DD
|
|
194
|
+
### Phase 0/1 Complete
|
|
195
|
+
- N entities identified
|
|
196
|
+
- M relationships mapped
|
|
197
|
+
- K business rules recorded
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Entity Catalog Format
|
|
203
|
+
|
|
204
|
+
Each entity in `specs/entity-catalog.md` follows this structure:
|
|
205
|
+
|
|
206
|
+
```markdown
|
|
207
|
+
## Entity: [Name]
|
|
208
|
+
- **Description**: [one sentence]
|
|
209
|
+
- **Source**: [L1: DB Schema | L2: ORM only | Multiple] (brownfield only)
|
|
210
|
+
- **Attributes**:
|
|
211
|
+
| Name | Type | Required | Constraints | Notes |
|
|
212
|
+
|------|------|----------|-------------|-------|
|
|
213
|
+
| id | UUID | Yes | PK | Primary key |
|
|
214
|
+
- **Relationships**:
|
|
215
|
+
| Target | Type | Cardinality | Delete Rule |
|
|
216
|
+
|--------|------|-------------|-------------|
|
|
217
|
+
- **State Transitions**: [if applicable]
|
|
218
|
+
- **Business Rules**: [BR-xxx references]
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Business Rule Format
|
|
222
|
+
|
|
223
|
+
Each rule in `docs/business-rules.md` follows this structure:
|
|
224
|
+
|
|
225
|
+
```markdown
|
|
226
|
+
### BR-001: [Rule Name]
|
|
227
|
+
- **Entity**: [related entity]
|
|
228
|
+
- **Type**: Constraint | Derivation | Transition | Validity
|
|
229
|
+
- **Description**: [rule description]
|
|
230
|
+
- **Enforcement Location**: DB constraint | Application logic | Both
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Completion Message
|
|
236
|
+
|
|
237
|
+
After all artifacts are generated, the verification checklist passes, and version headers are updated, output:
|
|
238
|
+
|
|
239
|
+
"Information model is ready. N entities identified, M relationships mapped, K business rules recorded. Proceed to Phase 2 (information design) with 'design information', or use /id3-spawn-team to compose a downstream Agent Team."
|
|
File without changes
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# Phase 0: Brownfield Reverse-Extraction -- Detailed Procedures
|
|
2
|
+
|
|
3
|
+
This document provides the detailed investigation procedures for Phase 0 (brownfield reverse-extraction). The lead agent follows these steps to extract the implicit information model from an existing codebase.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Phase 0 systematically investigates 4 information layers in order of confidence, from highest (DB schema) to lowest (frontend). Each layer reveals a different facet of the information model. After investigating all layers, discoveries are classified and consolidated into IDDD artifacts.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Layer 1: DB Schema (Highest Confidence)
|
|
14
|
+
|
|
15
|
+
### What to Investigate
|
|
16
|
+
- Tables, columns, data types
|
|
17
|
+
- Primary keys and foreign keys
|
|
18
|
+
- Indexes (unique, composite, partial)
|
|
19
|
+
- Constraints (NOT NULL, DEFAULT, CHECK, UNIQUE)
|
|
20
|
+
|
|
21
|
+
### How to Investigate
|
|
22
|
+
|
|
23
|
+
1. **Locate schema files:**
|
|
24
|
+
- Prisma: `prisma/schema.prisma`
|
|
25
|
+
- Drizzle: `drizzle/**/*.ts`
|
|
26
|
+
- SQL migrations: `migrations/**/*.sql`, `schema.sql`
|
|
27
|
+
- Django: `**/models.py`
|
|
28
|
+
- TypeORM: `**/entities/*.ts`
|
|
29
|
+
- JPA: `**/entities/*.java`
|
|
30
|
+
- Sequelize: `sequelize/` configuration
|
|
31
|
+
|
|
32
|
+
2. **For each table/model found, extract:**
|
|
33
|
+
- Table name and purpose (infer from name and comments)
|
|
34
|
+
- Column list with data types and constraints
|
|
35
|
+
- Primary key strategy (UUID, auto-increment, composite)
|
|
36
|
+
- Foreign key relationships (which table, which column, what rule)
|
|
37
|
+
- Indexes (what they cover, uniqueness)
|
|
38
|
+
|
|
39
|
+
3. **Build initial entity list:**
|
|
40
|
+
- Each table becomes a candidate entity
|
|
41
|
+
- Junction/pivot tables indicate many-to-many relationships
|
|
42
|
+
- Identify tables that are purely technical (migrations, sessions) vs. domain entities
|
|
43
|
+
|
|
44
|
+
### Recording Format
|
|
45
|
+
|
|
46
|
+
For each entity discovered at L1:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
Entity: [TableName]
|
|
50
|
+
Source: L1 (DB Schema)
|
|
51
|
+
Columns: [list with types and constraints]
|
|
52
|
+
PKs: [primary key columns]
|
|
53
|
+
FKs: [foreign key references]
|
|
54
|
+
Indexes: [index definitions]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Layer 2: ORM/Model Definitions (High Confidence)
|
|
60
|
+
|
|
61
|
+
### What to Investigate
|
|
62
|
+
- Virtual/computed fields not in DB schema
|
|
63
|
+
- Derived attributes (getters, computed properties)
|
|
64
|
+
- Soft delete patterns (`deleted_at`, `is_active`)
|
|
65
|
+
- State machine definitions and transitions
|
|
66
|
+
- Model hooks/lifecycle callbacks (beforeCreate, afterUpdate, etc.)
|
|
67
|
+
- Scopes/query helpers that imply business rules
|
|
68
|
+
|
|
69
|
+
### How to Investigate
|
|
70
|
+
|
|
71
|
+
1. **Locate model files:**
|
|
72
|
+
- Same files as L1, but focus on code-level annotations and logic
|
|
73
|
+
- Prisma: `@default`, `@updatedAt`, virtual relations
|
|
74
|
+
- Django: `Meta` class, `@property`, managers, querysets
|
|
75
|
+
- TypeORM: `@BeforeInsert`, `@AfterUpdate`, subscribers
|
|
76
|
+
- Sequelize: hooks, scopes, virtual fields
|
|
77
|
+
|
|
78
|
+
2. **For each model, extract:**
|
|
79
|
+
- Virtual fields and their computation logic
|
|
80
|
+
- Lifecycle hooks and what they enforce
|
|
81
|
+
- Soft delete configuration
|
|
82
|
+
- State transition definitions (enum fields + transition methods)
|
|
83
|
+
- Custom validation methods
|
|
84
|
+
|
|
85
|
+
3. **Compare with L1 findings:**
|
|
86
|
+
- Note any fields that exist in ORM but not in DB (virtual/computed)
|
|
87
|
+
- Note any constraints enforced in ORM but not in DB
|
|
88
|
+
- Record discrepancies as potential info-debt items
|
|
89
|
+
|
|
90
|
+
### Recording Format
|
|
91
|
+
|
|
92
|
+
For each entity augmented at L2:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
Entity: [ModelName]
|
|
96
|
+
L2 Additions:
|
|
97
|
+
Virtual fields: [list]
|
|
98
|
+
Computed properties: [list with formulas]
|
|
99
|
+
Lifecycle hooks: [hook -> action]
|
|
100
|
+
Soft delete: [yes/no, pattern]
|
|
101
|
+
State transitions: [from -> to transitions]
|
|
102
|
+
L1-L2 discrepancies: [list]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Layer 3: API Contracts (Medium Confidence)
|
|
108
|
+
|
|
109
|
+
### What to Investigate
|
|
110
|
+
- Endpoints (REST routes, GraphQL resolvers)
|
|
111
|
+
- DTOs (Data Transfer Objects) / request/response schemas
|
|
112
|
+
- Validation logic at API boundaries
|
|
113
|
+
- Authorization rules tied to entities
|
|
114
|
+
- Aggregation/transformation logic
|
|
115
|
+
|
|
116
|
+
### How to Investigate
|
|
117
|
+
|
|
118
|
+
1. **Locate API definition files:**
|
|
119
|
+
- Express/Fastify: route files, controller files
|
|
120
|
+
- NestJS: `*.controller.ts`, `*.dto.ts`
|
|
121
|
+
- Django REST: `views.py`, `serializers.py`, `urls.py`
|
|
122
|
+
- GraphQL: schema definitions, resolvers
|
|
123
|
+
- OpenAPI/Swagger: `openapi.yaml`, `swagger.json`
|
|
124
|
+
|
|
125
|
+
2. **For each endpoint, extract:**
|
|
126
|
+
- HTTP method + path pattern
|
|
127
|
+
- Which entity/entities it operates on
|
|
128
|
+
- Request body schema (create/update fields)
|
|
129
|
+
- Response schema (what attributes are exposed)
|
|
130
|
+
- Validation rules (required fields, format checks, range limits)
|
|
131
|
+
- Authorization requirements (who can access)
|
|
132
|
+
|
|
133
|
+
3. **Compare with L1/L2 findings:**
|
|
134
|
+
- Fields in API response but not in entity -> possible derived field
|
|
135
|
+
- Fields in entity but not exposed in API -> intentionally hidden or oversight
|
|
136
|
+
- Validation in API but not in DB -> missing constraint
|
|
137
|
+
- Entities with no API endpoints -> potentially unused or internal-only
|
|
138
|
+
|
|
139
|
+
### Recording Format
|
|
140
|
+
|
|
141
|
+
For each entity augmented at L3:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
Entity: [EntityName]
|
|
145
|
+
L3 API Coverage:
|
|
146
|
+
Endpoints: [method + path -> operation]
|
|
147
|
+
Exposed attributes: [list]
|
|
148
|
+
Hidden attributes: [list]
|
|
149
|
+
API-only validations: [list]
|
|
150
|
+
L1/L2-L3 discrepancies: [list]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Layer 4: Frontend (Reference Confidence)
|
|
156
|
+
|
|
157
|
+
### What to Investigate
|
|
158
|
+
- Route/page structure
|
|
159
|
+
- Screen-entity mapping
|
|
160
|
+
- UI pattern classification
|
|
161
|
+
- Component-entity relationships
|
|
162
|
+
- Form field-attribute mapping
|
|
163
|
+
|
|
164
|
+
### How to Investigate
|
|
165
|
+
|
|
166
|
+
1. **Locate frontend structure:**
|
|
167
|
+
- Next.js: `app/` or `pages/` directory
|
|
168
|
+
- React Router: route configuration files
|
|
169
|
+
- Vue Router: `router/index.ts`
|
|
170
|
+
- Angular: routing modules
|
|
171
|
+
- Other: scan for route/page patterns
|
|
172
|
+
|
|
173
|
+
2. **For each page/screen, extract:**
|
|
174
|
+
- URL pattern
|
|
175
|
+
- Related entities (infer from API calls, data fetching, imports)
|
|
176
|
+
- UI pattern classification:
|
|
177
|
+
- **List view**: table, grid, card list
|
|
178
|
+
- **Detail view**: single entity display
|
|
179
|
+
- **Create/Edit form**: entity creation or modification
|
|
180
|
+
- **Dashboard/Aggregate view**: charts, summaries, KPIs
|
|
181
|
+
- **Relationship navigation**: parent-to-child drill-down
|
|
182
|
+
|
|
183
|
+
3. **Build UI inventory:**
|
|
184
|
+
- Screen inventory table (screen name, URL, related entity, UI pattern, notes)
|
|
185
|
+
- Screen-entity mapping matrix (entity vs. list/detail/create/edit availability)
|
|
186
|
+
- Unmapped entities (in DB but no UI)
|
|
187
|
+
- Unmapped screens (UI exists but no clear entity mapping)
|
|
188
|
+
|
|
189
|
+
4. **Map form fields to entity attributes:**
|
|
190
|
+
- For each create/edit form, list input fields
|
|
191
|
+
- Match each field to entity attributes from L1/L2
|
|
192
|
+
- Note any fields that don't correspond to known attributes
|
|
193
|
+
|
|
194
|
+
### Recording Format
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
Screen: [PageName]
|
|
198
|
+
URL: [pattern]
|
|
199
|
+
Related Entities: [list]
|
|
200
|
+
UI Pattern: [classification]
|
|
201
|
+
Form Fields: [field -> entity.attribute mapping]
|
|
202
|
+
L1-L4 discrepancies: [list]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Discovery Classification
|
|
208
|
+
|
|
209
|
+
After investigating all 4 layers, classify every discovered element:
|
|
210
|
+
|
|
211
|
+
### Match (Consistent)
|
|
212
|
+
|
|
213
|
+
Elements represented consistently across all relevant layers. These form the confirmed information model skeleton.
|
|
214
|
+
|
|
215
|
+
**Action:** Record directly in `specs/entity-catalog.md` with high confidence.
|
|
216
|
+
|
|
217
|
+
### Mismatch (Inconsistent)
|
|
218
|
+
|
|
219
|
+
Elements represented differently across layers. Common examples:
|
|
220
|
+
- Column exists in DB but is never used in API or UI
|
|
221
|
+
- API validates a field that has no DB constraint
|
|
222
|
+
- UI shows a field that doesn't exist in the model
|
|
223
|
+
- Different naming across layers (e.g., `user_id` in DB, `userId` in API, `author` in UI)
|
|
224
|
+
- Soft delete in ORM but not enforced in DB
|
|
225
|
+
|
|
226
|
+
**Action:** Record each mismatch in `docs/info-debt.md` with:
|
|
227
|
+
- Layers involved
|
|
228
|
+
- What each layer says
|
|
229
|
+
- Recommended resolution
|
|
230
|
+
- Severity (high/medium/low)
|
|
231
|
+
|
|
232
|
+
### Missing (Implicit)
|
|
233
|
+
|
|
234
|
+
Rules or constraints that exist only in code logic (if statements, comments, error messages) but are not formalized anywhere.
|
|
235
|
+
|
|
236
|
+
**Action:** Extract and formalize as explicit business rules in `docs/business-rules.md`.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Verification Interview
|
|
241
|
+
|
|
242
|
+
After completing the investigation and classification, present the consolidated results to the user:
|
|
243
|
+
|
|
244
|
+
1. **Entity summary:** List all discovered entities with their source layer and confidence level
|
|
245
|
+
2. **Relationship map:** Show the ERD (Mermaid diagram)
|
|
246
|
+
3. **Info debt items:** Present mismatches and ask for resolution guidance
|
|
247
|
+
4. **Missing rules:** Present extracted implicit rules for confirmation
|
|
248
|
+
5. **Questions:** Ask about anything ambiguous or contradictory
|
|
249
|
+
|
|
250
|
+
**Key question:** "Does this information model accurately reflect your current codebase? Are there any entities, relationships, or rules that are missing or incorrect?"
|
|
251
|
+
|
|
252
|
+
Incorporate user corrections and additions before finalizing artifacts.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Artifact Generation
|
|
257
|
+
|
|
258
|
+
### specs/entity-catalog.md
|
|
259
|
+
|
|
260
|
+
For each entity:
|
|
261
|
+
|
|
262
|
+
```markdown
|
|
263
|
+
## Entity: [Name]
|
|
264
|
+
- **Description**: [one sentence]
|
|
265
|
+
- **Source**: [L1: DB Schema | L2: ORM only | L3: API only | L4: UI only | Multiple]
|
|
266
|
+
- **Attributes**:
|
|
267
|
+
| Name | Type | Required | Constraints | Source | Notes |
|
|
268
|
+
|------|------|----------|-------------|--------|-------|
|
|
269
|
+
| id | UUID | Yes | PK | L1 | |
|
|
270
|
+
| ... | ... | ... | ... | ... | ... |
|
|
271
|
+
- **Relationships**:
|
|
272
|
+
| Target | Type | Cardinality | Delete Rule | Source |
|
|
273
|
+
|--------|------|-------------|-------------|--------|
|
|
274
|
+
| ... | ... | ... | ... | ... |
|
|
275
|
+
- **State Transitions**: [if applicable, from L2]
|
|
276
|
+
- **Business Rules**: [rule numbers, e.g., BR-001, BR-002]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### specs/data-model.md
|
|
280
|
+
|
|
281
|
+
```markdown
|
|
282
|
+
---
|
|
283
|
+
version: "0.1"
|
|
284
|
+
last_verified: "YYYY-MM-DD"
|
|
285
|
+
phase: "Phase 0 Complete"
|
|
286
|
+
entity_count: N
|
|
287
|
+
rule_count: N
|
|
288
|
+
audit_status: "clean"
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
# Data Model
|
|
292
|
+
|
|
293
|
+
## ER Diagram
|
|
294
|
+
|
|
295
|
+
\`\`\`mermaid
|
|
296
|
+
erDiagram
|
|
297
|
+
ENTITY_A ||--o{ ENTITY_B : "relationship description"
|
|
298
|
+
...
|
|
299
|
+
\`\`\`
|
|
300
|
+
|
|
301
|
+
## Index Strategy
|
|
302
|
+
|
|
303
|
+
[Entity-by-entity index design extracted from L1]
|
|
304
|
+
|
|
305
|
+
## Design Decision Log
|
|
306
|
+
|
|
307
|
+
| Decision ID | Subject | Choice | Reason | Date |
|
|
308
|
+
|-------------|---------|--------|--------|------|
|
|
309
|
+
| (To be filled in Phase 2) | | | | |
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### specs/ui-inventory.md
|
|
313
|
+
|
|
314
|
+
```markdown
|
|
315
|
+
## Screen Inventory
|
|
316
|
+
|
|
317
|
+
| Screen | URL Pattern | Related Entities | UI Pattern | Notes |
|
|
318
|
+
|--------|-------------|-----------------|------------|-------|
|
|
319
|
+
| ... | ... | ... | ... | ... |
|
|
320
|
+
|
|
321
|
+
## Screen-Entity Mapping Matrix
|
|
322
|
+
|
|
323
|
+
| Entity | List View | Detail View | Create Form | Edit Form | Notes |
|
|
324
|
+
|--------|-----------|-------------|-------------|-----------|-------|
|
|
325
|
+
| ... | ... | ... | ... | ... | ... |
|
|
326
|
+
|
|
327
|
+
## Unmapped Entities (No UI)
|
|
328
|
+
- [Entities that exist in DB but have no corresponding UI]
|
|
329
|
+
|
|
330
|
+
## Unmapped Screens (No Entity)
|
|
331
|
+
- [Screens that don't clearly map to any entity in the catalog]
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### docs/business-rules.md
|
|
335
|
+
|
|
336
|
+
```markdown
|
|
337
|
+
### BR-001: [Rule Name]
|
|
338
|
+
- **Entity**: [related entity]
|
|
339
|
+
- **Type**: Constraint | Derivation | Transition | Validity
|
|
340
|
+
- **Description**: [rule description]
|
|
341
|
+
- **Enforcement Location**: DB constraint | Application logic | Both
|
|
342
|
+
- **Implementation**: [specific implementation approach]
|
|
343
|
+
- **Source**: [L1/L2/L3/L4, or implicit from code logic]
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### docs/info-debt.md
|
|
347
|
+
|
|
348
|
+
```markdown
|
|
349
|
+
## Info Debt Item: [ID]
|
|
350
|
+
- **Layers Involved**: [e.g., L1 vs. L3]
|
|
351
|
+
- **Description**: [what the mismatch is]
|
|
352
|
+
- **L1 says**: [...]
|
|
353
|
+
- **L3 says**: [...]
|
|
354
|
+
- **Severity**: High | Medium | Low
|
|
355
|
+
- **Recommended Resolution**: [suggestion]
|
|
356
|
+
- **Status**: Open | Resolved
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## Preview Integration
|
|
362
|
+
|
|
363
|
+
After artifact generation:
|
|
364
|
+
|
|
365
|
+
1. Generate an ERD preview from `specs/data-model.md` Mermaid content
|
|
366
|
+
2. Write it to `.iddd/preview/erd-phase0.html`
|
|
367
|
+
3. Start the preview server and display the URL
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Completion
|
|
372
|
+
|
|
373
|
+
Update version headers in `specs/entity-catalog.md` and `specs/data-model.md` (version: "0.1", phase: "Phase 0 Complete").
|
|
374
|
+
|
|
375
|
+
Add an entry to `docs/model-changelog.md`.
|
|
376
|
+
|
|
377
|
+
Output the completion message with entity count, relationship count, and business rule count.
|