agentsclimarketplace

Apply stack conventions

Skill igmarin/rails-agent-skills/skills/code-quality/apply-stack-conventions

This is my personal configuration of skills as a Ruby on Rails Dev

Install
npx -y skills add igmarin/rails-agent-skills --skill apply-stack-conventions

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Use when writing new Rails code (Ruby on Rails) for the PostgreSQL + Hotwire + Tailwind stack, including TDD (test-driven development), write-tests-first, or red-green-refactor workflows — must write specs and validate them RED BEFORE implementation, verify they pass GREEN after, show spec file content (not just spec path), include a Tests-first proof before implementation section showing actual spec code, the run command (bundle exec rspec spec/[path]_spec.rb), and the Observed RED output and Observed GREEN output labels, keeping steps testable in isolation. MVC structure, ActiveRecord queries, Turbo Frames/Streams, Stimulus controllers, and Tailwind patterns. Not for general Rails design principles — scoped to this specific stack.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

7.3 KB, as published. Nobody here has run it

Apply Stack Conventions

Quick Reference

Stack areaDefault convention
Rails MVCThin controllers; move non-trivial business logic into service objects
PostgreSQLAvoid N+1s with includes; use database constraints for integrity
HotwirePrefer Turbo Frames/Streams before Stimulus; only reach for Stimulus when Turbo cannot handle the interactivity
TailwindUse utilities in views; extract repeated UI into partials/components
AuthApply Devise authentication and Pundit authorization to every action that touches access-controlled resources

HARD-GATE: TDD Cycle

All new code must have its test written and validated before implementation. Follow this exact cycle for every layer:

  1. Write the spec file — show the full file content, not only the path
  2. Run: bundle exec rspec spec/[path]_spec.rb — verify it FAILS (Observed RED output)
  3. Write the implementation code
  4. Re-run the same command — verify it PASSES (Observed GREEN output)
  5. Refactor if needed, keeping tests green

CRITICAL: Execute all test commands using your shell/terminal tools. Do not fabricate, mock, or simulate terminal output. Copy-paste the actual observed output. If the environment does not support running tests, stop and tell the user — do not proceed to implementation without verified RED output.

Red-Green Cycle Example

Spec file — spec/models/order_spec.rb

require 'rails_helper'

RSpec.describe Order, type: :model do
  describe 'validations' do
    it 'is invalid without a total' do
      order = build(:order, total: nil)
      expect(order).not_to be_valid
      expect(order.errors[:total]).to include("can't be blank")
    end
  end
end

Run command

bundle exec rspec spec/models/order_spec.rb

Observed RED output — paste actual terminal output here (expect failure)

Model implementation — app/models/order.rb

class Order < ApplicationRecord
  validates :total, presence: true
end

Observed GREEN output — paste actual terminal output here (expect pass)

Core Process

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 apply-code-conventions.

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 create-service-object)
  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. In the final artifact, include a Layer isolation section naming the focused spec or check for model/query, service, controller/request, view/Turbo, Stimulus, and Tailwind. If a layer is not changed, mark it "not applicable"; do not silently omit any layer.

Service Object Pattern

Controllers delegate to a service via .call; the service returns a result hash. See create-service-object and assets/snippets/service_object.rb for the full pattern and implementation details.

# app/controllers/orders_controller.rb
def create
  result = CreateOrderService.call(order_params)
  if result[:success]
    redirect_to result[:record], notice: 'Order created.'
  else
    render :new, status: :unprocessable_entity
  end
end

For eager loading patterns and N+1 fixes, see the Extended Resources section below.

Pitfalls to Avoid

IssueCorrect approach
Controller action with 15+ lines of business logicExtract to a service object using the .call pattern
Accessing a protected resource without an authorisation checkApply a Pundit policy on every action that touches access-controlled data

Output Style

Every response must include these sections in order:

  1. Stack decisions — which Rails, PostgreSQL, Hotwire, Stimulus, Tailwind, auth, and service-object conventions apply.
  2. Tests-first proof before implementation — follow the HARD-GATE cycle per layer (spec file content → RED output → implementation → GREEN output).
  3. Layer isolation — focused spec/check for each changed layer; mark unchanged layers "not applicable".
  4. Layered implementation — separate model/query, service, controller, view, Stimulus, and Tailwind changes.
  5. Performance and security checks — N+1 prevention, authorization policy use, unsafe params/content handling.

Extended Resources (Progressive Disclosure)

Load these files only when their specific content is needed:

Integration

SkillWhen to chain
apply-code-conventionsFor design principles, structured logging, and path-specific rules
code-reviewWhen reviewing existing code against these conventions
create-service-objectWhen extracting business logic into service objects
write-testsFor testing conventions and full red/green/refactor TDD cycle
review-architectureFor structural review beyond conventions

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.