rails-hotwire-realtime

marckohlbrugge/37signals-skills · updated Jun 11, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills install marckohlbrugge/37signals-skills/rails-hotwire-realtime
0 commentsdiscussion
summary

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.

skill.md
name
rails-hotwire-realtime
description
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.
disable-model-invocation
true

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).
how to use rails-hotwire-realtime

How to use rails-hotwire-realtime on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add rails-hotwire-realtime
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills install marckohlbrugge/37signals-skills/rails-hotwire-realtime

The skills CLI fetches rails-hotwire-realtime from GitHub repository marckohlbrugge/37signals-skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/rails-hotwire-realtime

Reload or restart Cursor to activate rails-hotwire-realtime. Access the skill through slash commands (e.g., /rails-hotwire-realtime) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.571 reviews
  • Pratham Ware· Dec 28, 2024

    rails-hotwire-realtime fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Liam Menon· Dec 28, 2024

    rails-hotwire-realtime fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Tariq Torres· Dec 28, 2024

    Useful defaults in rails-hotwire-realtime — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Kiara Yang· Dec 20, 2024

    I recommend rails-hotwire-realtime for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Kofi Zhang· Dec 20, 2024

    Solid pick for teams standardizing on skills: rails-hotwire-realtime is focused, and the summary matches what you get after install.

  • Olivia Iyer· Dec 16, 2024

    We added rails-hotwire-realtime from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Anaya Kim· Nov 23, 2024

    rails-hotwire-realtime fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Yash Thakker· Nov 19, 2024

    Registry listing for rails-hotwire-realtime matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Anaya Torres· Nov 19, 2024

    Registry listing for rails-hotwire-realtime matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Olivia Ghosh· Nov 19, 2024

    rails-hotwire-realtime is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

showing 1-10 of 71

1 / 8