dhh-rails-style

Apply DHH/37signals conventions to Ruby on Rails projects.

Updated May 20, 2022
One-click install
npx skills add https://github.com/andrewhwaller/dotfiles --skill dhh-rails-style-andrewhwaller
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dhh-rails-style
Source: https://github.com/andrewhwaller/dotfiles/tree/main/opencode/skills/dhh-rails-style
Command: npx skills add https://github.com/andrewhwaller/dotfiles --skill dhh-rails-style-andrewhwaller

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This style provides a coherent, opinionated set of conventions for Ruby and Rails development inspired by DHH/37signals, reducing cognitive overhead and aligning code with RESTful, domain-driven patterns.

Core Features & Use Cases

  • RESTful controllers with thin controllers and rich domain models
  • Use of concerns for horizontal reuse and shared behavior
  • State-as-records approach for lifecycle events and auditing
  • Testing with Minitest and fixtures to ensure deterministic behavior across apps
  • Clear code reviews and code organization guidance for Rails projects

Quick Start

Begin by refactoring controllers to RESTful resources, moving state into dedicated models, and colocating authorization logic on the User model.

Frequently Asked Questions about dhh-rails-style

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I apply DHH Rails style conventions to clean up my Ruby code?

Apply DHH Rails style by refactoring controllers into RESTful resources, moving state into dedicated models, and colocating authorization logic on the User model to reduce cognitive overhead and align code with domain-driven patterns.

What is the best way to organize fat models and controllers in Ruby on Rails?

Organize fat models and thin controllers in Ruby on Rails by adopting RESTful architecture and using model concerns for horizontal reuse. This style moves shared behavior into concerns and manages lifecycle events through a state-as-records approach.

Why use Minitest and fixtures instead of other testing frameworks for Rails conventions?

Use Minitest and fixtures for Rails conventions to ensure deterministic behavior across applications. This testing approach aligns with DHH/37signals style, providing coherent and opinionated rules for code reviews and organization.

When should I use model concerns for horizontal reuse in Rails?

Use model concerns for horizontal reuse in Rails when extracting shared behavior across multiple rich domain models. This pattern reduces code duplication and keeps models clean while adhering to DHH coding style conventions.

Does this Rails coding style require specific frontend patterns?

This Rails coding style requires lightweight frontend patterns across controllers, models, and views. It focuses on a state-as-records approach for lifecycle events and auditing, ensuring clear code organization without heavy frontend frameworks.