advanced-alchemy-modeling
SKILL.md
Modeling
Execution Workflow
- Choose a base class around key shape and audit needs:
BigIntBase,BigIntAuditBase,UUIDBase,UUIDv7Base, or related variants. - Add mixins intentionally:
SlugKeyfor URL slugs, audit columns when timestamps are required, andUniqueMixinwhen get-or-create semantics matter. - Model relationships with explicit loading strategy such as
selectinorjoinedinstead of relying on defaults. - Use
UniqueMixinto collapse duplicate creation logic for tags, lookup tables, and many-to-many helper models. - Customize the declarative base only when the built-in bases do not fit an existing schema or database-specific requirement.
Implementation Rules
- Pick one primary-key strategy per bounded context and keep it consistent.
- Let mixins own their concern; do not duplicate slug or audit columns by hand.
- Implement both
unique_hash()andunique_filter()wheneverUniqueMixinis used. - Keep model classes transport-agnostic and leave request or response shaping to services or framework layers.
Example Pattern
from advanced_alchemy.base import BigIntAuditBase
from advanced_alchemy.mixins import SlugKey, UniqueMixin
class Tag(BigIntAuditBase, SlugKey, UniqueMixin):
__tablename__ = "tag"
Validation Checklist
- Confirm the base class matches the database key and migration strategy.
- Confirm relationship loading avoids obvious N+1 behavior in hot paths.
- Confirm
UniqueMixincriteria match actual uniqueness guarantees. - Confirm timestamps, slugs, and indexes align with the expected query patterns.
Cross-Skill Handoffs
- Use
advanced-alchemy-typesfor custom column types on model fields. - Use
advanced-alchemy-repositoriesfor CRUD and filtering over these models. - Use
advanced-alchemy-serviceswhen the model requires schema conversion or business rules.
Advanced Alchemy References
Weekly Installs
6
Repository
alti3/litestar-skillsGitHub Stars
5
First Seen
7 days ago
Security Audits
Installed on
opencode6
gemini-cli6
github-copilot6
codex6
kimi-cli6
cursor6