Agent skill
litestar
Expert knowledge for Litestar Python web framework. Use when working with Litestar routes, plugins, middleware, dependency injection, or configuration.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/testing/litestar
SKILL.md
Litestar Framework Skill
Quick Reference
Plugin Development
from litestar.plugins import InitPluginProtocol
from litestar import Litestar
class MyPlugin(InitPluginProtocol):
def __init__(self, config: MyConfig) -> None:
self.config = config
def on_app_init(self, app_config: AppConfig) -> AppConfig:
"""Modify app config during initialization."""
app_config.state["my_plugin"] = self
return app_config
Route Handlers
from litestar import get, post, Controller
from litestar.di import Provide
@get("/items/{item_id:int}")
async def get_item(item_id: int) -> Item:
return await fetch_item(item_id)
class ItemController(Controller):
path = "/items"
dependencies = {"service": Provide(get_service)}
@get("/")
async def list_items(self, service: ItemService) -> list[Item]:
return await service.list_all()
Dependency Injection
from litestar.di import Provide
def get_db_session(state: State) -> AsyncSession:
return state.db_session
@get("/", dependencies={"session": Provide(get_db_session)})
async def handler(session: AsyncSession) -> Response:
...
Middleware
from litestar.middleware import AbstractMiddleware
from litestar.types import ASGIApp, Receive, Scope, Send
class MyMiddleware(AbstractMiddleware):
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
# Pre-processing
await self.app(scope, receive, send)
# Post-processing
Project-Specific Patterns
This project uses:
- Type hints: PEP 604 (
T | None) - Async/await: For all I/O operations
- Google-style docstrings: For all public APIs
- No
from __future__ import annotations
Context7 Lookup
mcp__context7__get-library-docs(
context7CompatibleLibraryID="/litestar-org/litestar",
topic="plugins middleware dependency-injection",
mode="code"
)
Related Files
src/py/litestar_vite/plugin.py- VitePlugin implementationsrc/py/litestar_vite/config.py- ViteConfigsrc/py/litestar_vite/inertia/plugin.py- InertiaPlugin
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?