Imported from AVIDS2/seat-reserver (
api/.claude/skills/generate/SKILL.md). Install upstream withnpx skills add AVIDS2/seat-reserver --skill generate. Copyright stays with the author.
Generate Entities and Properties
Detect the database variant
Before running any command, grep package.json scripts to determine {db}:
generate:resource:all-dbpresent →{db}=all-db(PostgreSQL + MongoDB).generate:resource:relationalpresent (and noall-db) →{db}=relational(PostgreSQL/TypeORM).generate:resource:documentpresent (and noall-db) →{db}=document(MongoDB).
Do not ask the user — whichever generate:resource:* and add:property:to-* scripts remain in package.json are exactly the right ones to run.
Add an entity/schema
Rules:
- Never generate
UserorFileentities — they already exist. You can reference them in relationships. - Entity names must be PascalCase and singular (e.g.,
Post,Category,BlogComment).
Command:
npm run generate:resource:{db} -- --name {EntityName}
{db} comes from the detection section above.
Run sequentially, one entity at a time.
Add a property to an entity/schema
Rules:
- Never add
id,createdAt, orupdatedAt— these are predefined for all entities. - Property names must be camelCase (e.g.,
firstName,isActive).
Property kinds:
primitive— basic types:string,number,boolean,Datereference— relationship to another entitydenormalized— denormalized copy of another entity's data (stored inline instead of referenced)
Relationship rules:
- When creating a property with
referenceType: "oneToMany", do NOT create the correspondingmanyToOnein the referenced entity — the generator creates it automatically. - Do NOT create
oneToManyif thepropertyInReferencecould have many items. Instead, create amanyToOneon the child entity only. - For File relations, use only
oneToOneormanyToMany. propertyInReferenceis only required whenreferenceTypeisoneToMany.
Command:
npm run add:property:to-{db} -- --name {EntityName} --property {propertyName} --kind {kind} --type {type} --referenceType {referenceType} --propertyInReference {propertyInReference} --isAddToDto {isAddToDto} --isOptional {isOptional} --isNullable {isNullable} --shouldAutoLoad {shouldAutoLoad}
Argument rules:
--name(required): Entity name, PascalCase--property(required): Property name, camelCase--kind(required):primitive|reference|denormalized--type(required): For primitive:string|number|boolean|Date. For reference/denormalized: the referenced entity name (e.g.,User,File,Category)--referenceType: Only for reference/denormalized kind. Values:oneToOne|oneToMany|manyToOne|manyToMany--propertyInReference: Only whenreferenceTypeisoneToMany. The property name on the referenced entity.--isAddToDto:true|false— whether the property can be set via HTTP request--isOptional:true|false--isNullable:true|false— only meaningful whenisOptionalistrue--shouldAutoLoad:true(default) |false. Only meaningful forkind=reference.trueemitseager: true(TypeORM) andautopopulate: true(Mongoose).falsestores only the related entity's id (Mongoose:stringfield + ObjectId; TypeORM:eager: false). No effect forprimitive/denormalized.
Omit arguments that don't apply (e.g., omit --referenceType for primitive properties, omit --propertyInReference unless referenceType is oneToMany).
Run sequentially, one property at a time.