Skip to content
CAI
Software that uses CAICheck a score

stimulusreflex/stimulus_reflex

59.3

Adequate · 19 September 2026

2.8k

lines of production code

Ruby

with JavaScript

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is the StimulusReflex gem, a Ruby library that enables real-time, server-driven DOM updates in Rails applications by integrating with ActionCable and CableReady. It provides a modular architecture for managing reflex lifecycle callbacks, HTML morphing, and client-side JavaScript state, while offering generators and installers to scaffold components and configure build tools. The codebase includes comprehensive test coverage for both its Ruby core and JavaScript client, ensuring reliable handling of declarative attributes, data serialization, and browser-based interactions.

How it got here

2018–2019 — StimulusReflex 3.5.5 modular refactor

12 changes.

This period focused on upgrading StimulusReflex to version 3.5.5 through a comprehensive architectural overhaul of both the Ruby gem and JavaScript client. The work involved restructuring the codebase into modular components, introducing a robust callback system, and implementing a new generator for scaffolding Reflexes. Extensive test suites were added to cover the new core functionality, ensuring stability for the refactored dual-language architecture.

2020 — StimulusReflex 3.5 architecture and configuration

7 changes.

This period focused on the architectural overhaul for StimulusReflex 3.5, introducing dedicated broadcaster classes for granular DOM morphing and relocating the core ActionCable channel to allow user customization. The work also modernized generator templates and initializers to support various JavaScript bundlers and expose new configuration options for CableReady and reflex behavior.

2022–2023 — StimulusReflex 3.5 installer and HTML parsing

6 changes.

This period focused on releasing the StimulusReflex 3.5 installer, which automates setup for various JavaScript build tools and configures Redis for development. Concurrently, the library improved HTML fragment parsing by integrating Nokogiri's HTML5 engine and added comprehensive test coverage for document handling.

Features

New StimulusReflex 3.5 installer task

A new \rails stimulus\_reflex:install\ task has been added to automate the setup of StimulusReflex and CableReady. This installer supports multiple JavaScript build tools including Webpacker, Shakapacker, esbuild, Vite, and Importmaps, and handles configuration for Action Cable, initializers, and example reflexes. It also provides a \restart\ subtask to reset the installation state and allows for granular control over installation steps.

lib/tasks · high confidence

New broadcaster implementations for page, selector, and no-op morphs

StimulusReflex now includes dedicated broadcaster classes for handling different morphing scopes: PageBroadcaster updates the entire page by re-rendering the controller response and matching selectors, SelectorBroadcaster handles granular DOM updates by morphing or replacing specific elements based on configuration, and NothingBroadcaster dispatches a 'morph-nothing' event for no-op scenarios. These components also introduce an Update helper that supports ActiveRecord integration for rendering collections and resolving DOM IDs, enabling more flexible and efficient partial page updates.

_lib/stimulus\reflex/broadcasters · high confidence

New generator for creating StimulusReflex components

A new \StimulusReflexGenerator\ has been added to allow users to scaffold Reflex and Stimulus controller files via the command line. The generator accepts a name and optional actions, and supports \--skip-reflex\ and \--skip-stimulus\ flags to control which files are generated. When generating an 'example' component, it also creates a sample controller, view, and route, and automatically manages the \fireworks-js\ importmap pinning.

_lib/generators/stimulus\reflex · high confidence

Architecture

Project scaffolding and build tooling overhaul

The repository has been restructured to support a dual Ruby/JavaScript codebase. Node.js version is pinned to 20.5.1 and Ruby to 3.3.6 via dedicated version files. JavaScript is now bundled using Rollup (configured in rollup.config.mjs) to produce UMD and ES modules for both npm distribution and the Rails asset pipeline, with a new web-test-runner configuration for browser tests. Development standards are enforced via Standard for Ruby and Prettier-Standard for JavaScript, with corresponding ignore files and a Rakefile that runs both Ruby and JavaScript test suites.

(repo-wide) · high confidence

Behavioural changes

Cleanup of legacy asset files

The legacy \stimulus\_reflex.js\ file has been removed from the vendor assets directory, and a placeholder \.keep\ file has been added to the \dist\ directory to maintain the folder structure.

app/assets, dist · low confidence

Installer now uses Redis for Action Cable and caching in development

The installation process in lib/install now automatically configures Action Cable to use the Redis adapter in development environments and switches the cache store to Redis if it was previously set to memory. It also recommends or installs the redis-session-store gem for session storage, ensuring that the development environment is properly set up to support real-time features without requiring manual configuration.

lib/install · high confidence

New utility modules for logging, sanity checks, and attribute building

StimulusReflex introduces a new \lib/stimulus\_reflex/utils\ directory containing four new modules: \AttributeBuilder\ for constructing data attributes, \Colorize\ for terminal output styling, \Logger\ for structured server-side logging per reflex action, and \SanityChecker\ for validating environment setup (such as caching and URL options) at startup. These utilities replace previous inline implementations, providing a cleaner, more maintainable structure for core framework operations.

_lib/stimulus\reflex/utils · high confidence

Refactored server-side architecture with new core components

The server-side implementation has been restructured into distinct, modular components to improve maintainability and clarity. A new \StimulusReflex::HTML::Document\ class now handles HTML parsing using Nokogiri, replacing previous parsing logic. Reflex invocation is now governed by a \ReflexMethodInvocationPolicy\ that validates method arguments against required and optional parameters. Data handling is centralized in \ReflexData\, which now supports deep merging of URL parameters and provides a typed \Element\ wrapper for accessing attributes and datasets. Additionally, a \Broadcaster\ base class standardizes how CableReady operations are dispatched for events like morph halts, forbids, and errors, while a \ReflexFactory\ manages the instantiation of reflex classes with proper validation.

_stimulus\reflex · high confidence

StimulusReflex 3.5.5 release with new callback system and configuration options

This update upgrades the gem to version 3.5.5 and introduces a comprehensive callback system (\before\_reflex\, \after\_reflex\, \around\_reflex\) with support for skipping and prepending callbacks. It adds a new \StimulusReflex::Configuration\ class allowing users to customize behavior such as \precompile\_assets\, \parent\_channel\, and \on\_failed\_sanity\_checks\. The release also includes a new \StimulusReflex::Installer\ for improved setup experience, a \StimulusReflex::Dataset\ class for handling DOM attributes, and a \VersionChecker\ module that detects and reports gem/JS version mismatches. Additionally, it introduces a \CableReadyChannels\ proxy for reflex broadcasting and a \ConcernEnhancer\ to improve method resolution for Reflex classes.

_lib/stimulus\reflex · high confidence

StimulusReflex JavaScript client is completely refactored into a modular architecture

The StimulusReflex JavaScript client has been rewritten from a single monolithic file into a modular structure with separate files for core logic (stimulus\_reflex.js, reflex.js), lifecycle management (lifecycle.js, callbacks.js), DOM scanning (scanner.js), and transport (transports/action\_cable.js). This refactoring introduces a new Reflex class to encapsulate state, a dedicated lifecycle system with stages like 'before', 'success', 'error', and 'finalize', and a new scanner that automatically wires up declarative data-reflex attributes. The client now supports a configurable schema for data attributes, explicit controller registration, and improved version mismatch detection between the gem and the JavaScript package. Additionally, it includes new features like data-reflex-dataset for extracting attributes from related DOM elements, isolation mode for tab-specific reflexes, and better handling of form serialization and piggybacked CableReady operations.

javascript · high confidence

StimulusReflex channel moved to app/channels and made configurable

The core ActionCable channel implementation has been relocated from the gem's internal directory to app/channels/stimulus\_reflex/channel.rb, allowing developers to subclass and customize the channel behavior directly. The new class inherits from a configurable parent channel (defaulting to ApplicationCable::Channel), enabling integration with existing authentication or connection logic. The channel now handles reflex invocation via a dedicated ReflexFactory and ReflexMethodInvocationPolicy, manages session commits, and provides detailed error logging for issues like missing routes or HTTP basic auth failures.

app/channels · high confidence

StimulusReflex library initialization and component loading

The main library entry point now explicitly requires and loads the core components of the StimulusReflex gem, including HTML document handling (Nokogiri), CableReady integration, configuration, callbacks, various broadcasters (page, selector, nothing), and utility classes. This ensures that all necessary modules are available when the gem is loaded, replacing the previous empty module structure with a comprehensive setup of internal dependencies.

lib · high confidence

Support for HTML5 fragment parsing via Nokogiri

The library now uses Nokogiri's HTML5 inference engine to parse HTML fragments, enabling proper handling of incomplete HTML5 structures. This change introduces a new DocumentFragment class that delegates to Nokogiri::HTML5::Inference, ensuring that partial HTML inputs are processed correctly without requiring full document wrappers.

_lib/stimulus\reflex/html · high confidence

Update bin scripts and console configuration

The bin directory now includes new helper scripts: \loc\ for counting lines of code, \rake\ as a Bundler-generated binstub, and \standardize\ to run linting and formatting tools. The \bin/console\ script has been updated to initialize StimulusReflex with a parent channel configuration, replacing the previous IRB-based setup that relied on pry.

bin · high confidence

Updated JavaScript generator templates for StimulusReflex 3.5

The JavaScript templates used by the StimulusReflex installer have been updated to support StimulusReflex 3.5 and modernize the setup for various bundlers. The new templates provide distinct entry points for Action Cable consumers and controller registration tailored to esbuild, Importmaps, Shakapacker, Vite, and Webpacker. Key behavioral changes include the introduction of an \isolate: true\ option in the StimulusReflex initialization configuration and the adoption of \@hotwired/stimulus\ as the base controller framework, replacing previous inheritance patterns.

_lib/generators/stimulus\reflex/templates/app/javascript · high confidence

Updated StimulusReflex 3.5 installer templates

The installer templates for StimulusReflex have been updated to version 3.5. This includes a new example controller and a comprehensive demo view that showcases CableReady features like stream subscriptions and updatable content, along with a new esbuild configuration script that supports build, watch, and live-reload modes for JavaScript assets.

_lib/generators/stimulus\_reflex/templates, lib/generators/stimulus\_reflex/templates/app/controllers, lib/generators/stimulus\reflex/templates/app/views · high confidence

Updated StimulusReflex and CableReady initializer templates with new configuration options

The generated initializer templates for StimulusReflex and CableReady have been updated to expose additional configuration options for users. The StimulusReflex template now includes commented-out settings for handling missing default URLs, customizing server-side logging formats, enabling Rack middleware support for page morphs, and overriding parent channels. The CableReady template adds options to configure the default debounce time for updatable callbacks, set a custom broadcast job queue, and define custom operations.

_lib/generators/stimulus\reflex/templates/config · high confidence

Updated StimulusReflex generator templates for version 3.5

The generator templates for new and base Reflex classes have been updated to align with StimulusReflex 3.5. The generated reflex template now includes documentation comments for the \tab\_id\ accessor and provides a concrete \Example\ implementation demonstrating session-based counting, CableReady broadcasting, and event dispatching. The \ApplicationReflex\ base class template has been refreshed to reflect the new inheritance structure (\StimulusReflex::Reflex\) and includes updated guidance on internationalization, current user delegation, and view helper access.

_lib/generators/stimulus\reflex/templates/app/reflexes · high confidence

Test coverage

Added comprehensive test suite for JavaScript client utilities; Added test coverage for StimulusReflex broadcasters; Added tests for HTML document and fragment parsing; Added tests for the StimulusReflex generator; Initial test suite for StimulusReflex core components.

Dependencies

StimulusReflex 3.5.5 dependency and manifest overhaul

The gem and its JavaScript package have been updated to version 3.5.5, introducing a comprehensive dependency upgrade and restructuring. The Ruby gem now requires Ruby 3.0+ and Rails 5.2+, explicitly adding dependencies on \actionpack\, \actionview\, \activesupport\, and \railties\ alongside \cable\_ready \~\> 5.0\, \nokogiri \~\> 1.0\, \nokogiri-html5-inference \~\> 0.3\, \rack \>= 2, \< 4\, \redis \>= 4.0, \< 6.0\, and \ostruct \~\> 0.6\. The JavaScript package.json now lists \@hotwired/stimulus ^3\, \@rails/actioncable ^6 \|\| ^7 \|\| ^8\, and \cable\_ready ^5.0.6\ as dependencies, with \rollup ^4.22.4\ and \vitepress ^1.0.0-beta.1\ as dev dependencies. The gemspec also adds a post-install message guiding users to run the installation rake task.

(dependencies) · high confidence

Housekeeping

Added USAGE documentation for the StimulusReflex generator

A new USAGE file has been added to the lib/generators directory, providing users with clear instructions on how to use the \rails generate stimulus\_reflex\ command. The documentation explains that the generator creates boilerplate files for controllers and reflexes without overwriting existing ones, and includes a link to the setup guide for getting started with StimulusReflex.

lib/generators · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 59.

Lenses

  • Code Health 67
  • Architecture 88
  • Maturity 61
  • Readiness 52
  • Security 70

Changes since last survey

  • 300 commits — 285 feature/other, 15 fixes

By area

  • (root) — 155 commits
  • lib/stimulus_reflex — 35 commits
  • .github/workflows — 14 commits
  • docs/hello-world — 13 commits
  • javascript/stimulus_reflex.js — 11 commits
  • docs/guide — 10 commits
  • javascript/test — 10 commits
  • lib/generators — 7 commits
  • lib/install — 4 commits
  • (repo) — 3 commits
  • app/channels — 3 commits
  • docs/appendices — 3 commits
  • docs/rtfm — 3 commits
  • javascript/attributes.js — 3 commits
  • javascript/utils.js — 3 commits
  • javascript/callbacks.js — 2 commits
  • javascript/scanner.js — 2 commits
  • test/broadcasters — 2 commits
  • .github/PULL_REQUEST_TEMPLATE.md — 1 commit
  • assets/stimulus-reflex-logo-dark.png — 1 commit

Notable commits

  • fix: Fix NPM versions for @hotwired/stimulus and @rails/actioncable
  • fix: Fix ReflexData parsing (#688)
  • fix: Fix Gemfile Pathname reference in development installer task
  • fix: Fix reflex_data keyword argument (#673)
  • fix: Fix broken docs link in README.md (#637)
  • fix: Fix comment (#537)
  • fix: Fix encoding in ReflexFactoryTest
  • fix: Fix exception in ActionCable channel due to reflexes overwriting each other's data (#663)
  • fix: Fix logger when :logging is nil (#573)
  • fix: Fix reference to StimulusReflex::VersionMismatchError (#665)
  • fix: Fix undefined package_json during Yarn install (#676)
  • fix: Temporarily fix OpenStruct with fix for class and method attributes (#569)
  • fix: fix gh action for standardrb (#554)
  • fix: fix: Deep merge url_params in ReflexData (#647)
  • fix: fix: Generator file name references (#644)
  • change: 3.5.0.pre4
  • change: 3.5.0.pre5
  • change: 3.5.0.pre6
  • change: Add Node 18 and remove Node 12 from JavaScript tests
  • change: Add Ruby 3.2 to Ruby matrix
  • …and 280 more

Architecture

  • 0 containers · 1 bounded contexts · 0 dependency edges (baseline)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

stimulusreflex/stimulus_reflex was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit fd071e888afc537f341f87e99aa4d4bd8c9d72e7 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.