xiaohongshu
xiaohongshu
37signals-rails-style
Apply 37signals/DHH Rails conventions when writing Ruby on Rails code. Use when building Rails applications, reviewing Rails code, or making architectural decisions. Covers various aspects of Rails application architecture, design and dependencies.
Full skill instructions
| Gem/Pattern | Why |
|---|---|
devise | Auth is ~150 lines of custom code |
pundit/cancancan | Authorization lives in models |
dry-rb, interactor | Over-engineered |
view_component | ERB partials are fine |
sidekiq, redis | Use Solid Queue (database-backed) |
graphql | REST with Turbo is sufficient |
Every action maps to a CRUD verb. Create new resources instead of custom actions:
# Avoid: Custom actions
resources :cards do
post :close
end
# Good: State changes as resources
resources :cards do
resource :closure # POST to close, DELETE to reopen
resource :pin # POST to pin, DELETE to unpin
resource :watch # POST to watch, DELETE to unwatch
end
Use scope module: for namespaced nested resources. Use resolve for custom polymorphic URL generation.
Controllers orchestrate; business logic lives in models.
def create
@card.close # All logic in model
respond_to do |format|
format.turbo_stream { render_card_replacement }
format.json { head :no_content }
end
end
Use concerns for shared behavior:
CardScoped, BoardScoped - load parent resources via before_actionCurrentRequest - populate Current with request dataBlockSearchEngineIndexing, RequestForgeryProtectionTurboFlash - flash messages via Turbo StreamCheck permissions in controller, define permission logic in model:
# Controller
before_action :ensure_permission_to_administer_card, only: [:destroy]
# Model
def can_administer_card?(card)
admin? || card.creator == self
end
Each concern is self-contained with associations, scopes, and methods:
class Card < ApplicationRecord
include Assignable, Closeable, Eventable, Pinnable, Watchable
end
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 close(user: Current.user)
create_closure!(user: user) unless closed?
end
end
belongs_to :account, default: -> { board.account }
belongs_to :creator, class_name: "User", default: -> { Current.user }
Use ActiveSupport::CurrentAttributes for session, user, identity, account, and request metadata.
Namespace under parent model: Event::Description, Card::Eventable::SystemCommenter
Use for:
POROs are model-adjacent, NOT controller-adjacent (that would be a service object).
Create separate records instead of boolean columns:
# Separate record gives you: timestamp, who did it, easy scoping
class Closure < ApplicationRecord
belongs_to :card, touch: true
belongs_to :user, optional: true
end
card.closure.present? # Is it closed?
card.closure.user # Who closed it?
card.closure.created_at # When?
# Scoping
Card.closed # joins(:closure)
Card.open # where.missing(:closure)
Examples: Closure, Pin, Watch, Publication, Goldness
Custom passwordless magic link auth (~150 lines). No Devise.
Key components:
Authentication concern with require_authentication, resume_session, start_new_session_forSession model (belongs_to identity)MagicLink model with expiration and consumptionturbo_stream.replace, turbo_stream.before)method: :morph)static values/static classes for config, this.dispatch() for events, this.#privateMethod() for private methods_later and _now convention - mark_as_read_later queues job, mark_as_read_now executes immediatelyconfig/recurring.ymlchange { }, as: :turbo_stream, as: :jsonSignup as ActiveModelclose, reopen, publishclosed?, published?Adjectives describing capability: Closeable, Publishable, Watchable, Searchable
Nouns matching the resource: Cards::ClosuresController, Boards::PublicationsController
chronologically, reverse_chronologically, alphabetically, latestpreloaded as standard name for eager loadingindexed_by(index), sorted_by(sort)fresh_when etag: [...] for conditional GETetag { "v1" } in ApplicationController (bump to bust caches)cache card do in viewscached: true for collection renderingtouch: true on associations for cache invalidationaccount_id for multi-tenancy/{account_id}/boards/...@layer reset, base, components, modules, utilities@starting-style, color-mix(), :has(), native nesting, container queriesrespond_to201 Created + Location, Update/Delete → 204 No ContentUse sparingly:
after_commit :relay_later, on: :create for async workbefore_save :set_defaults for derived dataThe best code is the code you don't write. The second best is the code that's obviously correct.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience