plugins/litestar/skills/litestar-htmx/SKILL.md
Build HTMX-driven Litestar flows with `HTMXPlugin`, `HTMXRequest`, `request.htmx`, `HTMXTemplate`, and HTMX response classes such as `HXLocation`, `PushUrl`, `ReplaceUrl`, `Reswap`, `Retarget`, `TriggerEvent`, `ClientRedirect`, `ClientRefresh`, and `HXStopPolling`. Use when implementing server-rendered partial updates, progressive enhancement, polling, redirects, or history-aware HTML interactions. Do not use for SPA-only JSON APIs that do not exchange HTML or HTMX headers.
npx skillsauth add alti3/litestar-skills litestar-htmxInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
HTMXPlugin or locally with request_class=HTMXRequest.request.htmx instead of hand-parsing HTMX headers.HTMXTemplate for rendered fragments or the dedicated HTMX response classes for redirect, refresh, swap, retarget, event, history, or polling behavior.HTMXPlugin() when most of the app should speak HTMX-aware requests.request_class=HTMXRequest locally when only one app layer or route needs HTMX support.request.htmx and HTMXDetails properties over manual header inspection.HTMXTemplate handlers as returning Template, matching the Litestar docs.HTMXTemplate, provide after= and keep it to receive, settle, or swap.HX-* headers.HTMXPlugin() when HTMX is the dominant interaction model.HTMXConfig(set_request_class_globally=False) when you want the plugin installed without forcing HTMXRequest at app scope.request.htmx truthiness to branch between full-page and fragment responses.HTMXTemplate when the response is HTML and may also need push_url, re_swap, re_target, or event triggering.ClientRedirect when the browser should redirect with a full reload.HXLocation when the client should navigate without a full page reload and may need target, swap, select, headers, or values.PushUrl or ReplaceUrl when you want to return content and also mutate browser history or the location bar.Reswap, Retarget, or TriggerEvent when the content stays inline but the HTMX client behavior must change.ClientRefresh when the whole page must refresh.HXStopPolling for polling endpoints that should explicitly stop the HTMX client.Read only the sections you need:
HTMXPlugin, HTMXConfig, HTMXRequest, and request.htmx usage, read references/setup-and-request-patterns.md.HTMXTemplate, full-page vs fragment rendering, and the dedicated HTMX response classes, read references/template-and-response-patterns.md.template_config; layer HTMX on top of existing server-rendered HTML rather than inventing a separate rendering stack.HTMXPlugin() when most handlers will need request.htmx.HTMXTemplate and the built-in HTMX response classes over manual header management.push_url, replace_url, and HXLocation remain predictable in tests and browser history.HX-* headers directly when request.htmx already provides the values.HTMXTemplate instead of Template.request.htmx fields used by the handler actually match the client-side HTMX attributes in play.HTMXTemplate event triggering includes after= when required.litestar-templating for engine setup, template directories, shared layouts, and template helper concerns.litestar-responses when the main issue is generic response metadata rather than HTMX-specific headers and flow control.litestar-routing when controller/router-level request_class placement or route structure is the real problem.litestar-testing to assert fragment HTML, redirects, polling stop behavior, and HTMX header-driven contracts.development
Build Litestar WebSocket endpoints with low-level websocket handlers, websocket listeners, websocket streams, dependency injection, custom websocket classes, transport-mode control, and graceful connection lifecycle handling. Use when implementing bidirectional real-time communication, reactive websocket message handling, or proactive server push over WebSockets. Do not use for server-side pub/sub fanout that is better expressed with channels alone.
tools
Test Litestar applications with TestClient, AsyncTestClient, create_test_client, websocket test helpers, dependency overrides, mocked dependencies, lifecycle-aware fixtures, and deterministic success and failure assertions. Use when adding or fixing Litestar test coverage, including exception contracts, override precedence, websocket behavior, event-bus side effects, or live-server-only response patterns. Do not use as a substitute for production observability or runtime debugging strategy.
development
Configure Litestar templating with `TemplateConfig`, Jinja/Mako/MiniJinja engines, file-or-string `Template` responses, request and CSRF-aware context, template callables, and custom engine integration. Use when implementing or fixing server-rendered HTML in Litestar. Do not use for static asset serving or pure JSON API endpoints.
development
Configure Litestar stores and the store registry for caching, server-side sessions, rate limiting, and other key-value state with explicit backend selection, bytes-safe data handling, TTL and renewal policy, namespacing, registry wiring, and lifecycle cleanup. Use when a Litestar app depends on `MemoryStore`, `FileStore`, `RedisStore`, `ValkeyStore`, or `StoreRegistry`. Do not use for relational persistence, domain repositories, or response-caching policy details that belong in database or caching-focused skills.