| name | generating-orm-code |
| description | Execute use when you need to work with ORM code generation.
This skill provides ORM model and code generation with comprehensive guidance and automation.
Trigger with phrases like "generate ORM models", "create entity classes",
or "scaffold database models".
|
| allowed-tools | Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*), Bash(mongosh:*) |
| version | 1.28.0 |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| license | MIT |
| tags | ["database","orm-code"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
ORM Code Generator
Overview
Generate type-safe ORM model classes, migration files, and repository patterns from existing database schemas or domain specifications. Supports Prisma, TypeORM, Sequelize, SQLAlchemy, Django ORM, and Drizzle ORM.
Prerequisites
- Database connection string or credentials for schema introspection
psql or mysql CLI for querying information_schema
- Target ORM framework already installed in the project (
prisma, typeorm, sqlalchemy, etc.)
- Node.js/Python/Go runtime matching the target ORM
- Existing project structure to place generated models in the correct directory
Instructions
-
Introspect the database schema by querying information_schema.COLUMNS, information_schema.TABLE_CONSTRAINTS, and information_schema.KEY_COLUMN_USAGE to extract all tables, columns, data types, nullable flags, defaults, primary keys, foreign keys, and unique constraints.
-
For PostgreSQL, additionally query pg_catalog.pg_type for custom enum types and pg_catalog.pg_index for index definitions. For MySQL, query information_schema.STATISTICS for index details.
-
Map database column types to ORM field types:
varchar/text -> String / @Column('text')
integer/bigint -> Int / @Column('int')
boolean -> Boolean / @Column('boolean')
timestamp/datetime -> DateTime / @Column('timestamp')
jsonb/json -> Json / @Column('jsonb')
uuid -> String with @default(uuid()) or uuid.uuid4
- Custom enums -> Generate enum type definitions
-
Generate model classes with proper decorators/attributes:
- For Prisma: Generate
schema.prisma with blocks, , , , and directives.