agentleFS
dekozadekoza/oh-my-slop/skills/reference/litestar/SKILL.md

litestar

Skill4 starsChanged 9 months agoUnlicenseView on GitHub

Use when building, reviewing, or debugging a Litestar app — handlers, controllers/routers, dependency injection, DTOs, middleware, lifecycle hooks, templating, static files, websockets, or testing. Triggers on: "Litestar", an app that fails at startup after adding a handler or moving imports behind `TYPE_CHECKING`, sync-handler thread warnings, custom 404/405 handlers that never fire, `Provide`/`Dependency` wiring, or DTO configuration. Not a source of truth for generic FastAPI/Starlette guidance or deep ORM internals.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use semantic HTTP decorators: - Prefer @get, @post, @put, @patch, @delete, not @route(), unless multi-method handling is truly required.

    line 19
  2. Very specific:

    Use current static-files API: - Prefer create_static_files_router().

    line 30
  3. Distinctive:

    Generic FastAPI or Starlette advice: - Do not treat Litestar as a drop-in alias.

    line 34
  4. Very specific:

    All files live in references/.

    line 41
  5. Very specific:

    If runtime annotation availability or sync_to_thread behavior is part of the issue, say that explicitly instead of giving generic Python …

    line 64

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Litestar Framework Reference

Use this skill for core Litestar framework implementation and integration: application structure, layered configuration, handlers, requests, dependency injection, DTOs, middleware, lifecycle hooks, exceptions, templating, static files, testing, websockets, and guards. Open the single best reference file from the routing table, add a second only when the task clearly crosses domains, and implement with verified Litestar patterns, not generic ASGI guesses.

Critical Rules

  1. Use semantic HTTP decorators - Prefer @get, @post, @put, @patch, @delete, not @route(), unless multi-method handling is truly required.
  2. Annotate everything - Litestar requires full argument and return type annotations for handlers. Missing annotations fail app startup.
  3. Keep runtime types available - Handler and dependency annotations are inspected at runtime. TYPE_CHECKING-only imports can break signature parsing unless you provide signature_types or signature_namespace.
  4. Decide sync execution explicitly - Synchronous handlers and dependencies should set sync_to_thread=True for blocking work or False for safe non-blocking work. Implicit sync raises warnings.
  5. Respect layer precedence - For layered settings, the closest layer to the handler wins. Guards are the exception: they accumulate.
  6. Middleware order is deterministic - Middleware executes app -> router -> controller -> handler, left to right within each layer.
  7. Dependency keys must match kwargs - Dependency dictionary keys and injected parameter names must match exactly, and scope is limited to the declaring layer.
  8. Yield dependencies clean up before send - Cleanup runs after the handler returns but before the HTTP response is sent. Cleanup failures are re-raised later as ExceptionGroup.
  9. Request body defaults to JSON - For forms, multipart, or MessagePack, annotate data with Body(media_type=...). File uploads should use UploadFile.
  10. 404 and 405 are app-layer concerns - Litestar raises router-generated 404 Not Found and 405 Method Not Allowed before the normal middleware stack and lower-layer exception handlers are called. Handle them at the app layer, and when explaining them, state that timing directly instead of stopping at consequences like "controller middleware does not see them."
  11. Websocket dependencies are connection-scoped - Listener and stream dependencies are evaluated for the connection lifetime, not per message. Do not hold scarce resources for long-lived streams.
  12. Use current static-files API - Prefer create_static_files_router(). StaticFilesConfig is deprecated in current docs.

When Not To Use This Skill

  • Generic FastAPI or Starlette advice - Do not treat Litestar as a drop-in alias. Handler signatures, DI, DTOs, layering, and websockets differ in important ways.
  • ORM-specific implementation details - For deep SQLAlchemy, Piccolo, or repository-plugin behavior, use the relevant integration docs or project-specific skill.
  • HTMX attribute semantics - Litestar covers HTMX integration points, not full hx-* behavior. For swap, trigger, and attribute rules, load @htmx.
  • Project business rules - For app-specific architecture, load the project's custom skill.

Task Routing

All files live in references/. Add the secondary reference only when the task genuinely spans both domains.

TaskPrimarySecondary
Creating Litestar(...), routers, controllers, app state, lifespan, or layered configarchitecture-layers.md—
Building HTTP handlers, path params, request parsing, uploads, or custom requestshandlers-requests.md—
Implementing DI, Provide, Dependency, or DTO configurationdependencies-dto.md—
Adding middleware, lifecycle hooks, or exception handlersmiddleware-hooks-errors.md—
Building websocket listeners, streams, or Litestar testswebsockets-testing.md—
Rendering templates or serving static filestemplating-static.md—
HTMX plugin usage, template engine extras, or framework boundary questionsintegrations.md—
Multipart upload endpoint with DTO or dependency validationhandlers-requests.mddependencies-dto.md
Custom error handling that fails for 404 or 405middleware-hooks-errors.mdarchitecture-layers.md
HTMX partial rendering in a Litestar appintegrations.mdtemplating-static.md
Websocket endpoint with auth or connection-scoped resourceswebsockets-testing.mddependencies-dto.md
Startup failure after TYPE_CHECKING imports or forward refshandlers-requests.mdarchitecture-layers.md
Warnings or confusion around sync handlers and thread offloadinghandlers-requests.mdarchitecture-layers.md
Cross-cutting routing helpREFERENCE.md—

Output Expectations

  • Name the reference files used and call out the Litestar rules that matter for the change.
  • State the minimum verification steps: tests, startup validation, request or websocket checks, or OpenAPI checks.
  • If runtime annotation availability or sync_to_thread behavior is part of the issue, say that explicitly instead of giving generic Python advice.
  • Flag any 2.x vs 3.0 transition or deprecation risk if it affects the task.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.