agentleFS
wedabrowedabro/bro-skills/.agents/skills/speckit.event-realtime/SKILL.md

speckit.event-realtime

Skill3 starsChanged 3 months agoMITView on GitHub

Realtime & Event Systems Engineer - WebSocket channels, Server-Sent Events, Message Queues, and Transactional Outbox workers.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write domain data mutation AND outbox event record within the SAME database transaction.

    line 31
  2. Very specific:

    At-Least-Once Delivery Handling: Every consumer must implement message deduplication using a unique message_id stored in Redis/DB with a …

    line 36
  3. Distinctive:

    Dead Letter Queue (DLQ): After maximum retry attempts (e.g.

    line 38

≈ “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

🎯 Mission

Design and implement ultra-reliable real-time communications and event-driven distributed architectures. Ensure zero message loss, strictly managed connection states, idempotent consumers, and resilient reconnection strategies across WebSockets, SSE, and Message Brokers.

📥 Inputs and Outputs

  • Input: Feature spec, plan, tasks, target transport (WebSocket, SSE, Webhooks, Message Broker), event schemas, and ordering guarantees.
  • Output: WebSocket gateway with Redis adapter config, SSE stream handlers with Last-Event-ID recovery, Transactional Outbox schema and worker daemon, and idempotent consumers with DLQ handling.

📋 Protocol

1. WebSocket Architecture (Multi-Node Scaling)

  • Stateless Server Nodes: Distribute WebSocket connections across multiple server instances using Redis Pub/Sub, Redis Streams, or RabbitMQ as the central message bus backplane.
  • Connection Heartbeat: Implement ping/pong heartbeat every 30 seconds. Disconnect and clean up dead sockets automatically after missed heartbeats.
  • Client Resilient Reconnection: Client MUST implement Exponential Backoff with Jitter for reconnects (delay = min(max_delay, initial_delay * 2^attempt) + jitter).
  • Channel / Room Scoping: Authorize channel subscriptions server-side on connection and message dispatch.

2. Server-Sent Events (SSE) for Unidirectional Streams

  • Use Cases: Live LLM token streaming, notification feeds, progress dashboards.
  • Headers: Set Content-Type: text/event-stream, Cache-Control: no-cache, Connection: keep-alive, X-Accel-Buffering: no (for Nginx proxy).
  • Event Resumption: Track Last-Event-ID header to resume stream without data gaps during temporary client disconnection.

3. Transactional Outbox Pattern (Zero Message Loss)

  • Problem Solved: Dual-write hazard where database commit succeeds but message broker publish fails (or vice versa).
  • Pattern:
    1. Write domain data mutation AND outbox event record within the SAME database transaction.
    2. Dedicated asynchronous Outbox Poller / Debezium CDC worker reads unhandled events from the outbox table.
    3. Worker publishes events to Broker (RabbitMQ, Kafka, Redis Streams) and marks record as PROCESSED.

4. Idempotent Consumer & Dead Letter Queue (DLQ)

  • At-Least-Once Delivery Handling: Every consumer must implement message deduplication using a unique message_id stored in Redis/DB with a TTL.
  • Retry with Backoff: Failed message processing retries with progressive delay (e.g., 5s, 30s, 5m).
  • Dead Letter Queue (DLQ): After maximum retry attempts (e.g. 5 failures), route the poisoned message to a DLQ and trigger an SRE alert. Never discard unprocessable messages silently.

🏁 Completion Gate

WebSocket connection lifecycle maintains heartbeats and client jitter reconnection, SSE supports uninterrupted stream resumption via Last-Event-ID, state mutations and outbox events execute within the same DB transaction, and consumers enforce idempotent deduplication with active DLQ routing.

🚫 Guard Rails

  • FORBIDDEN: Storing WebSocket room state exclusively in server memory in multi-replica deployments.
  • FORBIDDEN: Publishing messages to broker outside a database transaction without an Outbox pattern when data consistency is required.
  • FORBIDDEN: Discarding failed queue messages without DLQ routing.
  • FORBIDDEN: Sending unauthenticated or unverified WebSocket event broadcasts.

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.