Backend Models Standards
Define database models with clear naming, appropriate data types, constraints, relationships, and validation at multiple layers. Use this skill when creating or modifying database model files, ORM classes, schema definitions, or data model relationships.
Install / Use
npx skills add Microck/ordinary-claude-skills --skill backend-models-standardsInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Data & AnalyticsSupported Platforms
Our assessment of Backend Models Standards
Backend Models Standards scores 83/100 on our quality scale, 437th of 592 Data & Analytics skills we index.
Its SKILL.md is 8.0 KB long, well organised into 22 sections with 10 code examples: a thorough specification that gives an agent plenty to work with.
It has 399 GitHub stars, a meaningful sign that others use it.
Maintenance, license and trust
- The repository was last updated 30 days ago, so Backend Models Standards is actively maintained.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 88/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Backend Models Standards compared with similar skills
All 4 of these similar skills score higher than Backend Models Standards; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| Backend Models Standards (this skill)by Microck | 83 | 399 | 30d ago | SKILL.md |
| algorithmic-artby anthropics | 100 | 177.9k | 14d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 14d ago | SKILL.md |
| designby nextlevelbuilder | 100 | 130.2k | 15d ago | SKILL.md |
| ui-ux-pro-maxby nextlevelbuilder | 100 | 130.2k | 15d ago | SKILL.md |
Frequently asked questions
- How do I install Backend Models Standards?
- Run
npx skills add Microck/ordinary-claude-skills --skill "Backend Models Standards". The install tabs above show the steps for each supported agent. - Which AI agents does Backend Models Standards work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is Backend Models Standards safe to use?
- It declares no license and scores 88/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is Backend Models Standards still maintained?
- The repository was last updated 30 days ago, so Backend Models Standards is actively maintained.
Skill content
View source on GitHubname: Backend Models Standards description: Define database models with clear naming, appropriate data types, constraints, relationships, and validation at multiple layers. Use this skill when creating or modifying database model files, ORM classes, schema definitions, or data model relationships. Apply when working with model files (e.g., models.py, models/, ActiveRecord classes, Prisma schema, Sequelize models), defining table structures, setting up foreign keys and relationships, configuring cascade behaviors, implementing model validations, adding timestamps, or working with database constraints (NOT NULL, UNIQUE, foreign keys). Use for any task involving data integrity enforcement, relationship definitions, or model-level data validation.
Backend Models Standards
Core Rule: Models define data structure and integrity. Keep them focused on data representation, not business logic.
When to use this skill
- When creating or modifying database model files (models.py, models/, schema.prisma, etc.)
- When defining ORM classes or ActiveRecord models for database tables
- When establishing table relationships (one-to-many, many-to-many, has-many, belongs-to)
- When configuring foreign keys, indexes, and cascade behaviors
- When implementing model-level validation rules
- When adding timestamp fields (created_at, updated_at) for auditing
- When setting database constraints (NOT NULL, UNIQUE, CHECK constraints)
- When choosing appropriate data types for model fields
- When balancing normalization with query performance needs
- When defining model methods or scopes for common queries
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.
Naming Conventions
Models: Singular, PascalCase (User, OrderItem, PaymentMethod)
Tables: Plural, snake_case (users, order_items, payment_methods)
Relationships: Descriptive and clear
user.orders(one-to-many)order.items(one-to-many)product.categories(many-to-many)
Avoid generic names: data, info, record, entity
Required Fields
Timestamps on every model:
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
updated_at = Column(DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
Primary keys: Always explicit, prefer UUIDs for distributed systems or auto-incrementing integers for simplicity
Why: Auditing, debugging, data lineage tracking, soft deletes
Data Integrity - Database Level
Use constraints, not just application validation:
# NOT NULL for required fields
email = Column(String(255), nullable=False)
# UNIQUE constraints
email = Column(String(255), unique=True, nullable=False)
# CHECK constraints for business rules
age = Column(Integer, CheckConstraint('age >= 18'))
# Foreign keys with explicit cascade behavior
user_id = Column(Integer, ForeignKey('users.id', ondelete='CASCADE'))
Why: Database enforces rules even if application code bypassed. Defense in depth.
Data Types - Choose Appropriately
| Data | Type | Avoid | | ---------- | ------------------ | ----------- | | Email, URL | VARCHAR(255) | TEXT | | Short text | VARCHAR(n) | TEXT | | Long text | TEXT | VARCHAR | | Money | DECIMAL(10,2) | FLOAT | | Boolean | BOOLEAN | TINYINT | | Timestamps | TIMESTAMP/DATETIME | VARCHAR | | JSON data | JSON/JSONB | TEXT | | UUIDs | UUID | VARCHAR(36) |
Why: Correct types enable database optimizations, constraints, and prevent data corruption.
Indexes - Performance Critical
Always index:
- Primary keys (automatic)
- Foreign keys (manual in most ORMs)
- Columns in WHERE clauses
- Columns in JOIN conditions
- Columns in ORDER BY clauses
Example:
class Order(Base):
__tablename__ = 'orders'
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey('users.id'), index=True)
status = Column(String(50), index=True) # Frequently filtered
created_at = Column(DateTime, index=True) # Frequently sorted
Don't over-index: Each index slows writes. Index only queried columns.
Relationships - Explicit Configuration
Define both sides of relationships:
# One-to-many
class User(Base):
orders = relationship('Order', back_populates='user', cascade='all, delete-orphan')
class Order(Base):
user_id = Column(Integer, ForeignKey('users.id'))
user = relationship('User', back_populates='orders')
Cascade behaviors:
CASCADE: Delete related records (user deleted → orders deleted)SET NULL: Nullify foreign key (category deleted → product.category_id = NULL)RESTRICT: Prevent deletion if related records existNO ACTION: Database default, usually same as RESTRICT
Choose based on business logic, not convenience.
Validation - Two Layers
Model-level validation (application):
@validates('email')
def validate_email(self, key, email):
if not re.match(r'^[^@]+@[^@]+\.[^@]+$', email):
raise ValueError('Invalid email format')
return email
Database-level constraints (see Data Integrity section)
Why both: Model validation provides clear error messages. Database constraints prevent data corruption if application bypassed.
What Belongs in Models
YES:
- Field definitions and types
- Relationships to other models
- Simple property methods (
@property def full_name) - Data validation rules
- Database constraints
NO:
- Business logic (move to service layer)
- External API calls
- Complex calculations (move to service methods)
- Email sending, file uploads, etc.
Models represent data structure, not behavior.
Normalization vs Performance
Normalize when:
- Data has clear entity boundaries
- Updates need to propagate (user email changes once)
- Avoiding data duplication is critical
Denormalize when:
- Read performance critical (analytics, reporting)
- Data rarely changes (historical snapshots)
- Joins become too expensive
Default to normalized. Denormalize only with evidence of performance issues.
Common Patterns
Soft deletes:
deleted_at = Column(DateTime, nullable=True, index=True)
# Query only active records
query = session.query(User).filter(User.deleted_at.is_(None))
Polymorphic associations:
# Avoid if possible - complex and hard to maintain
# Prefer separate relationship fields or inheritance
Enums for fixed values:
from enum import Enum
class OrderStatus(str, Enum):
PENDING = 'pending'
PAID = 'paid'
SHIPPED = 'shipped'
DELIVERED = 'delivered'
status = Column(Enum(OrderStatus), nullable=False, default=OrderStatus.PENDING)
Testing Models
Test constraints and validation:
def test_user_email_required():
with pytest.raises(IntegrityError):
user = User(name='Test')
session.add(user)
session.commit()
def test_user_email_unique():
user1 = User(email='test@example.com')
user2 = User(email='test@example.com')
session.add(user1)
session.commit()
with pytest.raises(IntegrityError):
session.add(user2)
session.commit()
Test relationships:
def test_user_orders_cascade_delete():
user = User(email='test@example.com')
order = Order(user=user)
session.add(user)
session.commit()
session.delete(user)
session.commit()
assert session.query(Order).count() == 0
Checklist for New Models
- [ ] Singular model name, plural table name
- [ ] Primary key defined
- [ ]
created_atandupdated_attimestamps - [ ] NOT NULL on required fields
- [ ] UNIQUE constraints where appropriate
- [ ] Foreign keys with explicit cascade behavior
- [ ] Indexes on foreign keys and queried columns
- [ ] Appropriate data types (not all VARCHAR)
- [ ] Validation at model and database levels
- [ ] Relationships defined on both sides
- [ ] Tests for constraints and validation
Related Skills
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em…
design
130.2kComprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini, Atlas Cloud, or MuAPI AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social/ads/web/print), icon design (15 styles, SVG…
ui-ux-pro-max
130.2kUI/UX design intelligence for web, mobile, and desktop. This skill should be used when designing, building, reviewing, or fixing interfaces, including pages, components, design systems, accessibility, interaction, responsive layout, typography, color, charts, and stack-specific UI implementation.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
