/superpowers-rails:rails-model-conventionsfrom superpowers-rails
Guides creation and modification of Rails models with clean interfaces, state-as-records patterns, and domain logic organization.
Ships in superpowers-rails. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Models own all domain logic. They provide clean interfaces and hide implementation details.
Card::Closeable in card/closeable.rbhas_one :closure not closed: boolean for audit trail# WRONG - leaking implementation
user.bookmarks.where(academy: academy).exists?
user.bookmarks.create!(academy: academy)
# RIGHT - clean interface
user.bookmarked?(academy)
user.bookmark(academy)
# Model exposes intent-based methods
class User < ApplicationRecord
def bookmarked?(academy)
academy_bookmarks.exists?(academy: academy)
end
def bookmark(academy)
academy_bookmarks.find_or_create_by(academy: academy)
end
end
Sender sends message to Receiver. Receiver performs action or returns data. Sender never reaches into Receiver's internal structure.
Binary state MUST be represented as a dedicated record, not a boolean column. The presence or absence of the record is the state.
Closure, Publication, Archival)has_one with dependent: :destroyjoins(:closure) and where.missing(:closure)touch: true on the belongs_to for cache invalidation# app/models/card/closeable.rb
module Card::Closeable
extend ActiveSupport::Concern
included do
has_one :closure, dependent: :destroy
scope :closed, -> { joins(:closure) }
scope :open, -> { where.missing(:closure) }
end
def closed? = closure.present?
def open? = !closed?
end
See rails-controller-conventions for routing and controller setup.
Boundary: For binary states (open/closed, published/draft, archived/active). For multi-step ordered workflows with transition guards, use a state machine.
Order: constants → associations → validations → scopes → callbacks → public methods → private methods
:dependent, :inverse_of, counter cachesincludes| Do | Don't |
|---|---|
Card::Closeable in card/closeable.rb | All logic in card.rb |
has_one :closure for state | closed: boolean column |
user.bookmark(academy) | user.bookmarks.create(...) |
| Intent-based method names | Exposing associations directly |
| Counter cache | .count on associations |
closed: boolean loses who/when context. Use a state recordRemember: Models are the domain. Rich interfaces, hidden implementation.
What SKILL.md sets; muted values are Claude Code's defaults
23 skills in this plugin
/brainstormingYou MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation./diagnosing-superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness./dispatching-parallel-agentsUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesnpx claudepluginhub fryga-io/superpowers-rails --plugin superpowers-railsOther plugins' skills for the same job