Skip to content
Back to skills

Architecture

ASecurity

Design of real-time features — WebSocket, SSE or long polling choice, scaling with Redis pub/sub, heartbeats, authentication and limits. Use when adding chat, live updates or any persistent connection.

  • 24 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added October 14, 2026
ai-agentsgobackendsecurity

Works with

  • cli

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned November 22, 2026

npx -y skills add andreibesleaga/GABBE --skill architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-architecture-bbfdf549/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-architecture-bbfdf549)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: realtime-comm
description: Design of real-time features — WebSocket, SSE or long polling choice, scaling with Redis pub/sub, heartbeats, authentication and limits. Use when adding chat, live updates or any persistent connection.
triggers: [realtime comm, websocket, server-sent events, pub/sub, live updates, long polling]
tags: [architecture]
role: eng-backend
context_cost: low
---
# realtime-comm Skill

## Goal
This skill guides the implementation of bi-directional, stateful communication.

## Steps
## 1. Protocol Selection

| Protocol | Use Case | Pros | Cons |
|---|---|---|---|
| **WebSockets** | Chat, Games, Collaboration | Full Duplex, Low Latency. | Stateful (hard to scale). |
| **SSE (Server-Sent Events)** | Stock Tickers, Notifications | Simple (HTTP), Auto-reconnect. | One-way (Server -> Client). |
| **Long Polling** | Legacy Support | Works everywhere. | High server resource usage. |

## 2. Scaling (The Hard Part)
- **Problem**: Client A connects to Server 1. Client B connects to Server 2. A sends message to B. Server 1 doesn't know B.
- **Solution**: **Redis Pub/Sub Adapter**.
  - Server 1 publishes event to Redis channel `room:123`.
  - Server 2 subscribes to `room:123` and forwards to Client B.

## 3. Implementation Checklist
- [ ] **Heartbeats**: Ping/Pong every 30s to keep connection alive through Load Balancers.
- [ ] **Authentication**: Authenticate *before* upgrade (pass Token in Query Param or Cookie).
- [ ] **Reconnection logic**: Exponential backoff on client.
- [ ] **State**: Store `socket_id` -> `user_id` mapping in Redis, not local memory.

## 4. Security
- **Origin Check**: Validate `Origin` header during handshake.
- **DoS Protection**: Limit message size (e.g., max 1KB).
- **Auth**: Validate token on every distinct action if connection is long-lived.

## Constraints
- State lives in shared storage (Redis), not in local memory.
- Clients reconnect with exponential backoff.

## Output Format
The protocol choice with its reason and the implementation following the checklist in section 3.

## Limits and safety
- Authenticate before the upgrade to WebSocket and check the `Origin` header in the handshake.
- Set a maximum message size and a rate limit on the server; a fallback transport (long polling) gets the same authentication and limits.
- Handle token expiry or revoked permissions mid-session: close the connection or re-check authorization on each message.
- Channel names include the tenant; a user can subscribe only to channels they may read.

Files in this skill

  • adaptive-architecture.skill.md3.7 KB
  • api-design.skill.md4.7 KB
  • api-standards.skill.md1.7 KB
  • arch-debt.skill.md8.2 KB
  • arch-design.skill.md12.6 KB
  • arch-patterns.skill.md3.9 KB
  • arch-review.skill.md14.1 KB
  • architecture-governance.skill.md3.6 KB
  • attribute-driven-design.skill.md7.5 KB
  • blockchain-dlt.skill.md1.9 KB
  • compatibility-design.skill.md3.6 KB
  • critical-systems-arch.skill.md2 KB
  • design-patterns.skill.md4.3 KB
  • diagramming.skill.md13.9 KB
  • domain-model.skill.md12.1 KB
  • enterprise-migration-scenario.skill.md2 KB
  • enterprise-patterns.skill.md1.9 KB
  • error-handling-strategy.skill.md3.9 KB
  • event-driven-architecture.skill.md1.8 KB
  • event-governance.skill.md3.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.