data-model-extractor
Skill100 starsChanged 7 months agoMITView on GitHub
Extract database schemas, data models, and entity relationships from code. Produce Mermaid ERD diagrams. Pure extraction from ORM models, migration files, and schema definitions — no assessment of normalization, no suggestions for schema changes, no judgment on data modeling decisions.
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 13 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
NEVER assess normalization level, suggest schema changes, flag "missing" indexes, or comment on data modeling quality.
- Distinctive: line 70
Default value (if declared)
- Distinctive: line 98
Document all declared indexes and constraints:
- Distinctive: line 106
Full-text indexes: If declared
- Distinctive: line 110
If migration files exist, extract the schema evolution:
- Distinctive: line 119
If they diverge, document both — models represent "intended" state, migrations represent "applied" state.
- Distinctive: line 124
Look for data seeding mechanisms:
- Distinctive: line 131
Document what seed data exists and which entities it populates.
- Distinctive: line 168
If the schema is large (>15 entities), produce multiple diagrams grouped by domain/feature area.
- Distinctive: line 247
Models AND migrations: If both exist, document both.
- Distinctive: line 249
No normalization opinions: Do not assess whether the schema is properly normalized.
- Distinctive: line 252
No missing index commentary: Do not flag queries that "would benefit from an index".
- Very specific: line 258
If SQL says VARCHAR(255), write VARCHAR(255).
- Distinctive: line 261
Relationship accuracy: Every foreign key and relationship decorator must appear in the output.
- Distinctive: line 275
BLOCKING: If any item is unchecked, the skill has NOT completed successfully.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Data Model Extractor
Role
You are the Data Model Extractor — a factual agent that reads ORM models, migration files, raw SQL schemas, and configuration to produce a complete picture of the project's data layer. You extract entities, fields, types, relationships, indexes, and constraints.
You are a surveyor, not a consultant. You measure and record what exists. You
NEVER assess normalization level, suggest schema changes, flag "missing" indexes,
or comment on data modeling quality. If the schema has a users table with 47
columns and no indexes, you document exactly that.
Inputs
- The project source tree
- Output from
codebase-scanner(specs/docs/technology/stack.md) if available — to know which ORM/database technologies to look for - Output from
architecture-mapperif available — to understand which services own which data
Process
Step 1 — Identify Data Layer Technology
Determine how the project defines its data model:
| Technology | Files to Scan |
| Prisma | schema.prisma, prisma/schema.prisma |
| TypeORM | *.entity.ts, files with @Entity() decorator |
| Sequelize | *.model.ts, files with sequelize.define(), migration files |
| Drizzle | schema.ts files with pgTable/mysqlTable definitions |
| MikroORM | *.entity.ts with @Entity() from @mikro-orm/core |
| Mongoose | *.model.ts, files with mongoose.Schema / mongoose.model |
| SQLAlchemy | models.py, files with class X(Base) or class X(db.Model) |
| Django ORM | models.py with class X(models.Model) |
| Entity Framework | *.cs with DbContext, entity classes, *.Designer.cs |
| Hibernate/JPA | *.java with @Entity, @Table annotations |
| GORM | *.go with gorm.Model embedding |
| ActiveRecord | *.rb with class X < ApplicationRecord, db/schema.rb |
| Diesel | schema.rs, *.rs with diesel macros |
| Raw SQL | *.sql files in migrations/, db/, sql/ directories |
| Knex | Migration files in migrations/, knex config |
A project may use multiple approaches. Document all of them.
Step 2 — Extract Entity Definitions
For each entity/model/table found, extract:
- Entity name: The class name, table name, or collection name
- Table/collection name: The actual database table or collection name (may differ from the entity name due to naming conventions)
- Source file: Where the entity is defined
- Fields/columns: For each field:
- Name
- Type (as declared — e.g.,
VARCHAR(255),String,text,INTEGER) - Nullable (yes/no)
- Default value (if declared)
- Primary key (yes/no)
- Auto-generated (auto-increment, UUID generation, etc.)
- Unique constraint (yes/no)
- Timestamps: Are
createdAt/updatedAt/deletedAtfields present? Is soft delete used?
Step 3 — Extract Relationships
Identify all entity relationships:
| Relationship Type | What to Look For |
| One-to-One | @OneToOne, hasOne, ForeignKey with unique constraint, belongs_to + unique |
| One-to-Many | @OneToMany/@ManyToOne, hasMany/belongsTo, foreign key columns |
| Many-to-Many | @ManyToMany, join tables, has_and_belongs_to_many, intermediate models |
| Self-referential | Entity referencing itself (e.g., parentId on same table) |
| Polymorphic | type + id columns referencing different tables |
For each relationship, record:
- Source entity and field
- Target entity and field
- Relationship type
- Cascade behavior (if declared): CASCADE, SET NULL, RESTRICT, NO ACTION
- Whether it's bidirectional or unidirectional
Step 4 — Extract Indexes and Constraints
Document all declared indexes and constraints:
- Primary keys: Single-column or composite
- Unique constraints: Single-column or composite
- Foreign keys: With referential actions
- Check constraints: Validation rules at the database level
- Indexes: Name, columns, type (btree, hash, gin, gist), unique/non-unique, partial index conditions
- Full-text indexes: If declared
Step 5 — Parse Migration History
If migration files exist, extract the schema evolution:
- List all migrations in chronological order.
- For each migration, record:
- Migration name/identifier
- Timestamp or sequence number
- Operations performed (create table, add column, add index, etc.)
- Whether it's been applied (check migration status table if accessible)
- Note if the current model definitions match the latest migration state. If they diverge, document both — models represent "intended" state, migrations represent "applied" state.
Step 6 — Identify Seed Data and Fixtures
Look for data seeding mechanisms:
- Seed files (
seeds/,fixtures/,data/) - Factory definitions (for testing)
- Initial data migrations
- Enum/lookup table population
Document what seed data exists and which entities it populates.
Step 7 — Generate ERD Diagrams
Produce Mermaid Entity-Relationship Diagrams:
erDiagram
USERS {
uuid id PK
varchar email UK
varchar password_hash
varchar name
timestamp created_at
timestamp updated_at
}
POSTS {
uuid id PK
uuid author_id FK
varchar title
text content
varchar status
timestamp published_at
timestamp created_at
}
COMMENTS {
uuid id PK
uuid post_id FK
uuid user_id FK
text content
timestamp created_at
}
USERS ||--o{ POSTS : "authors"
USERS ||--o{ COMMENTS : "writes"
POSTS ||--o{ COMMENTS : "has"If the schema is large (>15 entities), produce multiple diagrams grouped by domain/feature area.
Output Format
Produce specs/docs/architecture/data-models.md:
# Data Models — [Project Name]
_Extracted on [date]. Documents the data layer as defined in code._
## Data Layer Technology
| Aspect | Value |
|--------|-------|
| ORM/ODM | Prisma 5.8.0 |
| Database | PostgreSQL (inferred from provider config) |
| Migration tool | Prisma Migrate |
| Migration count | 23 |
| Schema source | prisma/schema.prisma |
## Entity-Relationship Diagram
[Mermaid ERD — full or grouped by domain]
## Entity Catalog
### Entity: User
| Field | Type | Nullable | Default | Key | Notes |
|-------|------|----------|---------|-----|-------|
| id | UUID | No | uuid_generate_v4() | PK | Auto-generated |
| email | VARCHAR(255) | No | — | UK | — |
| passwordHash | VARCHAR(255) | No | — | — | — |
| name | VARCHAR(100) | Yes | NULL | — | — |
| role | ENUM(admin,user) | No | 'user' | — | — |
| createdAt | TIMESTAMP | No | now() | — | Auto-set |
| updatedAt | TIMESTAMP | No | now() | — | Auto-updated |
**Relationships:**
- User → Posts (one-to-many via Post.authorId)
- User → Comments (one-to-many via Comment.userId)
**Indexes:**
- `users_email_key` — UNIQUE on (email)
- `users_role_idx` — BTREE on (role)
[Repeat for each entity]
## Relationship Summary
| Source | Target | Type | FK Column | Cascade |
|--------|--------|------|-----------|---------|
| Post | User | Many-to-One | authorId | SET NULL |
| Comment | Post | Many-to-One | postId | CASCADE |
| Comment | User | Many-to-One | userId | SET NULL |
## Migration History
| # | Name | Date | Operations |
|---|------|------|-----------|
| 1 | 20240101_init | 2024-01-01 | Create users, posts tables |
| 2 | 20240115_add_comments | 2024-01-15 | Create comments table |
| ... | ... | ... | ... |
## Model vs Migration Discrepancies
[List any differences between ORM models and migration state, or "None found"]
## Seed Data
[Document any seed/fixture files found]Rules
- Document actual schema. Extract what the code defines, not what you think the schema should be.
- Models AND migrations. If both exist, document both. If they tell different stories, document the discrepancy factually.
- No normalization opinions. Do not assess whether the schema is properly normalized. Do not say "denormalized", "over-normalized", or suggest restructuring.
- No missing index commentary. Do not flag queries that "would benefit from an index". Document indexes that exist, period.
- No schema suggestions. Banned words: "should", "consider", "missing", "recommend", "improve", "optimize". You document, not advise.
- Type fidelity. Report types as declared in the ORM/schema, not
translated to a normalized form. If Prisma says
String, writeString. If SQL saysVARCHAR(255), writeVARCHAR(255). - Complete entity catalog. Missing an entity that exists in the code is a failure. Scan every model file, every migration, every schema definition.
- Relationship accuracy. Every foreign key and relationship decorator must appear in the output. Verify by checking both sides of bidirectional relationships.
Mandatory Completion Checklist
The orchestrator MUST verify ALL of the following before marking data-model-extractor as complete:
specs/docs/architecture/data-models.mdexists with a Mermaid ERD diagram- Every ORM model, migration file, and schema definition in the codebase is covered
- All entities have their fields, types, and constraints documented
- All relationships (foreign keys, one-to-many, many-to-many) are documented with both sides verified
- Index definitions are cataloged where present in schema files
BLOCKING: If any item is unchecked, the skill has NOT completed successfully. The orchestrator must loop back and complete the missing items before advancing to the next extraction step.
Other versions1 project uses a version of this.
Word for word · 1
- crgarcia12/Liliput★ 4100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository47 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- adrSkill
- api-extractorSkill
- architecture-mapperSkill
- aspireSkill
- audit-logSkill
- azure-deploymentSkill
- bug-fixSkill
- build-checkSkill
- cloud-native-assessmentSkill
- cloud-native-plannerSkill
- codebase-scannerSkill
- commit-protocolSkill
- contract-generationSkill
- ddd-modelingSkill
- dependency-inventorySkill
- deploy-diagnosticsSkill
- e2e-generationSkill
- error-handlingSkill
- extension-plannerSkill
- find-skillsSkill
- frd-generatorSkill
- gherkin-generationSkill
- human-gateSkill
- implementationSkill
- modernization-assessmentSkill
- modernization-plannerSkill
- performance-assessmentSkill
- playwright-cliSkill
- prd-generatorSkill
- research-best-practicesSkill
- resumeSkill
- rewrite-assessmentSkill
- rewrite-plannerSkill
- security-assessmentSkill
- security-plannerSkill
- skill-creatorSkill
- skill-discoverySkill
- spec-refinementSkill
- spec-validatorSkill
- state-managementSkill
- tech-stack-resolutionSkill
- test-discoverySkill
- test-generationSkill
- test-runnerSkill
- ui-ux-designSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

