Skip to content
Skills Library
Programming · Building & coding

stimulus-patterns

/stimulus-patterns

Write small, Turbo-safe, server-driven Stimulus controllers, and catch the mistakes that fail at runtime or leak. Use when adding a Stimulus controller, wiring elements that arrive via Turbo Streams/Frames, passing config from the server via the Values/Classes API, or debugging a controller that doesn't connect / a missing-target error / a listener that double-fires after Turbo navigation. Provides annotated templates and a controller linter.

Licence
MIT
Last repository change
02.07.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
5
Scripts
1
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 02.07.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • 1 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/lint_stimulus.sh

What it does and when to use it

Write small, Turbo-safe, server-driven Stimulus controllers, and catch the mistakes that fail at runtime or leak. Use when adding a Stimulus controller, wiring elements that arrive via Turbo Streams/Frames, passing config from the server via the Values/Classes API, or debugging a controller that doesn't connect / a missing-target error / a listener that double-fires after Turbo navigation. Provides annotated templates and a controller linter.

Original author description

Write small, Turbo-safe, server-driven Stimulus controllers, and catch the mistakes that fail at runtime or leak. Use when adding a Stimulus controller, wiring elements that arrive via Turbo Streams/Frames, passing config from the server via the Values/Classes API, or debugging a controller that doesn't connect / a missing-target error / a listener that double-fires after Turbo navigation. Provides annotated templates and a controller linter.

How it works

  1. When to use
  2. The patterns (and their footguns)
  3. Start a controller
  4. Lint
Original SKILL.md headings · 52 lines, 288 words
SKILL.md preview
---
name: stimulus-patterns
description: Write small, Turbo-safe, server-driven Stimulus controllers, and catch the mistakes that fail at runtime or leak. Use when adding a Stimulus controller, wiring elements that arrive via Turbo Streams/Frames, passing config from the server via the Values/Classes API, or debugging a controller that doesn't connect / a missing-target error / a listener that double-fires after Turbo navigation. Provides annotated templates and a controller linter.
---

# Stimulus patterns

Keep controllers small, Turbo-safe, and driven by the server. Full patterns:
[`references/stimulus-guide.md`](references/stimulus-guide.md) (grounded in the Piazza controllers).

## When to use

- Adding a Stimulus controller.
- Wiring elements that arrive later (Turbo Stream append, frame load) — use the
  `xTargetConnected` self-wiring callback instead of re-querying.
- Passing data/CSS from the server (Values/Classes API).
- Debugging: a controller that never connects, a `this.fooTarget` undefined error, or
  a listener/timer that double-fires after navigation.

## The patterns (and their footguns)

1. **Small, single-purpose controllers** — many tiny ones over one big one.
2. **Self-wiring** via `xTargetConnected(target)` — fires per element as each
   connects, including streamed-in ones (`templates/self_wiring_controller.js.tmpl`).
3. **Values/Classes API** — push config + CSS class names from ERB
   (`this.fooValue`, `this.fooClasses`); keep styling in the view.
4. **State machine + delegate** — controller toggles DOM state; a plain helper does
   SDK/transport plumbing and calls back.
5. **Clone a server `<template>`** — stamp repeated markup instead of building HTML
   in JS.
6. **Clean up in `disconnect()`** — undo `addEventListener`(window/document),
   `setInterval`, observers, or native UI you rendered, or it leaks and double-fires
   after Turbo navigation. `data-action` listeners are auto-managed; manual ones aren't.

## Start a controller

```bash
sed 's/__NAME__/your-name/g' templates/controller.js.tmpl > your_name_controller.js
# or templates/self_wiring_controller.js.tmpl for the streamed-in case
```
Register it (manifest `index.js` via `bin/rails stimulus:manifest:update`, or
stimulus-loading) — an unregistered controller never connects.

## Lint

```bash
scripts/lint_stimulus.sh path/to/rails-app      # or a controllers/ dir
```

Flags: `this.xTarget`/`xValue`/`xClass` used but not declared in `static
targets`/`values`/`classes` (runtime errors); `connect()` that registers a
listener/timer/observer with **no `disconnect()`** (leak/double-fire); a controller
file missing from the `index.js` manifest (never connects). Heuristic regex scan
(needs `ruby`); names its ceiling. Verified: clean on all 7 Piazza controllers,
flags a synthetic broken one on every check.
Files in this package (5)
  • SKILL.md 3 KB
  • references/stimulus-guide.md 4 KB
  • scripts/lint_stimulus.sh 4 KB
  • templates/controller.js.tmpl 1 KB
  • templates/self_wiring_controller.js.tmpl 1 KB

Versions

RepositoryScoreLicence
This page · davidteren/hotwire-codex-skills100MIT
ThibautBaissac/rails_ai_agents100MIT

Database snapshot: 13.11.2026 · package version e452586036ba (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100rails-cto-stimulus
    How to write Stimulus controllers for this Rails 8 / Hotwire project. Use when creating, modifying, or debugging Stimulus controllers, wiring controllers to ERB views, or integrating JavaScript behavior with Turbo Streams and Frames. Also use when the user mentions "stimulus",…
  • 100better-stimulus
    Apply opinionated StimulusJS best practices from betterstimulus.com. Use this skill whenever writing, reviewing, debugging, or refactoring Stimulus controllers. Triggers when user asks to write, fix, or review a Stimulus controller, asks about data-controller, data-action,…
  • 100turbo-patterns
    Creates Turbo Streams, Turbo Frames, and morphing patterns for real-time UI updates. Use when adding real-time updates, partial page rendering, form submissions, or broadcasting. WHEN NOT: For Stimulus JavaScript controllers (see stimulus-patterns skill). For general view…
  • 100rails-hotwire
    Ruby on Rails Hotwire best practices for building interactive applications with Turbo Drive, Turbo Frames, Turbo Streams, Turbo 8 morphing, and Stimulus controllers. This skill should be used when writing, reviewing, or refactoring Hotwire-powered Rails code to ensure optimal…
  • 100hotwire-patterns
    Hotwire in Rails: Turbo Frames, Streams, Stimulus, Action Cable. Triggers: \"live update no reload\", \"broadcast model\", \"stimulus controller\". Do NOT use for: native mobile, jobs.
  • 85rails-ai:hotwire
    Use when adding interactivity to Rails views - Hotwire Turbo (Drive, Frames, Streams, Morph) and Stimulus controllers

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.