sqlmodel-crud
Use when creating SQLModel database models, CRUD operations, queries with joins, or relationships. NOT when non-database operations, plain SQL, or unrelated data handling. Triggers: "SQLModel", "database model", "CRUD", "create/read/update/delete", "query", "ForeignKey", "relationship".
What this skill does
# SQLModel CRUD Skill
## Overview
Expert guidance for SQLModel database models and CRUD operations, including Pydantic integration, async session management, query building with joins, and relationship configuration for ERP entities like Student, Fee, and Attendance.
## When This Skill Applies
This skill triggers when users request:
- **Models**: "Student model", "SQLModel", "database model", "table=True"
- **CRUD Operations**: "Create student", "Read fees", "Update attendance", "Delete record"
- **Query Building**: "Query with join", "select statement", "where clause", "pagination"
- **Relationships**: "ForeignKey", "back_populates", "relationship", "linked models"
- **Validation**: "Pydantic validators", "field constraints", "indexes"
## Core Rules
### 1. Models: table=True with Pydantic Validation
```python
# models/student.py
from sqlmodel import SQLModel, Field, Relationship
from datetime import datetime
from typing import Optional, List
from enum import Enum
class StudentRole(str, Enum):
STUDENT = "student"
TEACHER = "teacher"
ADMIN = "admin"
class Student(SQLModel, table=True):
"""Student model with relationships to fees and attendance"""
id: Optional[str] = Field(default=None, primary_key=True)
name: str = Field(min_length=2, max_length=100, index=True)
email: str = Field(unique=True, index=True)
phone: Optional[str] = Field(default=None, pattern=r'^\+?[\d\s-]+$')
password_hash: str
role: StudentRole = Field(default=StudentRole.STUDENT)
class_id: Optional[str] = Field(default=None, foreign_key="class.id", index=True)
created_at: datetime = Field(default_factory=datetime.utcnow)
updated_at: datetime = Field(default_factory=datetime.utcnow)
# Relationships
class_obj: Optional["Class"] = Relationship(back_populates="students")
fees: List["Fee"] = Relationship(back_populates="student")
attendance: List["Attendance"] = Relationship(back_populates="student")
class Config:
from_attributes = True
class Class(SQLModel, table=True):
"""Class model for organizing students"""
id: Optional[str] = Field(default=None, primary_key=True)
name: str = Field(min_length=2, max_length=50)
grade_level: int = Field(ge=1, le=12)
academic_year: str = Field(max_length=9, pattern=r'^\d{4}-\d{4}$')
created_at: datetime = Field(default_factory=datetime.utcnow)
# Relationships
students: List[Student] = Relationship(back_populates="class_obj")
class Fee(SQLModel, table=True):
"""Fee model linked to students"""
id: Optional[str] = Field(default=None, primary_key=True)
student_id: str = Field(foreign_key="student.id", index=True)
amount: float = Field(gt=0)
description: str = Field(max_length=500)
status: str = Field(default="pending", pattern=r'^(pending|paid|overdue|waived)$')
due_date: datetime
paid_date: Optional[datetime] = None
created_at: datetime = Field(default_factory=datetime.utcnow)
updated_at: datetime = Field(default_factory=datetime.utcnow)
# Relationships
student: Optional[Student] = Relationship(back_populates="fees")
class Attendance(SQLModel, table=True):
"""Attendance model linked to students"""
id: Optional[str] = Field(default=None, primary_key=True)
student_id: str = Field(foreign_key="student.id", index=True)
date: datetime = Field(index=True)
status: str = Field(pattern=r'^(present|absent|late|excused)$')
notes: Optional[str] = None
created_at: datetime = Field(default_factory=datetime.utcnow)
# Relationships
student: Optional[Student] = Relationship(back_populates="attendance")
```
**Requirements:**
- Use `table=True` for database tables
- Add `index=True` for frequently queried fields
- Use `unique=True` for email and other unique fields
- Add `foreign_key` for relationships
- Use Pydantic validators (min_length, max_length, pattern, ge, gt)
- Use `Relationship` with `back_populates` for bidirectional links
- Include `created_at` and `updated_at` timestamps
### 2. CRUD Operations: Async Session Management
```python
# crud/student.py
from sqlmodel import select, and_
from sqlalchemy.ext.asyncio import AsyncSession
from typing import List, Optional
from datetime import datetime
from models.student import Student
from schemas.student import StudentCreate, StudentUpdate
class StudentCRUD:
"""CRUD operations for Student model"""
@staticmethod
async def create(db: AsyncSession, student_data: StudentCreate) -> Student:
"""Create a new student"""
student = Student(
name=student_data.name,
email=student_data.email,
phone=student_data.phone,
password_hash=student_data.password_hash,
role=student_data.role,
class_id=student_data.class_id,
)
db.add(student)
await db.commit()
await db.refresh(student)
return student
@staticmethod
async def get_by_id(db: AsyncSession, student_id: str) -> Optional[Student]:
"""Get student by ID"""
result = await db.execute(
select(Student).where(Student.id == student_id)
)
return result.scalar_one_or_none()
@staticmethod
async def get_by_email(db: AsyncSession, email: str) -> Optional[Student]:
"""Get student by email"""
result = await db.execute(
select(Student).where(Student.email == email)
)
return result.scalar_one_or_none()
@staticmethod
async def get_all(
db: AsyncSession,
skip: int = 0,
limit: int = 100,
class_id: Optional[str] = None,
role: Optional[str] = None,
) -> List[Student]:
"""Get all students with pagination and filters"""
query = select(Student)
if class_id:
query = query.where(Student.class_id == class_id)
if role:
query = query.where(Student.role == role)
query = query.offset(skip).limit(limit).order_by(Student.created_at.desc())
result = await db.execute(query)
return result.scalars().all()
@staticmethod
async def update(
db: AsyncSession,
student_id: str,
student_data: StudentUpdate,
) -> Optional[Student]:
"""Update a student"""
student = await StudentCRUD.get_by_id(db, student_id)
if not student:
return None
update_data = student_data.model_dump(exclude_unset=True)
for field, value in update_data.items():
setattr(student, field, value)
student.updated_at = datetime.utcnow()
await db.commit()
await db.refresh(student)
return student
@staticmethod
async def delete(db: AsyncSession, student_id: str) -> bool:
"""Delete a student"""
student = await StudentCRUD.get_by_id(db, student_id)
if not student:
return False
await db.delete(student)
await db.commit()
return True
@staticmethod
async def count(
db: AsyncSession,
class_id: Optional[str] = None,
role: Optional[str] = None,
) -> int:
"""Count students with filters"""
query = select(Student)
if class_id:
query = query.where(Student.class_id == class_id)
if role:
query = query.where(Student.role == role)
result = await db.execute(query)
return len(result.scalars().all())
```
**Requirements:**
- Use `AsyncSession` for async database operations
- Use `select()`, `where()`, `offset()`, `limit()`, `order_by()`
- Return `Optional[T]` for single items, `List[T]` for lists
- Use `scalar_one_or_none()` for single results
- Use `scalars().all()` for list results
- Handle transactions with commit/rollback
- Update `updated_at` timestamp on modifications
### 3. Query Building: Joins, Filters, Pagination
```python
# queries/advanced.py
from sqlmodel import select, and_,Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.