Write Ruby and Rails code in DHH's distinctive 37signals style. Use this skill when writing Ruby code, Rails applications, creating models, controllers, or any Ruby file. Triggers on Ruby/Rails code generation, refactoring requests, or when the user mentions DHH, 37signals, Basecamp, HEY, Fizzy, or Campfire style.
Generates Ruby/Rails code in DHH's 37signals style. Triggers on Ruby/Rails requests or mentions of DHH, 37signals, Basecamp, HEY, or Campfire style.
/plugin marketplace add majesticlabs-dev/majestic-marketplace/plugin install majestic-rails@majestic-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/activerecord-tips.mdreferences/activestorage-tips.mdreferences/caching-strategies.mdreferences/concerns-organization.mdreferences/config-tips.mdreferences/controllers-tips.mdreferences/css-architecture.mdreferences/database-patterns.mdreferences/delegated-types.mdreferences/filter-objects.mdreferences/hotwire-tips.mdreferences/multi-tenancy.mdreferences/palkan-patterns.mdreferences/passwordless-auth.mdreferences/patterns.mdreferences/recording-pattern.mdreferences/resources.mdreferences/stimulus-catalog.mdreferences/structured-events.mdreferences/turbo-morphing.mdWrite Ruby and Rails code following DHH's philosophy: clarity over cleverness, convention over configuration, developer happiness above all.
index, show, new, create, edit, update, destroyclass MessagesController < ApplicationController
before_action :set_message, only: %i[ show edit update destroy ]
def index
@messages = @room.messages.with_creator.last_page
fresh_when @messages
end
def show
end
def create
@message = @room.messages.create_with_attachment!(message_params)
@message.broadcast_create
end
private
def set_message
@message = @room.messages.find(params[:id])
end
def message_params
params.require(:message).permit(:body, :attachment)
end
end
Indent private methods one level under private keyword:
private
def set_message
@message = Message.find(params[:id])
end
def message_params
params.require(:message).permit(:body)
end
Models own business logic, authorization, and broadcasting:
class Message < ApplicationRecord
belongs_to :room
belongs_to :creator, class_name: "User"
has_many :mentions
scope :with_creator, -> { includes(:creator) }
scope :page_before, ->(cursor) { where("id < ?", cursor.id).order(id: :desc).limit(50) }
def broadcast_create
broadcast_append_to room, :messages, target: "messages"
end
def mentionees
mentions.includes(:user).map(&:user)
end
end
class User < ApplicationRecord
def can_administer?(message)
message.creator == self || admin?
end
end
Use Current for request context, never pass current_user everywhere:
class Current < ActiveSupport::CurrentAttributes
attribute :user, :session
end
# Usage anywhere in app
Current.user.can_administer?(@message)
# Symbol arrays with spaces inside brackets
before_action :set_message, only: %i[ show edit update destroy ]
# Modern hash syntax exclusively
params.require(:message).permit(:body, :attachment)
# Single-line blocks with braces
users.each { |user| user.notify }
# Ternaries for simple conditionals
@room.direct? ? @room.users : @message.mentionees
# Bang methods for fail-fast
@message = Message.create!(params)
@message.update!(message_params)
# Predicate methods with question marks
@room.direct?
user.can_administer?(@message)
@messages.any?
# Expression-less case for cleaner conditionals
case
when params[:before].present?
@room.messages.page_before(params[:before])
when params[:after].present?
@room.messages.page_after(params[:after])
else
@room.messages.last_page
end
# WRONG: Load all records then extract attribute
users.map(&:name)
# CORRECT: Pluck directly from database
users.pluck(:name)
# WRONG: Count via Ruby
messages.to_a.count
# CORRECT: Count via SQL
messages.count
Use .inquiry on string enums for readable conditionals:
class Event < ApplicationRecord
def action
super.inquiry
end
end
# Clean predicate methods
event.action.completed?
event.action.pending?
event.action.failed?
# Return 204 No Content for successful updates without body
def update
@message.update!(message_params)
head :no_content
end
# Return 201 Created for successful creates
def create
@message = Message.create!(message_params)
head :created
end
Use My:: namespace for resources scoped to Current.user:
# routes.rb
namespace :my do
resource :profile, only: %i[ show edit update ]
resources :notifications, only: %i[ index destroy ]
end
# app/controllers/my/profiles_controller.rb
class My::ProfilesController < ApplicationController
def show
@profile = Current.user
end
end
No index or show with ID needed—resource is implicit from Current.user.
Perform data manipulation during saves, not during presentation:
# WRONG: Compute on read
def display_name
"#{first_name} #{last_name}".titleize
end
# CORRECT: Compute on write
before_save :set_display_name
private
def set_display_name
self.display_name = "#{first_name} #{last_name}".titleize
end
Benefits: enables pagination, caching, and reduces view complexity.
Use delegate to enable lazy loading through associations:
class Message < ApplicationRecord
belongs_to :session
delegate :user, to: :session
end
# Lazy loads user through session
message.user
| Element | Convention | Example |
|---|---|---|
| Setter methods | set_ prefix | set_message, set_room |
| Parameter methods | {model}_params | message_params |
| Association names | Semantic, not generic | creator not user |
| Scopes | Chainable, descriptive | with_creator, page_before |
| Predicates | End with ? | direct?, can_administer? |
| Current user resources | My:: namespace | My::ProfilesController |
Broadcasting is model responsibility:
# In model
def broadcast_create
broadcast_append_to room, :messages, target: "messages"
end
# In controller
@message.broadcast_replace_to @room, :messages,
target: [ @message, :presentation ],
partial: "messages/presentation",
attributes: { maintain_scroll: true }
Rescue specific exceptions, fail fast with bang methods:
def create
@message = @room.messages.create_with_attachment!(message_params)
@message.broadcast_create
rescue ActiveRecord::RecordNotFound
render action: :room_not_found
end
Track state via database records rather than boolean columns:
# WRONG: Boolean columns for state
class Card < ApplicationRecord
# closed: boolean, gilded: boolean columns
end
card.update!(closed: true)
card.closed? # Loses who/when/why
# CORRECT: State as separate records
class Card < ApplicationRecord
has_one :closure
has_one :gilding
def close(by:)
create_closure!(closed_by: by)
end
def closed?
closure.present?
end
end
card.close(by: Current.user)
card.closure.closed_by # Full audit trail
Map custom actions to nested resource controllers:
| Custom Action | REST Resource |
|---|---|
POST /cards/:id/close | POST /cards/:id/closure |
DELETE /cards/:id/close | DELETE /cards/:id/closure |
POST /cards/:id/gild | POST /cards/:id/gilding |
POST /posts/:id/publish | POST /posts/:id/publication |
DELETE /posts/:id/publish | DELETE /posts/:id/publication |
# routes.rb
resources :cards do
resource :closure, only: %i[ create destroy ]
resource :gilding, only: %i[ create destroy ]
end
# app/controllers/cards/closures_controller.rb
class Cards::ClosuresController < ApplicationController
def create
@card = Card.find(params[:card_id])
@card.close(by: Current.user)
end
def destroy
@card = Card.find(params[:card_id])
@card.closure.destroy!
end
end
| Traditional | DHH Way |
|---|---|
| PostgreSQL | SQLite (for single-tenant) |
| Redis + Sidekiq | Solid Queue |
| Redis cache | Solid Cache |
| Kubernetes | Single Docker container |
| Service objects | Fat models |
| Policy objects (Pundit) | Authorization on User model |
| FactoryBot | Fixtures |
| Boolean state columns | State as records |
For comprehensive patterns and examples, see:
references/patterns.md - Complete code patterns with explanationsreferences/palkan-patterns.md - Namespaced model classes, counter caches, model organization order, PostgreSQL enumsreferences/concerns-organization.md - Model-specific vs common concerns, facade patternreferences/delegated-types.md - Polymorphism without STI problemsreferences/recording-pattern.md - Unifying abstraction for diverse content typesreferences/filter-objects.md - PORO filter objects, URL-based state, testable query buildingreferences/database-patterns.md - UUIDv7, hard deletes, state as records, counter caches, indexingreferences/activerecord-tips.md - ActiveRecord query patterns, validations, associationsreferences/controllers-tips.md - Controller patterns, routing, rate limiting, form objectsreferences/hotwire-tips.md - Turbo Frames, Turbo Streams, Stimulus, ViewComponentsreferences/turbo-morphing.md - Turbo 8 page refresh with morphing patternsreferences/activestorage-tips.md - File uploads, attachments, blob handlingreferences/stimulus-catalog.md - Copy-paste-ready Stimulus controllers (clipboard, dialog, hotkey, etc.)references/css-architecture.md - Native CSS patterns (layers, OKLCH, nesting, dark mode)references/passwordless-auth.md - Magic link authentication, sessions, identity modelreferences/multi-tenancy.md - Path-based tenancy, cookie scoping, tenant-aware jobsreferences/webhooks.md - Secure webhook delivery, SSRF protection, retry strategiesreferences/caching-strategies.md - Russian Doll caching, Solid Cache, cache analysisreferences/config-tips.md - Configuration, logging, deployment patternsreferences/structured-events.md - Rails 8.1 Rails.event API for structured observabilityreferences/resources.md - Links to source material and further readingCode aligns with DHH style when:
can_*? methods)chronologically, with_*, etc.)pluck over map for attribute extractionMy:: namespaceThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.