AgentSkillsCN

Backend Models

定义数据库模型和 ORM 类,遵循框架约定,使用正确的数据类型、关系、约束和验证逻辑。在处理模型定义、模式类、实体文件,或 models.py、entities.ts、schema.prisma、models/ 等文件中的数据库表表示时使用此技能。适用于定义表结构、关系(一对多、多对多)、验证规则、时间戳、索引、外键和数据库级别的数据完整性约束。

SKILL.md
--- frontmatter
name: Backend Models
description: Define database models and ORM classes with proper data types, relationships, constraints, and validation logic following framework conventions. Use this skill when working with model definitions, schema classes, entity files, or database table representations in files like models.py, entities.ts, schema.prisma, or models/. Applies when defining table structures, relationships (one-to-many, many-to-many), validation rules, timestamps, indexes, foreign keys, and data integrity constraints at the database level.

Backend Models

When to use this skill

  • When creating or modifying model files like models.py, models.ts, entities.ts, models/User.js, or schema.prisma
  • When working in model directories such as models/, entities/, orm/, or database/
  • When defining database table structures with columns, data types, and constraints
  • When establishing relationships between models (one-to-many, many-to-many, belongs-to, has-many)
  • When adding timestamps (created_at, updated_at) to models for auditing purposes
  • When implementing model-level validation rules before database operations
  • When creating or modifying foreign key relationships and cascade behaviors
  • When defining database constraints like NOT NULL, UNIQUE, CHECK constraints, or default values
  • When choosing appropriate data types (INTEGER, VARCHAR, TEXT, TIMESTAMP, ENUM, etc.) for columns
  • When adding indexes to foreign keys or frequently queried fields for performance optimization
  • When working with ORM classes in Django, SQLAlchemy, TypeORM, Prisma, Sequelize, or similar frameworks

Backend Models

This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle backend models.

Instructions

For details, refer to the information provided in this file: backend models