Skip to content

rails-cto-erb

The ERB template formatting skill. Keeps view files scannable.

What it does

ERB files are the most-read files in the codebase — developers scan them constantly to understand layout, wiring, and data flow. Every formatting decision in this skill optimizes for scannability: a developer glancing at a file should immediately see the structure, the Stimulus wiring, and the data being rendered.

The skill enforces:

  • Attribute alignment. Multi-attribute tags get their attributes stacked and aligned via the Herb align-attributes rewriter.
  • No inline variables. No <% variable = ... %> in templates. Data goes on the controller; display logic goes on the model or helper.
  • No inline styles. The no-inline-styles Herb rule flags any style="..." attribute.
  • Consistent indentation. Two-space indents, no tabs, no trailing whitespace.
  • Partial-first composition. When a template gets long, extract partials or ViewComponents rather than letting the file grow.
  • Clear Stimulus wiring. data-controller, data-action, and data-*-target attributes are formatted so they stand out.

When it triggers

  • Creating or modifying any .html.erb file — view, partial, layout, or ViewComponent template
  • When you mention erb, views, partials, templates, html formatting, or attribute alignment

This skill is mandatory after every .html.erb change. The CLAUDE.md block that rails-cto init installs enforces it — the task isn't considered done until the ERB skill has run.

Example

erb
<%# Before %>
<%= form_with model: @post, data: { controller: "autosave", autosave_url_value: autosave_post_path(@post), turbo_frame: "post_form" } do |form| %>

<%# After (attributes aligned, sub-tags unpacked) %>
<%= form_with model: @post,
              data: {
                controller: "autosave",
                autosave_url_value: autosave_post_path(@post),
                turbo_frame: "post_form"
              } do |form| %>

View source

skills/rails-cto-erb/SKILL.md on GitHub →

Released under the MIT License.