SQLModel Task Models

VerifiedSafe

Defines a type-safe SQLModel schema for a Todo app with User and Task models, including foreign keys, indexes, and timestamps. Optimized for PostgreSQL and compatible with Better Auth. Helps when needing a production-ready database layer with async support.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#sqlmodel#database-schema#todo-app#python#postgresql

Recommended for

Automated summary

This guide defines a robust, type-safe, async-compatible database schema for a Todo app using SQLModel, optimized for PostgreSQL and compatible with Better Auth.

Strengths

  • Clear User and Task model definitions with relationships
  • Strategic indexing for query performance
  • Automatic timestamp management
  • Follows SQLModel best practices for production readiness

Limitations

  • Does not cover database migrations or seeding
  • Models are Todo-specific and may need adaptation
  • Relies on SQLModel and its version compatibility
When to use it

When building a Todo app with SQLModel and PostgreSQL, needing a strong foundation for user-related task CRUD operations.

When not to use it

If using a different ORM (e.g., Django ORM, raw SQLAlchemy) or if the app does not require relational models.

Security analysis

Safe
Quality score88/100

The skill provides declarative guidance and code examples for SQLModel models without any executable commands, destructive operations, or data exfiltration.

No concerns found

How this analysis is made

Examples

Create SQLModel task schema
Define SQLModel models for a Todo app with User and Task tables, ensuring user_id foreign key, indexes on user_id and completed, and automatic timestamps. Compatible with Better Auth.
Add task model to existing project
I have a SQLModel project with User model already defined. Add a Task model with fields: title, description, completed, and a relationship to User. Include created_at and updated_at.
Optimize SQLModel schema for PostgreSQL
Write SQLModel models for a Todo app optimized for PostgreSQL. Use proper indexing, default values, and datetime.utcnow. Ensure compatibility with Better Auth user IDs as strings.

name: sqlmodel-task-models description: This skill should be used when defining a robust, type-safe, and async-compatible database schema for the Todo application using SQLModel, ensuring compatibility with Better Auth and optimized for PostgreSQL.

SQLModel Task Models

This skill providing guidance on defining a robust database schema using SQLModel for the Todo application.

Purpose

Defining a robust, type-safe, and async-compatible database schema for the Todo application using SQLModel, ensuring compatibility with Better Auth and optimized for PostgreSQL.

Capabilities

  • User Model: Schema aligned with Better Auth requirements.
  • Task Model: Full CRUD capability with relational mapping to Users.
  • Relational Integrity: Proper foreign key constraints and back-references.
  • Performance: Strategic indexing on user_id and completed fields.
  • Safety: Automated timestamp management (created_at, updated_at).

Implementation Details

Models Definition

from sqlmodel import SQLModel, Field, Relationship
from typing import List, Optional
from datetime import datetime

class User(SQLModel, table=True):
    id: str = Field(primary_key=True)
    email: str = Field(unique=True, index=True)
    name: Optional[str] = None
    created_at: datetime = Field(default_factory=datetime.utcnow)
    tasks: List["Task"] = Relationship(back_populates="user")

class Task(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    user_id: str = Field(foreign_key="user.id", index=True)
    title: str
    description: Optional[str] = None
    completed: bool = Field(default=False, index=True)
    created_at: datetime = Field(default_factory=datetime.utcnow)
    updated_at: datetime = Field(default_factory=datetime.utcnow)
    user: Optional[User] = Relationship(back_populates="tasks")

Best Practices

  • Using table=True for models that map to database tables.
  • Explicitly defining indexes for fields used in WHERE clauses (e.g., user_id, completed).
  • Using datetime.utcnow for consistent cross-region timestamping.
  • Keeping user_id as a string to match Better Auth's UUID/ID format.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/sqlmodel-task-models-mm5t8aeh/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/sqlmodel-task-models-mm5t8aeh' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/sqlmodel-task-models-mm5t8aeh/download' --output '.skill-downloads/sqlmodel-task-models-mm5t8aeh/SKILL.md.part' && mv '.skill-downloads/sqlmodel-task-models-mm5t8aeh/SKILL.md.part' '.skill-downloads/sqlmodel-task-models-mm5t8aeh/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/sqlmodel-task-models-mm5t8aeh/SKILL.md' && test -s '.skill-downloads/sqlmodel-task-models-mm5t8aeh/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/sqlmodel-task-models' && cp -R '.skill-downloads/sqlmodel-task-models-mm5t8aeh' '.claude/skills/sqlmodel-task-models'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/sqlmodel-task-models-mm5t8aeh'

openskills read 'sqlmodel-task-models-mm5t8aeh'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/sqlmodel-task-models-mm5t8aeh/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills