ruby-on-rails
<essential_principles>
Vanilla Rails Philosophy
"No one paradigm" - Pragmatism over purity. Rails provides everything needed without complex architectural patterns.
1. Rich Domain Models Over Service Objects
Business logic lives in models. Use nested operation classes for complex workflows:
# Model method delegates to nested class
class Quote < ApplicationRecord
def create_purchase_order
PurchaseOrderCreation.new(self).call
end
end
# app/models/quote/purchase_order_creation.rb
class Quote::PurchaseOrderCreation
def initialize(quote) = @quote = quote
def call
ApplicationRecord.transaction do
po = create_purchase_order
update_quote_status
po
end
end
end
2. Concerns for Cohesive Traits
Concerns represent domain concepts, not junk drawers:
module Closable
extend ActiveSupport::Concern
included do
scope :open, -> { where(closed_at: nil) }
scope :closed, -> { where.not(closed_at: nil) }
end
def close! = update!(closed_at: Time.current)
def closed? = closed_at.present?
def open? = !closed?
end
3. Thin Controllers, Fat Models
Controllers coordinate; models contain logic. Use filter chaining:
def index
resources = Resource.all
.then(&method(:apply_scoping))
.then(&method(:filter_by_status))
.then(&method(:apply_ordering))
render json: ResourceBlueprint.render(resources)
end
4. Current Pattern for Request Context
Use Current for cross-cutting concerns:
class Current < ActiveSupport::CurrentAttributes
attribute :user, :organization
end
# Set once in controller, use anywhere
Current.organization
</essential_principles>
- Build a new feature/endpoint
- Debug an existing issue
- Write/run tests
- Optimize performance
- Refactor code
- Something else
Then read the matching workflow from workflows/ and follow it.
<verification_loop>
After Every Change
# 1. Syntax check
ruby -c app/models/changed_file.rb
# 2. Run tests
bin/rails test test/models/changed_file_test.rb
# 3. Lint
bundle exec rubocop app/models/changed_file.rb -a
Report: "Syntax: OK | Tests: X pass | Lint: clean" </verification_loop>
<reference_index>
Domain Knowledge
All in references/:
Architecture: architecture.md Models: models.md Controllers: controllers.md Serialization: blueprints.md Validations: validations-callbacks.md Background Jobs: background-jobs.md Performance: performance.md Testing: testing.md Multi-Tenant: multi-tenant.md Anti-Patterns: anti-patterns.md </reference_index>
<workflows_index>
Workflows
All in workflows/:
| File | Purpose |
|---|---|
| build-feature.md | Create new feature/endpoint from scratch |
| debug.md | Find and fix bugs |
| write-tests.md | Write and run tests |
| optimize-performance.md | Profile and speed up |
| refactor.md | Restructure code following patterns |
| </workflows_index> |
More from faqndo97/ai-skills
kamal-deployment
Deploy containerized applications (especially Rails) to VPS using Kamal 2. Covers deploy.yml configuration, accessories (PostgreSQL, Redis, Sidekiq), SSL/TLS, secrets management, CI/CD with GitHub Actions, database backups, server hardening, debugging, and scaling. Use when setting up Kamal, configuring deployments, troubleshooting deploy issues, or managing production infrastructure with Kamal.
31stimulus
Build Stimulus controllers from scratch through production. Full lifecycle - create, debug, test, optimize, integrate with Turbo. Covers targets, values, actions, outlets, and UI patterns.
22ruby-llm
Build AI-powered Ruby applications with RubyLLM. Full lifecycle - chat, tools, streaming, Rails integration, embeddings, and production deployment. Covers all providers (OpenAI, Anthropic, Gemini, etc.) with one unified API.
20noticed
Build Rails notifications with the noticed gem. Full lifecycle - create notifiers, configure delivery methods (email, Slack, push, SMS, ActionCable), debug, and test. Covers individual and bulk delivery patterns.
15shadcn-ui
Build production-ready React/Next.js UIs with shadcn/ui components. Full lifecycle - install, customize, compose, debug, optimize. Covers components, forms, tables, theming, animations, and hooks.
14inertia-rails
Build Rails + Inertia.js applications from scratch through production. Full lifecycle - setup, pages, forms, validation, shared data, authentication. Covers React/Vue/Svelte frontends with Vite bundling. Includes cookbook for shadcn/ui, modals, meta tags, and error handling.
13