Logo di Rails Hotwire Realtime

Rails Hotwire Realtime

Community
marckohlbrugge
rails-hotwire-realtime

Apply Hotwire, Turbo, Stimulus, and ActionCable best practices for real-time Rails interfaces. Use when building Turbo Streams/Frames, Stimulus interactions, or websocket-driven updates.

Add to TypingMind

Panoramica

Pubblicato damarckohlbrugge
Repository37signals-skills
Nome della skillrails-hotwire-realtime
Stelle
724
Fork
56
File inclusi
Solo istruzioni
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da marckohlbrugge su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Rails Hotwire Realtime in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/marckohlbrugge/37signals-skills/tree/main/skills/rails-hotwire-realtime
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/marckohlbrugge/37signals-skills.git /tmp/37signals-skills
mkdir -p .claude/skills
cp -r /tmp/37signals-skills/skills/rails-hotwire-realtime .claude/skills/rails-hotwire-realtime
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Rails Hotwire Realtime in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Rails Hotwire Realtime non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Rails Hotwire Realtime non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Rails Hotwire + Realtime

Use for Turbo/Stimulus/ActionCable architecture and reviews. Patterns from Campfire (cable-heavy chat) and Fizzy (streams-only kanban).

Choose the Right Realtime Architecture

Two proven 37signals topologies:

  • Streams-only (Fizzy): no custom ActionCable channels at all. turbo_stream_from, broadcasts_refreshes + morph, lazy frames with ETags. Default to this for CRUD-ish apps.
  • Cable-augmented (Campfire): custom channels only for lightweight JSON signals (presence, typing, unread pings) where rendering HTML server-side would be wasteful. Durable DOM state still goes through Turbo Streams.

Rule of thumb: Turbo Streams for anything that changes the DOM; bare ActionCable only for tiny ephemeral signals.

Turbo Defaults

  • Prefer server-rendered partial updates over heavy client-side state systems.
  • Set global morph refresh in the layout: turbo_refreshes_with method: :morph, scroll: :preserve.
  • Use Turbo Streams for targeted updates; one action can render a multi-target stream template that updates every affected region atomically (source column + destination + detail pane).
  • Lazy-load expensive sections with turbo_frame_tag ..., src:, loading: :lazy and give the frame endpoint its own fresh_when ETag. Extract frequently-changing fragments into their own frames so they don't bust the parent cache.
  • Use data-turbo-permanent for elements that must survive navigation/morph (footer trays, in-progress editors).
  • Block morph from clobbering client-owned state (e.g. localStorage-driven collapsed columns) via turbo:before-morph-attribute + preventDefault().
  • Exempt realtime-heavy pages from Turbo's page cache (turbo_exempts_page_from_cache); rely on frame-level ETags instead.
  • Optimistic UI without a JS framework: server-render a <template> partial with $placeholder$ tokens; client clones it with a generated ID before submit; the stream response replaces it.

Broadcast Patterns

  • Keep broadcast logic on models (Message::Broadcasts concern with broadcast_create), not in controllers.
  • Scope every stream name by tenant/user: [board.account, :all_boards], [user, :notifications] — stream names are isolation boundaries.
  • Dual streams when needed: broadcasts_refreshes for direct subscribers plus broadcasts_refreshes_to ->(r) { [r.account, :aggregate_view] } for account-wide views.
  • Gate noisy secondary broadcasts on meaningful change: set a flag in before_update when preview-relevant fields change; broadcast if: :preview_changed?.
  • Suppress broadcasts in background jobs that incidentally touch records (Model.suppressing_turbo_broadcasts), e.g. around ActiveStorage analysis.
  • Fan-out efficiently: render_to_string once, then broadcast_replace_to user, ..., html: per recipient.
  • Use broadcast_*_later async variants when synchronous broadcasting hurts request latency.
  • Broadcast-rendered partials lack request context: wrap attachment/url helpers (broadcast_image_tag pattern) so URLs resolve.

Reconnect & Catch-Up

  • Catch-up over reload: on reconnect/tab-return, fetch a turbo-stream diff (?since=<epoch_ms>); server appends new records and replaces updated ones.
  • An empty HeartbeatChannel gives reliable connected/disconnected callbacks for triggering catch-up and a debounced offline UI.
  • Guard Stimulus connect() with a turbo-preview check so back/forward cache previews don't open sockets or request permissions.

Stimulus Defaults

  • Keep controllers single-purpose; compose multiple small controllers on one element.
  • Prefer targets/values over ad-hoc selectors and attribute parsing.
  • Always clean up timers/listeners/subscriptions in disconnect. For cable subscriptions, defer unsubscribe one animation frame and skip if the element reconnected (morph churn).
  • Use event dispatch between controllers (or outlets) instead of tight coupling.
  • For complex surfaces, compose data-controller/data-action/target wiring in Ruby helpers (message_area_tag) so views stay declarative and the contract lives in one place.
  • Read page context from <meta> tags into a tiny window.Current object rather than inlining JSON.
  • Will elements added later via broadcast get the behavior? Design controllers to handle dynamically-inserted children (e.g. targetConnected callbacks).

Scroll & Interaction Contracts

  • Preserve scroll declaratively: pass a custom attribute (maintain_scroll: true) on broadcasts and handle it once in a turbo:before-stream-render listener.
  • Serialize competing scroll mutations through a promise queue when streams and optimistic inserts race.
  • Strip a stream target's id on turbo:submit-start so background broadcasts can't race the form's own stream response.
  • Infinite feeds: IntersectionObserver sentinels in turbo-stream pagination (remove trigger, append batch, append new sentinel); cap DOM size; only autoscroll when the user is at the latest page.

ActionCable / Connection Safety

  • Authenticate in Connection#connect with the same identity resolution as HTTP; scope channel subscriptions through ownership (current_user.rooms.find_by(id: params[:room_id])).
  • Disconnect deactivated/banned users remotely: ActionCable.server.remote_connections.where(current_user: user).disconnect.
  • Presence: reference-count connections with a TTL (connections counter + connected_at, 60s freshness scope) to survive multi-tab and reconnects; debounce visibility changes (~5s) to avoid flicker.
  • Under path-based tenancy, emit the cable URL from request.script_name via a custom meta tag helper.

Caching + Realtime

  • Keep cache keys aligned with what affects output (record, user, timezone, filter state); use touch: true chains so child edits invalidate parents.
  • Personalize cached fragments client-side: render data-creator-id, let a Stimulus controller compare against Current.user and toggle visibility — don't break fragment caching for per-user toggles.
  • Avoid HTTP-caching form pages where token freshness is critical.

Web Push (when applicable)

  • Push only to disconnected users, excluding the actor; respect per-user involvement levels (everything vs mentions-only).
  • Deliver via a thread pool with persistent HTTP connections, resolving all AR data before posting to threads; invalidate expired subscriptions async.
  • Clean up the push subscription client-side on logout.

Testing

  • Model broadcasts: assert_turbo_stream_broadcasts([user, :notifications], count: 1) { ... } and assert_no_turbo_stream_broadcasts for negatives.
  • Controller responses: as: :turbo_stream + assert_turbo_stream action: :replace, target: dom_id(...).
  • For DOM-level assertions on broadcasts, a small helper reading ActionCable.server.pubsub.broadcasts + assert_select covers it.
  • System tests: using_session("OtherUser") for multi-user realtime, and wait for turbo-cable-stream-source[connected] before asserting.

Red Flags

  • Duplicate stream IDs/targets causing unstable updates.
  • Broadcast channels or stream names that are not tenant/user-scoped.
  • HTML rendering inside bare ActionCable channels (use Turbo Streams).
  • Stimulus controllers leaking timers/listeners after navigation.
  • Replacing full pages for small interactions that should be streamed.
  • Custom ActionCable channels for things turbo_stream_from already does.
  • Morph refreshes destroying in-progress user input (missing data-turbo-permanent).

Domande frequenti

Cosa fa la skill IA Rails Hotwire Realtime?

Apply Hotwire, Turbo, Stimulus, and ActionCable best practices for real-time Rails interfaces. Use when building Turbo Streams/Frames, Stimulus interactions, or websocket-driven updates.

Perché usare Rails Hotwire Realtime su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Rails Hotwire Realtime è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Rails Hotwire Realtime in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/marckohlbrugge/37signals-skills/tree/main/skills/rails-hotwire-realtime. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Rails Hotwire Realtime?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Rails Hotwire Realtime?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Rails Hotwire Realtime: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Rails Hotwire Realtime è gratuita?

È pubblicata su GitHub da marckohlbrugge. Consulta il repository per i termini di licenza. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇