kemalcr/kemal/kemal-sse
Claude Code and agent skill by kemalcr/kemal
- community
Checking that the SKILL.md file is still in the repository.
Real-time Server-Sent Events (SSE) streaming in Kemal 1.12+, following established project patterns.
Install
npx vskill@latest install kemalcr/kemal/kemal-sseSKILL.md
The same SKILL.md was published earlier as kemalcr/kemal/kemal-sse.
Kemal Server-Sent Events (SSE)
This skill provides expert guidance on implementing real-time unidirectional event streaming using Kemal's built-in sse helper (available in Kemal 1.12.0+).
Version Notes
sseroute helper andKemal::EventStream(named events,id:,retry:): since Kemal 1.12.0.- SSE injection protection (CR/LF rejected in
event/id, CRLF normalization indataand comments) and theretryfield Int32 overflow fix: since Kemal 1.13.0. - Negative
retryspans are omitted from the output (clients discard non-digit values): unreleased, after Kemal 1.13.0.
Core Mandates
- SSE Route Definition (Kemal 1.12.0+): Use the
ssehelper block to define an SSE endpoint:
``crystal sse "/events" do |stream, env| stream.send("hello world") end ``
- Sending Named Events & Security: Pass
event,id, and optionalretry(Time::Span) keyword arguments:
``crystal sse "/notifications" do |stream, env| stream.send({"message" => "New alert"}.to_json, event: "alert", id: 101, retry: 5.seconds) end ``
Security Note (Kemal 1.13.0+): Kemal::EventStream prevents SSE injection by rejecting raw newlines in event and id arguments, and automatically normalizes CRLF sequences in data and comment.
- Streaming Loops & Channels: Use Crystal channels or keep-alive loops for streaming events:
``crystal sse "/stream" do |stream, env| loop do sleep 1.seconds stream.send(Time.utc.to_s, event: "time") rescue IO::Error break # Connection closed by client end end ``
Patterns from Source Code
Real-Time Live Updates with Channel / Loop
Pub/Sub Broadcasting via SSE Stream Manager
Best Practices
- Connection Cleanup: Always handle client disconnects gracefully by rescuing
IO::Erroror using anensureblock. - Content Type: Kemal automatically sets
Content-Type: text/event-streamandCache-Control: no-cacheheaders for SSE routes. - JSON Serialization: Convert Crystal data structures to JSON strings using
.to_jsonbefore passing tostream.send(...). - API Response Helpers: For JSON response formatting and error handling on companion HTTP routes (e.g.
post "/publish"), follow the patterns in `kemal-json`. - Prefer SSE over WebSockets for Uni-directional Feeds: Use SSE for live log feeds, dashboard metrics, and notifications where full bi-directional socket protocol overhead is unnecessary.
When to Use
- When building real-time dashboards, log streaming, or live notification feeds.
- When client-to-server responses are handled via standard HTTP POST routes, while server-to-client updates stream via HTTP
text/event-stream.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/kemal-sse/SKILL.md
Popularity
- Repository stars
- 3,918
- Repository forks
- 205
- 7-day trend score
- 41
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kemalcr/kemal/kemal-sse)