Help us improve
Share bugs, ideas, or general feedback.
From orm-code-generator
Generates ORM models, migrations, and relations for Prisma, TypeORM, Sequelize, SQLAlchemy, Django ORM, Drizzle from Postgres, MySQL schemas via introspection.
npx claudepluginhub jeremylongshore/claude-code-plugins-plus-skills --plugin orm-code-generatorHow this skill is triggered — by the user, by Claude, or both
Slash command
/orm-code-generator:generating-orm-codeThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
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.
Guides schema design, migration safety, and ORM analysis. Detects database engine and ORM, evaluates normalization and indexing, and validates backward compatibility.
Teaches SQL basics, database types (PostgreSQL, SQLite, MongoDB), ORMs like Prisma, schemas, migrations, and relationships for data modeling.
Provides fast reference for Prisma 5+ ORM: schema design, migrations, type-safe CRUD, relations, transactions, error handling, testing, and integrations with Supabase, PlanetScale, Neon for TypeScript/JavaScript database access.
Share bugs, ideas, or general feedback.
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.
psql or mysql CLI for querying information_schemaprisma, typeorm, sqlalchemy, etc.)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.uuid4Generate model classes with proper decorators/attributes:
schema.prisma with model blocks, @id, @unique, @relation, and @default directives.@Entity(), @Column(), @PrimaryGeneratedColumn(), @ManyToOne(), @OneToMany() decorators.Base with Column(), ForeignKey(), relationship(), and __tablename__.pgTable(), serial(), varchar(), timestamp(), and relations().Generate relationship mappings from foreign key constraints. Detect one-to-one (unique FK), one-to-many, and many-to-many (junction table with two FKs) patterns automatically. Add both sides of each relationship with proper cascade options.
Create migration files that capture the current schema state. For Prisma: npx prisma migrate dev --name init. For TypeORM: generate migration with typeorm migration:generate. For Alembic: alembic revision --autogenerate.
Generate repository/service layer with common CRUD operations: findById, findAll with pagination, create, update, delete, and relationship-aware queries (findWithRelations).
Add validation decorators or constraints matching database CHECK constraints and NOT NULL columns. Use class-validator for TypeORM, Pydantic validators for SQLAlchemy, or Zod schemas for Prisma.
Generate TypeScript/Python type definitions or interfaces for API layer consumption, ensuring the ORM models and API types stay synchronized.
Validate generated models by running a test migration against a temporary database or by comparing the generated schema against the live database schema with a diff tool.
| Error | Cause | Solution |
|---|---|---|
| Circular relationship dependency | Two entities reference each other, causing import cycles | Use lazy loading (() => RelatedEntity) in TypeORM; use ForwardRef in SQLAlchemy; split into separate files with deferred imports |
| Unknown column type mapping | Database uses custom types, extensions, or domain types not in the standard mapping | Add custom type mapping in generator config; use @Column({ type: 'text' }) as fallback; register custom transformers |
| Migration conflicts with existing data | Generated migration adds NOT NULL columns without defaults | Add default values to new columns; create a two-phase migration (add nullable, backfill, set NOT NULL) |
| Junction table not detected as many-to-many | Junction table has extra columns beyond the two foreign keys | Model as an explicit entity with two ManyToOne relationships instead of an implicit ManyToMany |
| Schema drift between ORM models and database | Manual database changes not reflected in ORM code | Run introspection again; use prisma db pull or sqlacodegen to regenerate; diff against existing models |
Prisma schema from PostgreSQL e-commerce database: Introspect 15 tables including users, orders, products, and categories. Generate schema.prisma with proper @relation directives, enum types for order status, and @default(autoincrement()) for serial columns. Output includes Zod validation schemas for each model.
TypeORM entities from MySQL SaaS application: Generate entity classes for a multi-tenant application with tenant isolation. Each entity includes a tenantId column with a custom @TenantAware decorator. Repository layer includes tenant-scoped query methods.
SQLAlchemy models from legacy database with naming conventions: Introspect a database with inconsistent naming (mix of camelCase and snake_case). Generate models with __tablename__ preserving original names while using Pythonic property names. Alembic migration captures the full schema.