skillZs
★ LIVE SKILL TAGS ★
>>> LIVE SKILLS INDEX <<<
* OPEN SOURCE *
NO LOGIN, NO TRACKING
※ REAL INSTALL DATA ※
← back to all skills
midudev/autoskills55 installs

rails-stack-conventions

Use when writing new Rails code for a project using the PostgreSQL + Hotwire + Tailwind CSS stack. Covers stack-specific patterns only: MVC structure, ActiveRecord query conventions, Turbo Frames/Streams wiring, Stimulus controllers, and Tailwind component patterns. Not for general Rails design principles — this skill is scoped to what changes based on this specific technology stack.

How do I install this agent skill?

npx skills add https://github.com/midudev/autoskills --skill rails-stack-conventions
view source ↗

Is this agent skill safe to install?

  • Gen Agent Trust Hubpass

    This skill provides standard coding conventions and snippets for a Ruby on Rails stack using PostgreSQL, Hotwire, and Tailwind CSS. It promotes secure development practices such as using authentication (Devise) and authorization (Pundit) libraries, and performance-oriented patterns like avoiding N+1 queries. No security issues were detected.

  • Socketpass

    No alerts

  • Snykpass

    Risk: LOW · No issues

What does this agent skill do?

Rails Stack Conventions

When writing or generating code for this project, follow these conventions. Stack: Ruby on Rails, PostgreSQL, Hotwire (Turbo + Stimulus), Tailwind CSS.

Style: If the project uses a linter, treat it as the source of truth for formatting. For cross-cutting design principles (DRY, YAGNI, structured logging, rules by directory), use rails-code-conventions.

HARD-GATE: Tests Gate Implementation

ALL new code MUST have its test written and validated BEFORE implementation.
  1. Write the spec: bundle exec rspec spec/[path]_spec.rb
  2. Verify it FAILS — output must show the feature does not exist yet
  3. Write the implementation code
  4. Verify it PASSES — run the same spec and confirm green
  5. Refactor if needed, keeping tests green
See rspec-best-practices for the full gate cycle.

Feature Development Workflow

For a typical feature, compose stack patterns in this order:

  1. Model — add validations, associations, scopes; eager-load with includes for any association used in loops
  2. Service object — extract non-trivial business logic from the controller (see ruby-service-objects)
  3. Controller — keep actions thin; delegate to services; respond with turbo_stream and html formats
  4. View / Turbo wiring — wrap dynamic sections in <turbo-frame> tags; broadcast turbo_stream responses from the controller
  5. Stimulus — add a controller only when client-side interactivity cannot be handled by Turbo alone
  6. Tailwind — apply utility classes to the view; extract repeated patterns into partials or Stimulus targets

Each step should remain testable in isolation before wiring to the next layer.

Key Code Patterns

Hotwire: Turbo Frames

<%# Wrap a section to be replaced without a full page reload %>
<turbo-frame id="order-<%= @order.id %>">
  <%= render "orders/details", order: @order %>
</turbo-frame>

<%# Link that targets only this frame %>
<%= link_to "Edit", edit_order_path(@order), data: { turbo_frame: "order-#{@order.id}" } %>

Hotwire: Turbo Streams (broadcast from controller)

respond_to do |format|
  format.turbo_stream do
    render turbo_stream: turbo_stream.replace(
      "order_#{@order.id}",
      partial: "orders/order",
      locals: { order: @order }
    )
  end
  format.html { redirect_to @order }
end

Avoiding N+1 — Eager Loading

# BAD — triggers one query per order
@orders = Order.where(user: current_user)
@orders.each { |o| o.line_items.count }

# GOOD — single JOIN via includes
@orders = Order.includes(:line_items).where(user: current_user)

Service Object (complex business logic out of the controller)

# Controller stays thin — delegate to service
result = Orders::CreateOrder.call(user: current_user, params: order_params)
if result[:success]
  redirect_to result[:order], notice: "Order created"
else
  @order = Order.new(order_params)
  render :new, status: :unprocessable_entity
end

See ruby-service-objects for the full .call pattern and response format.

Security

This project uses Devise for authentication and Pundit for authorization. Apply these on every feature that introduces access-controlled resources.

Pitfalls to Avoid

IssueCorrect approach
Business logic in viewsUse helpers, presenters, or Stimulus controllers
N+1 queries in loopsEager load with includes before the loop
Skipping FactoryBot for "quick" testsFixtures are brittle — always use factories
Controller action with 15+ lines of business logicExtract to a service object
Model with no validations on required fieldsAdd presence/format validations
View with 10+ lines of embedded Ruby conditionalsMove logic to a presenter or partial
Hardcoded strings that belong in I18nUse t() helpers

Integration

SkillWhen to chain
rails-code-conventionsFor design principles, structured logging, and path-specific rules
rails-code-reviewWhen reviewing existing code against these conventions
ruby-service-objectsWhen extracting business logic into service objects
rspec-best-practicesFor testing conventions and full red/green/refactor TDD cycle
rails-architecture-reviewFor structural review beyond conventions

Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.

<a href="https://skillzs.dev/skills/midudev/autoskills/rails-stack-conventions">View rails-stack-conventions on skillZs</a>