$ recombobulate _
home / tips / ask-claude-to-write-your-websocket-event-handlers
0

Ask Claude to Write Your WebSocket Event Handlers

bagwaa @bagwaa · Mar 26, 2026 · Workflows
ask-claude-to-write-your-websocket-event-handlers

WebSockets look intimidating until you've done a few. Claude knows the APIs, the edge cases (heartbeats, reconnects, room isolation), and can have you running in minutes.

Add WebSocket support to my Express app using the ws package.
Broadcast a "user_joined" event with the username when a client connects.
Broadcast a "user_left" event when they disconnect.
Keep a Map of connected clients so I can send messages to specific users.

Claude generates the server setup, event handler structure, and a helper for broadcasting to specific rooms or all connected clients. It will add a ping/pong heartbeat by default to detect stale connections.

For Laravel projects using Reverb or Pusher:

Create a Laravel broadcast event called OrderStatusUpdated.
It should fire on the private channel orders.{order_id} when an order status changes.
Include the channel authorization policy.
Also generate the frontend Echo listener using Laravel Echo and Pusher JS.

Claude understands the difference between public and private channels, knows to add the ShouldBroadcast interface, and will generate the matching channel route in routes/channels.php.

If you're unsure which stack to use, just ask:

What's the simplest way to add real-time notifications to my Laravel + Vue app in 2024?
Compare Reverb, Pusher, and SSE for my use case: ~500 concurrent users.

Describe the event, let Claude write the handler — real-time features don't need to be hard.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 2 hours ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 2 hours ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago