aurostack-org/stacks/add-realtime-listener
Claude Code and agent skill by aurostack-org/stacks
- community
Checking that the SKILL.md file is still in the repository.
React to a server-sent Socket.IO event in this app — keep the event names in step with the API, connect once for a signed-in user, join rooms, and update the RTK Query cache when the event arrives. Use when asked to "update this live", "show new X without refreshing", "listen for Y", or for presence, typing indicators, live counters and inbox badges.
Install
npx vskill@latest install aurostack-org/stacks/add-realtime-listenerSKILL.md
The same SKILL.md was published earlier as aurostack-org/stacks/add-realtime-listener.
Listen for a realtime event
The client is src/shared/api/socket.ts (connectSocket, getSocket, joinRoom, leaveRoom, disconnectSocket); the names are in src/shared/api/realtime-events.ts (ServerEvent, ClientEvent, FEED_ROOM, channelRoom).
- Names in lockstep. Add the event to
ServerEventwith exactly the
string the API's src/realtime/constants/index.ts uses. A mismatch is silent: the handler simply never fires.
- Connect once. If nothing connects yet, connect when a session exists
and disconnect on sign-out, in one place (a hook used by the signed-in shell): connectSocket(API_URL) (from @/lib/env) on sign-in, disconnectSocket() on sign-out. It sends the session cookie (withCredentials); the API authenticates the socket from it.
- Join what you listen to. The user's own room is joined by the server.
For a shared room, joinRoom(channelRoom(id)) when the screen mounts and leaveRoom when it unmounts. The server only admits rooms it allows.
- Update the cache, not local state:
``ts useEffect(() => { const socket = getSocket(); if (!socket) return; const onUpdated = (thing: ThingEntity) => { dispatch(thingsApi.util.updateQueryData('listThings', {}, (draft) => { const i = draft.list.findIndex((t) => t.id === thing.id); if (i >= 0) draft.list[i] = thing; })); }; socket.on(ServerEvent.ThingUpdated, onUpdated); return () => void socket.off(ServerEvent.ThingUpdated, onUpdated); }, [dispatch]); ``
When patching is awkward, dispatch(baseApi.util.invalidateTags(['Things'])) refetches instead. Always remove the listener on unmount.
- Check with two browser sessions: change the thing in one, watch it
update in the other.
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 repositoryCheckingtemplates/react-app/files/.claude/skills/add-realtime-listener/SKILL.md
Popularity
- 7-day trend score
- 5
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/aurostack-org/stacks/add-realtime-listener)