---
name: "rails-action-cable-websockets"
description: "Integrate full-duplex WebSocket communication into Rails applications using Action Cable."
metadata:
  author: "Ruby on Rails"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "setup action cable channel"
  - "stream_for action cable"
  - "broadcast from model rails"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Ruby on Rails Action Cable Real-Time WebSockets

Implements Rails Action Cable: Channel classes (ApplicationCable::Channel), stream_from / stream_for, client subscriptions in JavaScript (@rails/actioncable), broadcasting from models and jobs, and Redis adapter.

## When to Invoke
Invoke this skill whenever you need to:
- setup action cable channel
- stream_for action cable
- broadcast from model rails

## Execution SOP & Rules
1. Generate channel: bin/rails g channel Chat.
2. Implement subscription: class ChatChannel < ApplicationCable::Channel: def subscribed: stream_for Room.find(params[:id]).
3. Broadcast from model: ChatChannel.broadcast_to(room, { message: render_message(self) }).
4. Subscribe in JS: consumer.subscriptions.create({ channel: 'ChatChannel', id: roomId }, { received(data) { ... } }).

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
