advanced-alchemy-litestar
SKILL.md
Litestar
Execution Workflow
- Configure
SQLAlchemyAsyncConfigorSQLAlchemySyncConfigand registerSQLAlchemyPlugin. - Use the plugin to provide session and engine dependencies instead of hand-rolling request-scoped session management.
- Build controllers around services first, and fall back to repository-only patterns only when they stay simpler.
- Keep application composition in
Litestar(...)and let providers or DI supply services. - Enable CLI database commands and optional session-backend support only after the core CRUD path is stable.
Implementation Rules
- Prefer a single canonical plugin configuration per application.
- Keep
before_send_handlerand session dependency keys explicit when changing defaults. - Use controller or handler injection for
db_sessiononly when service injection is unnecessary. - Keep DTO or schema shaping close to the controller boundary, not inside repositories.
Example Pattern
from advanced_alchemy.extensions.litestar import (
AsyncSessionConfig,
SQLAlchemyAsyncConfig,
SQLAlchemyPlugin,
)
from litestar import Litestar
alchemy_config = SQLAlchemyAsyncConfig(
connection_string="sqlite+aiosqlite:///test.sqlite",
before_send_handler="autocommit",
session_config=AsyncSessionConfig(expire_on_commit=False),
create_all=True,
)
app = Litestar(plugins=[SQLAlchemyPlugin(config=alchemy_config)])
Validation Checklist
- Confirm Litestar injects the expected
db_sessionor renamed dependency. - Confirm request lifecycle commit and rollback behavior matches
before_send_handler. - Confirm
litestar databasecommands are available when the plugin is installed. - Confirm route handlers, providers, and DTOs agree on model and schema types.
Cross-Skill Handoffs
- Use
advanced-alchemy-routingfor CRUD route structure. - Use
advanced-alchemy-servicesfor service-backed controllers. - Use
advanced-alchemy-clifor migration commands exposed through Litestar CLI. - Use
litestar-app-setup,litestar-dependency-injection, orlitestar-dtofor deeper Litestar-only concerns.
Advanced Alchemy References
Weekly Installs
5
Repository
alti3/litestar-skillsGitHub Stars
5
First Seen
6 days ago
Security Audits
Installed on
cline5
github-copilot5
codex5
kimi-cli5
gemini-cli5
cursor5