websocket-development
Skill275 starsChanged 52 days agoApache-2.0View on GitHub
Best practices and guidelines for building real-time applications with WebSocket communication
In this repository264 other files it gives its agents.
- accessibility-a11ySkill
- alpine-jsSkill
- analytics-data-analysisSkill
- android-developmentSkill
- angular-developmentSkill
- angularSkill
- anime-jsSkill
- anthropic-claude-developmentSkill
- api-developmentSkill
- apollo-graphqlSkill
- aspnet-coreSkill
- astroSkill
- auth0-authenticationSkill
- autogen-developmentSkill
- automl-hyperparameter-optimizationSkill
- aws-developmentSkill
- azureSkill
- backend-developmentSkill
- bash-scriptingSkill
- beautifulsoup-parsingSkill
- bitbucket-workflowSkill
- blazorSkill
- blender-python-addonSkill
- blockchainSkill
- bootstrapSkill
- business-central-developmentSkill
- cheerio-parsingSkill
- chrome-extension-developmentSkill
- ci-cd-best-practicesSkill
- clean-architectureSkill
- clean-codeSkill
- clerk-authenticationSkill
- cloudflare-developmentSkill
- computer-vision-opencvSkill
- convexSkill
- cppSkill
- c-sharpSkill
- cssSkill
- cypressSkill
- data-analysis-jupyterSkill
- data-analystSkill
- data-jupyter-pythonSkill
- deep-learning-pythonSkill
- deep-learning-pytorchSkill
- deep-learningSkill
- deno-typescriptSkill
- design-systemsSkill
- devopsSkill
- django-pythonSkill
- django-rest-api-developmentSkill
- dockerSkill
- dotnetSkill
- drizzle-ormSkill
- drupal-developmentSkill
- elasticsearch-best-practicesSkill
- electron-developmentSkill
- elixirSkill
- embedded-stm32Skill
- esbuild-bundlerSkill
- ethereumSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
22 rules. About 0 are common, 20 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈20
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Follow the user's requirements carefully and to the letter
- Distinctive: line 18
Leave NO todos, placeholders, or missing pieces in the implementation
- Very specific: line 24
Always use the wss:// protocol with SSL/TLS encryption for production environments
- Distinctive: line 32
Use reconnection logic with exponential backoff for dropped connections
- Distinctive: line 40
Use structured message formats (JSON with type/payload pattern)
- Distinctive: line 43
Keep message payloads small to reduce latency
- Distinctive: line 47
Always include error handling logic for WebSocket connections
- Distinctive: line 56
Use a message broker (Redis Pub/Sub, RabbitMQ) for cross-server communication
- Distinctive: line 59
Consider using a dedicated WebSocket gateway service
- Distinctive: line 65
Use binary protocols (MessagePack, Protocol Buffers) for bandwidth-sensitive applications
- Distinctive: line 73
Use token-based authentication (JWT) with proper expiration
- Distinctive: line 81
Never trust client-provided data without validation
- Distinctive: line 94
Prefer Bun's native capabilities over third-party alternatives
- Very specific: line 95
Use Bun.serve() with WebSocket support instead of separate WebSocket libraries
- Distinctive: line 101
Use the standard WebSocket API for broad compatibility
- Distinctive: line 110
Test message serialization/deserialization independently
- Distinctive: line 111
Verify error handling paths
- Distinctive: line 115
Test full connection lifecycle scenarios
- Distinctive: line 116
Verify reconnection behavior under various failure modes
- Distinctive: line 131
Use efficient data structures for subscriber lookup
- Distinctive: line 138
Consider using acknowledgment messages for reliability
- Distinctive: line 143
Consider message deduplication strategies
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.
Files
WebSocket Development
You are an expert in WebSocket development and real-time communication systems. Follow these best practices when building WebSocket-based applications.
Core Principles
- Think through the implementation step-by-step before writing code
- Follow the user's requirements carefully and to the letter
- Prioritize security, scalability, and maintainability throughout
- Leave NO todos, placeholders, or missing pieces in the implementation
Connection Management
Establishing Connections
- Always use the
wss://protocol with SSL/TLS encryption for production environments - This ensures data transmitted over the connection is encrypted and secure from eavesdropping or tampering
- Implement proper handshake validation before accepting connections
- Set appropriate connection timeouts to prevent resource exhaustion
Connection Lifecycle
- Implement heartbeat/ping-pong mechanisms to detect stale connections
- Use reconnection logic with exponential backoff for dropped connections
- Maintain connection state to handle disconnection scenarios gracefully
- Clean up resources properly when connections close
Message Handling
Message Design
- Use structured message formats (JSON with type/payload pattern)
- Include message IDs for request-response correlation
- Implement message versioning for backward compatibility
- Keep message payloads small to reduce latency
Error Handling
- Always include error handling logic for WebSocket connections
- Manage potential disconnections or message failures gracefully
- Implement dead letter handling for unprocessable messages
- Log errors with sufficient context for debugging
Scalability Patterns
Horizontal Scaling
- Use a message broker (Redis Pub/Sub, RabbitMQ) for cross-server communication
- Implement sticky sessions or connection affinity when needed
- Design stateless handlers where possible
- Consider using a dedicated WebSocket gateway service
Performance Optimization
- Buffer messages during brief disconnections
- Implement message batching for high-frequency updates
- Use binary protocols (MessagePack, Protocol Buffers) for bandwidth-sensitive applications
- Monitor connection counts and message throughput
Security Best Practices
Authentication
- Authenticate connections during the handshake phase
- Use token-based authentication (JWT) with proper expiration
- Validate tokens on both connection and periodic intervals
- Implement rate limiting per connection and per user
Authorization
- Validate permissions for each message type/channel
- Implement channel-based access control for pub/sub patterns
- Never trust client-provided data without validation
- Sanitize all incoming message payloads
Framework-Specific Guidelines
Node.js Native WebSocket (v21+)
- Utilize Node.js's built-in WebSocket client for real-time communication to reduce dependencies
- The built-in client simplifies real-time communication and ensures better interoperability
- For servers, use established libraries like
wsor framework-specific solutions
Bun Runtime
- Prefer Bun's native capabilities over third-party alternatives
- Use
Bun.serve()with WebSocket support instead of separate WebSocket libraries - Leverage Bun's built-in stream handling and fetch implementation
Browser Clients
- Implement graceful degradation for older browsers
- Use the standard WebSocket API for broad compatibility
- Handle visibility changes to manage connection state
- Implement offline detection and queuing
Testing Strategies
Unit Testing
- Mock WebSocket connections for isolated testing
- Test message serialization/deserialization independently
- Verify error handling paths
Integration Testing
- Test full connection lifecycle scenarios
- Verify reconnection behavior under various failure modes
- Load test with realistic connection counts and message rates
Monitoring and Observability
- Track connection count metrics
- Monitor message latency and throughput
- Alert on connection error rates
- Log connection lifecycle events for debugging
Common Patterns
Pub/Sub Pattern
- Implement channel subscription management
- Use efficient data structures for subscriber lookup
- Handle subscription cleanup on disconnect
Request/Response Pattern
- Correlate requests and responses with unique IDs
- Implement timeout handling for pending requests
- Consider using acknowledgment messages for reliability
Broadcast Pattern
- Optimize for one-to-many message delivery
- Consider message deduplication strategies
- Implement backpressure for slow consumers
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
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.

