sse-realtime

sse-realtime is a cursor rule for Cursor from golid-ai/golid. It costs 0 tokens per session (611 once invoked), scanned A, original, MIT.

A set of rules for building server-sent event (SSE) connections, which let a server send live updates to a browser. It covers authentication tickets, per-user message channels, keepalive messages, reconnecting, and connection limits.

In plain words
What is it for?
Use it when implementing live updates such as notifications, progress reports, or streaming events from a Go service to a browser.
Why use it?
It provides a consistent way to handle live connections without putting reusable login tokens in URLs. It also addresses dropped messages, reconnect attempts, resource limits, and clean shutdowns.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when implementing live updates such as notifications, progress reports, or streaming events from a Go service to a browser.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/golid-ai/golid/sse-realtime
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/golid-ai/golid

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for sse-realtime

README.md
[![agentmods](https://agentmods.dev/badge/rules/golid-ai/golid/sse-realtime/github.svg)](https://agentmods.dev/rules/golid-ai/golid/sse-realtime)
Your own site
<a href="https://agentmods.dev/rules/golid-ai/golid/sse-realtime"><img src="https://agentmods.dev/badge/rules/golid-ai/golid/sse-realtime/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for sse-realtime

Your own site · 80×15
<a href="https://agentmods.dev/rules/golid-ai/golid/sse-realtime"><img src="https://agentmods.dev/badge/rules/golid-ai/golid/sse-realtime.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 611 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00611
Opus 5 $0.00000 $0.00305
Sonnet 5 $0.00000 $0.00122
Haiku 4.5 $0.00000 $0.00061

Measured 9d ago against content hash 86897298823b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

sse-realtime scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/sse-realtime.mdc · 67 lines

How it starts

The opening of the file, as written. The whole thing — 67 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SSE / Real-Time Patterns

Thesis: SSE uses one-time ticket auth (never JWT in URLs), per-user buffered channels, and frontend reconnect with exponential backoff.

Hub Architecture

SSEHub is a singleton created in wire.BuildServices (internal/wire/services.go). Per-user channel sets with buffered channels (16). Non-blocking sends — if a client's buffer is full, the event is dropped (logged as warning). Max 5 connections per user prevents resource exhaustion.

// in wire.BuildServices:
sseHub := sse.NewSSEHub(cfg.SSETicketTTL)
// Pass to handler and any service that needs to push events

main.go shuts down the hub after HTTP drain: svcs.SSEHub.Shutdown().

Ticket Auth (not JWT in URL)

EventSource can't set Authorization headers. Never put JWTs in URLs (they leak into logs). Use one-time tickets:

  1. Client calls POST /api/v1/events/ticket with JWT auth → gets a 30s single-use ticket
  2. Client opens EventSource("/api/v1/events/stream?ticket=<ticket>")
  3. Server validates and burns the ticket, begins streaming

The stream endpoint is on the public API group (not behind JWT middleware) — it uses ticket auth directly.

Keepalive

Send : keepalive\n\n every 30 seconds. Cloud Run closes idle connections at 15 minutes.

Frontend Reconnect

On disconnect: refresh access token first (it may have expired), request a new ticket, reconnect with exponential backoff (1s → 2s → 4s → max 30s). Reset backoff on successful connect.

Scaling Limitation

The hub is in-memory — all connected clients must be on the same instance. For multi-instance deployments, add a pub/sub layer (Redis, NATS). Send() and Broadcast() are the integration points.

Adding New Event Types

Backend — publish from any service:

sseHub.Send(userID, sse.SSEEvent{
    Event: "order_updated",
    Data:  map[string]any{"order_id": orderID, "status": newStatus},
})

Frontend — register a typed handler:

onSSEEvent<OrderUpdate>("order_updated", (data) => {
    toast.info(`Order ${data.order_id} is now ${data.status}`);
});

Read the full file on GitHub · 67 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 67 lines · 0 tokens per session scan A 86897298823b

Subscribe to this mod's changes

sse-realtime is a cursor rule published in the GitHub repository golid-ai/golid (40 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 611 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.