Skip to content
Development
Skill

/litestar-realtime

Auto-activate for @websocket, websocket_listener, websocket_stream, WebSocket, ServerSentEvent, ChannelsPlugin, AsyncPgChannelsBackend, RedisChannelsPubSubBackend, SQLSpecChannelsBackend, or fan-out. Not for polling APIs.

From plugin
litestar
1431 skills1 agent1 hook
Install
$ npx -y skills add litestar-org/litestar-skills --skill litestar-realtime --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/litestar-realtime

Context preview

The summary Claude sees to decide when to auto-load this skill.

Auto-activate for @websocket, websocket_listener, websocket_stream, WebSocket, ServerSentEvent, ChannelsPlugin, AsyncPgChannelsBackend, RedisChannelsPubSubBackend, SQLSpecChannelsBackend, or fan-out. Not for polling APIs.

SKILL.md

litestar-realtime.SKILL.md
name: litestar-realtime
description: "Auto-activate for @websocket, websocket_listener, websocket_stream, WebSocket, ServerSentEvent, ChannelsPlugin, AsyncPgChannelsBackend, RedisChannelsPubSubBackend, SQLSpecChannelsBackend, or fan-out. Not for polling APIs."

Litestar Realtime

Use this skill for WebSockets, SSE, ChannelsPlugin backends, realtime event contracts, and fan-out from workers or services.

Code Style Rules

  • Use plain WebSocket handlers for one-off streams.
  • Use ChannelsPlugin when dynamic topics, history, or cross-process fan-out matter.
  • Choose the backend that matches the existing stack.
  • Treat WebSocket auth separately from HTTP header auth constraints.

Quick Reference

  • WebSocket and Channels patterns: [websockets.md](references/websockets.md)
  • Event contract patterns: [realtime-events.md](references/realtime-events.md)
  • Pair with [litestar-auth-guards](../litestar-auth-guards/SKILL.md) for socket auth.

<workflow>

Workflow

1. Choose WebSocket, SSE, or Channels based on delivery needs. 2. Define event contracts before wiring transport. 3. Select a backend that fits the project stack. 4. Test connection, auth, fan-out, disconnect, and error paths.

</workflow>

<guardrails>

Guardrails

  • Do not force Redis into a PostgreSQL-only stack just for Channels.
  • Do not assume browsers can set arbitrary WebSocket headers.
  • Do not publish untyped event dicts across service boundaries.
  • Do not use request-scoped resources after the socket lifecycle ends.

</guardrails>

<validation>

Validation Checkpoint

  • [ ] Transport choice matches the user experience.
  • [ ] Event payloads are typed.
  • [ ] Backend choice matches the stack.
  • [ ] Auth and disconnect behavior are tested.

</validation>

<example>

Example

from litestar import websocket


@websocket("/ws")
async def stream(socket: WebSocket) -> None:
    await socket.accept()
    await socket.send_json({"type": "ready"})

</example>

References Index

  • [websockets.md](references/websockets.md)
  • [realtime-events.md](references/realtime-events.md)

Official References

  • <https://docs.litestar.dev/> - Litestar documentation
  • <https://docs.litestar.dev/latest/reference/> - Litestar API reference

Shared Styleguide Baseline

  • [General](../litestar-styleguide/references/general.md)
  • [Python](../litestar-styleguide/references/python.md)
  • [Litestar](../litestar-styleguide/references/litestar.md)
Read more
Ships withlitestar

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.

Get the whole plugin

Other skills on litestar.