[IMPORTANT] Use TaskCreate to break ALL work into small tasks BEFORE starting — including tasks for each file read. This prevents context loss from long files. For simple tasks, AI MUST ask user whether to skip.
Prerequisites: MUST READ before executing:
.claude/skills/shared/scan-and-update-reference-doc-protocol.md
.claude/skills/shared/understand-code-first-protocol.md
Quick Summary
Goal: Scan project codebase and populate docs/project-reference/domain-entities-reference.md with domain entities, data models, DTOs, aggregate boundaries, cross-service entity sync maps, and Mermaid ER diagrams.
Workflow:
- Read — Load current target doc, detect init vs sync mode
- Scan — Discover entities, models, DTOs, relationships via parallel sub-agents
- Report — Write findings to external report file
- Generate — Build/update reference doc from report
- Verify — Validate entity references point to real files
Key Rules:
- Generic — works with any framework (.NET, Node.js, Java, Python, game engines, etc.)
- Detect framework first, then scan for framework-specific entity patterns
- For microservices: unify cross-service entities (identify owner vs consumer services)
- Every entity reference must come from actual project files with file:line references
- Detail level: summary + key properties (IDs, FKs, status fields, relationships) — NOT full property listing
Be skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence percentages (Idea should be more than 80%).
Scan Domain Entities
Phase 0: Read & Assess
- Read
docs/project-reference/domain-entities-reference.md
- Detect mode: init (placeholder) or sync (populated)
- If sync: extract existing sections and note what's already documented
Phase 1: Plan Scan Strategy
Detect Project Type & Framework
Scan for project type indicators in this priority order:
- Check
docs/project-config.json — Use modules[] for service paths, project.languages for tech stack
- Filesystem detection fallback:
| Indicator |
Framework |
Entity Patterns to Search |
.csproj |
.NET |
Entity, AggregateRoot, ValueObject, IEntity, BaseEntity, project entity base |
package.json + ORM |
Node.js |
Mongoose Schema, TypeORM @Entity, Prisma model, Sequelize define |
pom.xml / build.gradle |
Java/Kotlin |
JPA @Entity, Spring Data, Hibernate, @Table |
requirements.txt / pyproject.toml |
Python |
Django models.Model, SQLAlchemy, Pydantic BaseModel |
*.proto |
Protobuf |
message definitions (cross-service contracts) |
| Unity project files |
Unity |
ScriptableObject, MonoBehaviour data classes |
| Unreal project files |
Unreal |
UObject, USTRUCT, UCLASS data types |
- Generic fallback (any project): scan for
class.*Entity, class.*Model, class.*Dto, interface.*Repository, schema, @table, collection
Detect Architecture Type
- Microservices: Multiple service directories with separate domain layers → enable cross-service entity sync analysis
- Monolith: Single domain layer → skip cross-service analysis
- Modular monolith: Single deployment but bounded contexts → analyze module boundaries
Use docs/project-config.json modules[] to identify service boundaries. If unavailable, detect from directory structure.
Phase 2: Execute Scan (Parallel Sub-Agents)
Launch 3-4 Explore agents in parallel:
Agent 1: Domain Entities & Aggregates
- Grep for entity base class inheritance (framework-specific patterns from Phase 1)
- Find aggregate root classes
- Find value objects
- Find enum types used as entity properties
- For each entity: note key properties (ID, foreign keys, status/state fields, timestamps)
- Note file paths with line numbers
Agent 2: DTOs, ViewModels & Application Layer Models
- Grep for DTO classes (
*Dto, *DTO, *ViewModel, *Response, *Request)
- Find command/query objects that carry entity data
- Identify DTO-to-Entity mapping patterns (who owns mapping, method names)
- Note which DTOs map to which entities
Agent 3: Database Schemas & Persistence
- Find database collection/table definitions
- Find migration files that create/alter entity tables
- Find index definitions on entities
- Find seed data files
- Identify database technology per service (MongoDB, SQL Server, PostgreSQL, etc.)
Agent 4: Cross-Service Entity Sync (microservices only)
- Grep for integration event classes (
*IntegrationEvent, *Event, *Message)
- Find message bus consumers that sync entity data across services
- Identify shared contracts/DTOs between services
- Map: which entity originates in which service, which services consume it
- Find event handler classes that create/update projected entities
Write all findings to: plans/reports/scan-domain-entities-{YYMMDD}-{HHMM}-report.md
Phase 3: Analyze & Generate
Read the report. Build these sections:
Target Sections
| Section |
Content |
| Entity Catalog |
Table per service/module: entity name, key properties (IDs, FKs, status), base class, file path |
| Entity Relationships |
Mermaid ER diagram per service showing entity relationships (1:N, N:M, 1:1) |
| Cross-Service Entity Map |
Table: entity name, owner service, consumer services, sync mechanism (event name), sync direction |
| DTO Mapping |
Table: DTO class → Entity class, mapping approach (manual/auto), file path |
| Aggregate Boundaries |
Which entities form aggregates, aggregate root identification |
| Naming Conventions |
Detected naming patterns (suffixes, prefixes, namespace conventions) |
Entity Catalog Format
For each service/module, produce a table:
### {ServiceName} Entities
| Entity | Key Properties | Base Class | Relationships | File |
| -------- | ----------------------------- | ---------- | ---------------------- | ---------------------- |
| Employee | Id, CompanyId, UserId, Status | EntityBase | 1:N Goals, 1:N Reviews | `path/Employee.cs:L15` |
Detail level: Summary + key properties only. Include: IDs, foreign keys, status/state fields, important business fields. Do NOT list every property.
Cross-Service Entity Map Format (microservices)
When the same entity concept appears in multiple services:
| Unified Entity | Owner Service | Consumer Services | Sync Event | Direction |
| -------------- | ------------- | ------------------ | -------------------- | ----------------- |
| Employee | ServiceA | ServiceB, Accounts | EmployeeCreatedEvent | Owner → Consumers |
Mermaid ER Diagram Guidelines
- One diagram per service/bounded context (keep diagrams readable)
- One cross-service diagram showing entity sync flows
- Use Mermaid
erDiagram syntax
- Show only key relationships, not every FK
erDiagram
Employee ||--o{ Goal : "has"
Employee ||--o{ Review : "receives"
Goal ||--o{ CheckIn : "tracks"
Content Rules
- Show actual entity class declarations (3-5 lines) with
file:line references
- Include count of entities per service
- Group by service/module, not by entity type
- For microservices: highlight cross-service boundaries clearly
Phase 4: Write & Verify
- Write updated doc with
<!-- Last scanned: YYYY-MM-DD --> at top
- Verify: 5+ entity file paths exist (Glob check)
- Verify: class names in catalog match actual class definitions (Grep check)
- Report: sections updated, entities discovered, coverage gaps
IMPORTANT Task Planning Notes (MUST FOLLOW)
- Always plan and break work into many small todo tasks using TaskCreate
- Always add a final review todo task to verify work quality and identify fixes/enhancements
1---2name: scan-domain-entities3description: [Documentation] Scan project and populate/sync docs/project-reference/domain-entities-reference.md with domain entities, data models, DTOs, aggregate boundaries, cross-service entity sync, and ER diagrams.4---5
6> **[IMPORTANT]** Use `TaskCreate` to break ALL work into small tasks BEFORE starting — including tasks for each file read. This prevents context loss from long files. For simple tasks, AI MUST ask user whether to skip.
7
8**Prerequisites:** **MUST READ** before executing:
9
10- `.claude/skills/shared/scan-and-update-reference-doc-protocol.md`
11- `.claude/skills/shared/understand-code-first-protocol.md`
12
13## Quick Summary
14
15**Goal:** Scan project codebase and populate `docs/project-reference/domain-entities-reference.md` with domain entities, data models, DTOs, aggregate boundaries, cross-service entity sync maps, and Mermaid ER diagrams.
16
17**Workflow:**
18
191. **Read** — Load current target doc, detect init vs sync mode
202. **Scan** — Discover entities, models, DTOs, relationships via parallel sub-agents
213. **Report** — Write findings to external report file
224. **Generate** — Build/update reference doc from report
235. **Verify** — Validate entity references point to real files
24
25**Key Rules:**
26
27- Generic — works with any framework (.NET, Node.js, Java, Python, game engines, etc.)
28- Detect framework first, then scan for framework-specific entity patterns
29- For microservices: unify cross-service entities (identify owner vs consumer services)
30- Every entity reference must come from actual project files with file:line references
31- Detail level: summary + key properties (IDs, FKs, status fields, relationships) — NOT full property listing
32
33**Be skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence percentages (Idea should be more than 80%).**
34
35# Scan Domain Entities
36
37## Phase 0: Read & Assess
38
391. Read `docs/project-reference/domain-entities-reference.md`
402. Detect mode: init (placeholder) or sync (populated)
413. If sync: extract existing sections and note what's already documented
42
43## Phase 1: Plan Scan Strategy
44
45### Detect Project Type & Framework
46
47Scan for project type indicators in this priority order:
48
491. **Check `docs/project-config.json`** — Use `modules[]` for service paths, `project.languages` for tech stack
502. **Filesystem detection fallback:**
51
52| Indicator | Framework | Entity Patterns to Search |
53| ------------------------------------- | ----------- | -------------------------------------------------------------------------------------- |
54| `.csproj` | .NET | `Entity`, `AggregateRoot`, `ValueObject`, `IEntity`, `BaseEntity`, project entity base |
55| `package.json` + ORM | Node.js | Mongoose `Schema`, TypeORM `@Entity`, Prisma `model`, Sequelize `define` |
56| `pom.xml` / `build.gradle` | Java/Kotlin | JPA `@Entity`, Spring Data, Hibernate, `@Table` |
57| `requirements.txt` / `pyproject.toml` | Python | Django `models.Model`, SQLAlchemy, Pydantic `BaseModel` |
58| `*.proto` | Protobuf | `message` definitions (cross-service contracts) |
59| Unity project files | Unity | `ScriptableObject`, `MonoBehaviour` data classes |
60| Unreal project files | Unreal | `UObject`, `USTRUCT`, `UCLASS` data types |
61
623. **Generic fallback** (any project): scan for `class.*Entity`, `class.*Model`, `class.*Dto`, `interface.*Repository`, `schema`, `@table`, `collection`
63
64### Detect Architecture Type
65
66- **Microservices:** Multiple service directories with separate domain layers → enable cross-service entity sync analysis
67- **Monolith:** Single domain layer → skip cross-service analysis
68- **Modular monolith:** Single deployment but bounded contexts → analyze module boundaries
69
70Use `docs/project-config.json` `modules[]` to identify service boundaries. If unavailable, detect from directory structure.
71
72## Phase 2: Execute Scan (Parallel Sub-Agents)
73
74Launch **3-4 Explore agents** in parallel:
75
76### Agent 1: Domain Entities & Aggregates
77
78- Grep for entity base class inheritance (framework-specific patterns from Phase 1)
79- Find aggregate root classes
80- Find value objects
81- Find enum types used as entity properties
82- For each entity: note key properties (ID, foreign keys, status/state fields, timestamps)
83- Note file paths with line numbers
84
85### Agent 2: DTOs, ViewModels & Application Layer Models
86
87- Grep for DTO classes (`*Dto`, `*DTO`, `*ViewModel`, `*Response`, `*Request`)
88- Find command/query objects that carry entity data
89- Identify DTO-to-Entity mapping patterns (who owns mapping, method names)
90- Note which DTOs map to which entities
91
92### Agent 3: Database Schemas & Persistence
93
94- Find database collection/table definitions
95- Find migration files that create/alter entity tables
96- Find index definitions on entities
97- Find seed data files
98- Identify database technology per service (MongoDB, SQL Server, PostgreSQL, etc.)
99
100### Agent 4: Cross-Service Entity Sync (microservices only)
101
102- Grep for integration event classes (`*IntegrationEvent`, `*Event`, `*Message`)
103- Find message bus consumers that sync entity data across services
104- Identify shared contracts/DTOs between services
105- Map: which entity originates in which service, which services consume it
106- Find event handler classes that create/update projected entities
107
108Write all findings to: `plans/reports/scan-domain-entities-{YYMMDD}-{HHMM}-report.md`
109
110## Phase 3: Analyze & Generate
111
112Read the report. Build these sections:
113
114### Target Sections
115
116| Section | Content |
117| ---------------------------- | ------------------------------------------------------------------------------------------------- |
118| **Entity Catalog** | Table per service/module: entity name, key properties (IDs, FKs, status), base class, file path |
119| **Entity Relationships** | Mermaid ER diagram per service showing entity relationships (1:N, N:M, 1:1) |
120| **Cross-Service Entity Map** | Table: entity name, owner service, consumer services, sync mechanism (event name), sync direction |
121| **DTO Mapping** | Table: DTO class → Entity class, mapping approach (manual/auto), file path |
122| **Aggregate Boundaries** | Which entities form aggregates, aggregate root identification |
123| **Naming Conventions** | Detected naming patterns (suffixes, prefixes, namespace conventions) |
124
125### Entity Catalog Format
126
127For each service/module, produce a table:
128
129```markdown
130### {ServiceName} Entities
131
132| Entity | Key Properties | Base Class | Relationships | File |
133| -------- | ----------------------------- | ---------- | ---------------------- | ---------------------- |
134| Employee | Id, CompanyId, UserId, Status | EntityBase | 1:N Goals, 1:N Reviews | `path/Employee.cs:L15` |
135```
136
137**Detail level:** Summary + key properties only. Include: IDs, foreign keys, status/state fields, important business fields. Do NOT list every property.
138
139### Cross-Service Entity Map Format (microservices)
140
141When the same entity concept appears in multiple services:
142
143```markdown
144| Unified Entity | Owner Service | Consumer Services | Sync Event | Direction |
145| -------------- | ------------- | ------------------ | -------------------- | ----------------- |
146| Employee | ServiceA | ServiceB, Accounts | EmployeeCreatedEvent | Owner → Consumers |
147```
148
149### Mermaid ER Diagram Guidelines
150
151- One diagram per service/bounded context (keep diagrams readable)
152- One cross-service diagram showing entity sync flows
153- Use Mermaid `erDiagram` syntax
154- Show only key relationships, not every FK
155
156```mermaid
157erDiagram
158 Employee ||--o{ Goal : "has"
159 Employee ||--o{ Review : "receives"
160 Goal ||--o{ CheckIn : "tracks"
161```
162
163### Content Rules
164
165- Show actual entity class declarations (3-5 lines) with `file:line` references
166- Include count of entities per service
167- Group by service/module, not by entity type
168- For microservices: highlight cross-service boundaries clearly
169
170## Phase 4: Write & Verify
171
1721. Write updated doc with `<!-- Last scanned: YYYY-MM-DD -->` at top
1732. Verify: 5+ entity file paths exist (Glob check)
1743. Verify: class names in catalog match actual class definitions (Grep check)
1754. Report: sections updated, entities discovered, coverage gaps
176
177---
178
179**IMPORTANT Task Planning Notes (MUST FOLLOW)**
180
181- Always plan and break work into many small todo tasks using TaskCreate
182- Always add a final review todo task to verify work quality and identify fixes/enhancements