/kenji:backend-realtimefrom kenji skills
Implements real-time features using WebSockets, Supabase Realtime, or Server-Sent Events. Useful for live updates, chat, notifications, presence, and collaborative features.
Ships in kenji skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Degree of freedom: MIXED. Which transport and event [HIGH freedom];
existing-subscription probes and unmount cleanup [LOW freedom — run exactly].
Observe: chat mounts
useRealtimeMessagestwice; no untrack on leave;package.jsonalready has@supabase/supabase-js. Interpret: duplicate INSERT listeners; leftover presence. Classify: one channel hook with unmount cleanup; reuse Supabase Realtime — do not add Socket.io. Verify: onepostgres_changessubscription;removeChannelon unmount; no second socket lib.
removeChannel / closedebug-fe-be-integration; queue/job instead of live push → backend-patternsImplement live, collaborative features using WebSockets, Supabase Realtime, and Server-Sent Events.
Code examples assume a Next.js App Router + Supabase stack (
@/lib/supabase/client,'use client'). Adapt import paths and row types to the detected stack.
Before implementing ANY real-time feature, verify:
cat package.json | grep -i "socket\|realtime\|pusher\|ably"
rg "supabase.*channel|useSubscription|WebSocket" --type ts --type tsx
rg "on\('INSERT'\|on\('UPDATE'\|subscribe\(" --type ts
ls -la src/hooks/use*Realtime* src/lib/realtime* 2>/dev/null
rg "createClient|supabaseUrl" --type ts -l
grep -oh "SUPABASE_[A-Z_]*" .env* 2>/dev/null | sort -u # names only — never print values
Why: Real-time connections are stateful. Don't create duplicate subscriptions.
The canonical useRealtimeMessages hook (initial fetch + INSERT/DELETE
subscription with unmount cleanup) is in
references/patterns.md.
useEffect(() => {
const channel = supabase
.channel(`room:${roomId}`)
.on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'messages', filter: `room_id=eq.${roomId}` },
(payload) => setMessages((prev) => [...prev, payload.new as Message]))
.subscribe()
return () => { supabase.removeChannel(channel) }
}, [roomId, supabase])
presence:${roomId}); channel.track(currentUser) only after status === 'SUBSCRIBED'.presenceState() on the sync event; join/leave are for side effects only.channel.untrack() then supabase.removeChannel(channel).Full usePresence hook: references/patterns.md §Presence.
useRef; register .on('broadcast', { event }) handlers once, then .subscribe().channel.send({ type: 'broadcast', event, payload }); broadcast is ephemeral, never a source of truth.postgres_changes for anything that must persist.Full useBroadcast hook and collaborative-cursor usage: references/patterns.md §Broadcast.
useQuery as the data source; the realtime channel only calls queryClient.invalidateQueries({ queryKey }).postgres_changes with event: '*' on the table (optional filter); remove the channel on unmount.useRealtimeQuery(queryKey, queryFn, table, filter?), so every list gets the same behaviour.Full useRealtimeQuery hook: references/patterns.md §TanStack Query + Real-time.
useOptimistic(initial, reducer) plus useTransition; add the optimistic row with pending: true and a crypto.randomUUID() id, then await the Server Action.isPending.const [optimisticMessages, addOptimisticMessage] = useOptimistic(
initialMessages, (state, msg: Message) => [...state, msg]
)
startTransition(async () => {
addOptimisticMessage({ id: crypto.randomUUID(), content, pending: true, /* ... */ })
await addMessage(content) // Server Action
})
Full Chat component: references/patterns.md §Optimistic Updates.
ReadableStream; write data: ${JSON.stringify(x)}\n\n frames with TextEncoder.text/event-stream, Cache-Control: no-cache, Connection: keep-alive; heartbeat every 30 s.request.signal abort (clear timers, controller.close()).new EventSource(url); close in the effect cleanup and on onerror, then reconnect with backoff.Full route handler and useSSE hook: references/patterns.md §Server-Sent Events.
{ event: 'typing', payload: { userId } } on keystroke; ignore your own id on receipt.typingUsers and drop them after 3 s of silence; debounce sends with a timeoutRef.Full useTypingIndicator hook: references/patterns.md §Typing Indicators.
After implementing real-time features:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
realtime, websocket, supabase-realtime, server-sent-events, live-updates, chat
npx claudepluginhub kensaurus/skills --plugin kenji162 skills in this plugin
/audit-accessibilityWCAG 2.2 AA audit via playwright-cli: axe-core, keyboard, contrast, target size, focus, ARIA. Use when "audit accessibility", "check a11y", "WCAG audit", "check keyboard nav", or "test screen reader".
/audit-agent-speedMeasure and fix a slow coding-agent setup: status line, hooks, instruction bloat, effort, worktree pile-up, antivirus and indexer scans. Use when "Claude is slow" or "CPU is pinned". App speed → audit-performance.
/audit-analyticsRead-only audit of product-analytics events (PostHog, Amplitude, Mixpanel, GA4): taxonomy, funnels, consent-gated firing, dead or duplicate events. Use when "audit our analytics", "are we tracking the right events", or "funnel instrumentation".
Other plugins' skills for the same job