fastapi-model-creation

Create SQLModel-based database models with standardized naming and inheritance for FastAPI projects.

Updated Jan 2, 2026
One-click install
npx skills add https://github.com/tanaka-mambinge/dotfiles --skill fastapi-model-creation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi-model-creation
Source: https://github.com/tanaka-mambinge/dotfiles/tree/main/ai-configs/skills/fastapi-model-creation
Command: npx skills add https://github.com/tanaka-mambinge/dotfiles --skill fastapi-model-creation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a standardized blueprint for creating SQLModel-based database models in FastAPI projects, ensuring consistent structure, naming, and inheritance across models and reducing onboarding time for new developers.

Core Features & Use Cases

  • Base Model Features: All models inherit from BaseModelMixin, include id, created_at, updated_at automatically.
  • File Structure & Registration: Models live under ./models/ with explicit tablename and export in ./models/init.py.
  • Conventions: Explicit table naming, nullable/required fields, indexing, uniqueness, and foreign keys.
  • Use Case: When starting a new FastAPI project or modifying existing models, apply this standard to ensure consistency and type safety.

Quick Start

Create a new model file under ./models/ following the naming and inheritance guidelines, and export it in ./models/init.py.

Frequently Asked Questions about fastapi-model-creation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize SQLModel database models across FastAPI projects?

Standardize SQLModel database models by enforcing uniform class patterns, explicit table naming, BaseModelMixin inheritance, and clean foreign key definitions across FastAPI services. This ensures consistent structure, naming, and type safety, reducing onboarding time for new developers.

What is the best way to structure FastAPI database models with SQLModel for type safety?

Structure FastAPI database models by placing files under ./models/ with explicit __tablename__ declarations and exporting them in ./models/__init__.py. All models should inherit from BaseModelMixin to automatically include id, created_at, and updated_at fields for consistent type safety.

Can I use BaseModelMixin to add automatic timestamps to SQLModel tables?

Yes, BaseModelMixin can be used to add automatic timestamps to SQLModel tables. Inheriting from BaseModelMixin ensures all FastAPI database models automatically include id, created_at, and updated_at fields without requiring manual field definitions in each model class.

How do I define foreign keys and field constraints in SQLModel for FastAPI?

Define foreign keys and field constraints in SQLModel by following explicit conventions for nullable and required fields, indexing, uniqueness, and clean foreign key definitions. Applying these standards ensures type safety and consistent database model behavior across FastAPI applications.

When do I need explicit table names for SQLModel models in FastAPI?

Explicit table names are needed when creating or modifying SQLModel models across FastAPI services to enforce uniform class patterns and table naming. Declaring __tablename__ explicitly prevents ambiguous database mapping and maintains consistency across multiple models.