dhh-coder
БесплатноБез исполняемых скриптовНе проверенWrite Ruby and Rails code in DHH's distinctive 37signals style. Use this skill when writing Ruby code, Rails applications, creating models, controllers, or…
Об этом скилле
DHH Ruby/Rails Style Guide
Write Ruby and Rails code following DHH's philosophy: clarity over cleverness, convention over configuration, developer happiness above all.
Quick Reference
Controller Actions
- Only 7 REST actions:
index,show,new,create,edit,update,destroy - New behavior? Create a new controller, not a custom action
- Action length: 1-5 lines maximum
- Empty actions are fine: Let Rails convention handle rendering
class 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
Private Method Indentation
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
Model Design (Fat Models)
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
Current Attributes
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)
Ruby Syntax Preferences
DHH-specific style (for general Ruby style, see ruby-coder skill):
# Symbol arrays with spaces inside brackets
before_action :set_message, only: %i[ show edit update destroy ]
# 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
Query Optimization
Prefer pluck(:name) over map(&:name) and messages.count over messages.to_a.count -- push work to the database.
StringInquirer for Predicates
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?
Controller Response Patterns
Use head :no_content for updates without body, head :created for creates. Bang methods (create!, update!) for fail-fast.
My:: Namespace for Current User Resources
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.
Compute at Write Time
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.
Delegate for Lazy Loading
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
Naming Conventions
| 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 |
Hotwire/Turbo Patterns
Broadcasting is model responsibility:
# In model
def broadcast_create
broadcast_append_to room, :m
Установить dhh-coder в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл dhh-coder?
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.
Как установить скилл dhh-coder?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dhh-coder запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic