Backend Models Standards logo

Backend Models Standards

Community
Microck
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. 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.

Overview

PublisherMicrock
Repositoryordinary-claude-skills
Skill nameBackend Models Standards
Stars
398
Forks
53
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Microck on GitHub. Read the source before you install it.

Installation

Install the Backend Models Standards AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Microck/ordinary-claude-skills.git /tmp/ordinary-claude-skills
mkdir -p .claude/skills
cp -r /tmp/ordinary-claude-skills/skills_all/backend-models-standards .claude/skills/microck-backend-models-standards
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Backend Models Standards in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Backend Models Standards on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Backend Models Standards is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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:

python
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:

python
# 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

DataTypeAvoid
Email, URLVARCHAR(255)TEXT
Short textVARCHAR(n)TEXT
Long textTEXTVARCHAR
MoneyDECIMAL(10,2)FLOAT
BooleanBOOLEANTINYINT
TimestampsTIMESTAMP/DATETIMEVARCHAR
JSON dataJSON/JSONBTEXT
UUIDsUUIDVARCHAR(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:

python
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:

python
# 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 exist
  • NO ACTION: Database default, usually same as RESTRICT

Choose based on business logic, not convenience.

Validation - Two Layers

Model-level validation (application):

python
@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:

python
deleted_at = Column(DateTime, nullable=True, index=True)

# Query only active records
query = session.query(User).filter(User.deleted_at.is_(None))

Polymorphic associations:

python
# Avoid if possible - complex and hard to maintain
# Prefer separate relationship fields or inheritance

Enums for fixed values:

python
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:

python
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:

python
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_at and updated_at timestamps
  • 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

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Backend Models Standards AI skill do?

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)....

Why use Backend Models Standards on TypingMind?

Because you install it once and use it with any model. Backend Models Standards is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Backend Models Standards in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Microck/ordinary-claude-skills/tree/main/skills_all/backend-models-standards. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Backend Models Standards?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Backend Models Standards?

As many as you like. As long as a model supports skills, you can use Backend Models Standards with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Backend Models Standards AI skill free?

It is published on GitHub by Microck. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇