litestar-ai-serving
Auto-activate for Google ADK, LlmAgent, Runner, SQLSpecSessionService, Vertex AI, SSE agent chats, tool calls, or Litestar model workflows. Not for offline ML…
Auto-activate for advanced_alchemy imports, alembic/, SQLAlchemyAsyncRepositoryService, SQLAlchemyAsyncConfig, repository_type, service_class, filters, or storage. Not for raw SQLAlchemy without Advanced Alchemy — use SQLAlchemy guidance.
$ npx -y skills add litestar-org/litestar-skills --skill advanced-alchemy --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/advanced-alchemyContext preview
The summary Claude sees to decide when to auto-load this skill.
Auto-activate for advanced_alchemy imports, alembic/, SQLAlchemyAsyncRepositoryService, SQLAlchemyAsyncConfig, repository_type, service_class, filters, or storage. Not for raw SQLAlchemy without Advanced Alchemy — use SQLAlchemy guidance.
name: advanced-alchemy description: "Auto-activate for advanced_alchemy imports, alembic/, SQLAlchemyAsyncRepositoryService, SQLAlchemyAsyncConfig, repository_type, service_class, filters, or storage. Not for raw SQLAlchemy without Advanced Alchemy — use SQLAlchemy guidance."
supports it in model modules.
advanced-alchemy ships first-party extensions for five web frameworks. If your project uses one of these, **jump directly to the matching integration guide and skip the others**:
Transaction configuration is framework-specific. Litestar uses `before_send_handler`; FastAPI, Flask, Starlette, and Sanic use `commit_mode="manual"`, `"autocommit"`, or `"autocommit_include_redirect"`. Read the matching framework guide, then [`references/commit-modes.md`](references/commit-modes.md) and [`references/multi-database.md`](references/multi-database.md).
The rest of this SKILL.md covers framework-agnostic topics: base classes, repositories, services, filters, custom types, caching, replicas, operations, and Alembic migrations.
Advanced Alchemy is NOT a raw ORM — it is a **service/repository layer** built on top of SQLAlchemy 2.0+ with opinionated base classes, audit mixins, and deep framework integrations (Litestar, FastAPI, Flask, Starlette, Sanic). It provides:
| Base Class | PK Type | Audit Columns | When to Use | | --- | --- | --- | --- | | `UUIDAuditBase` | UUID v4 | `created_at`, `updated_at` | Default choice for most models | | `UUIDBase` | UUID v4 | None | Lookup tables, tags, no audit needed | | `UUIDv7AuditBase` | UUID v7 | `created_at`, `updated_at` | Time-ordered IDs when `uuid-utils` is installed or Python supplies UUIDv7 | | `BigIntAuditBase` | BigInt auto-increment | `created_at`, `updated_at` | Legacy systems, integer PKs | | `NanoIDAuditBase` | NanoID string | `created_at`, `updated_at` | URL-friendly short IDs | | `IdentityAuditBase` | database identity | `created_at`, `updated_at` | Native IDENTITY columns | | `DefaultBase` | None (define yourself) | None | Custom primary keys with AA table naming |
| Repository | Purpose | | --- | --- | | `SQLAlchemyAsyncRepository[Model]` | Standard async CRUD | | `SQLAlchemyAsyncSlugRepository[Model]` | CRUD + automatic slug generation | | `SQLAlchemyAsyncQueryRepository` | Complex read-only queries (no model_type) |
| Service | Purpose | | --- | --- | | `SQLAlchemyAsyncRepositoryService[Model]` | Full CRUD with lifecycle hooks | | `SQLAlchemyAsyncRepositoryReadService[Model]` | Read-only (get_many, get, count, exists) |
Key lifecycle hooks: `to_model_on_create`, `to_model_on_update`, `to_model_on_upsert`.
| Type | Purpose | Notes | | --- | --- | --- | | `FileObject` | Object storage with lifecycle hooks | Tracks file state across session; auto-deletes on row delete via `StoredObject` tracker | | `PasswordHash` | Hashed password storage | Supports Argon2, Passlib, and Pwdlib backends; hashes on assignment | | `EncryptedString` | Transparent encryption at rest | Pass a stable key explicitly; the random default is deprecated | | `UUID6` / `UUID7` | Time-sortable UUID variants | UUID7 preferred for standardized timestamp-ordered identifiers | | `DateTimeUTC` | Timezone-aware UTC datetime | Stores as UTC; raises on naive datetimes | | `Bool` | Dialect-aware boolean | Uses Oracle 23c native `BOOLEAN` when SQLAlchemy exposes it; falls back to stock SQLAlchemy `Boolean` | | `Vector` | Dialect-aware vector storage and distance operators | Oracle 23ai `VECTOR`, PostgreSQL/CockroachDB `pgvector`, JSON fallback without distance operators | | `TOTPSecret` / `OneTimeCode` | MFA and single-use code storage | `TOTPSecret` encrypts shared secrets; `OneTimeCode` hashes codes and requires an explicit hashing backend |
`SQLAlchemyAsyncRepositoryService` is the primary service base class. Key behaviors:
Opinionated, first-party agent skills, plugins, subagents, slash commands, and MCP servers for the Litestar framework and its ecosystem — publishable to every major AI agent and IDE from a single repo.
Repo: litestar-org/litestar-skills
Auto-activate for Google ADK, LlmAgent, Runner, SQLSpecSessionService, Vertex AI, SSE agent chats, tool calls, or Litestar model workflows. Not for offline ML…
Auto-activate for guards=, Guard, ASGIConnection, JWTAuth, JWTCookieAuth, SessionAuth, role or tenant checks, or WebSocket auth. Not for frontend route…
Auto-activate for litestar_autowire, AutowirePlugin, AutowireConfig, domain_packages, AutowireIntegration, AutowireLoader, or clear_autowire_cache. Not for…
Auto-activate for uv build, hatch build, PyApp, PYAPP_*, wheel assets, GitHub release matrices, cargo-zigbuild, or python-build-standalone. Not for runtime…
Auto-activate for SQLAlchemyAsyncRepositoryService, SQLSpecAsyncService, create_filter_dependencies, LimitOffsetFilter, OffsetPagination, filters, or CRUD…
Auto-activate for Dockerfile, compose, Railway, Cloud Run, GKE, systemd, Kubernetes, Terraform, deploy scripts, or granian/litestar run at runtime. Not for…