install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/rails-dev" ~/.claude/skills/comeonoliver-skillshub-rails-dev && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/rails-dev/SKILL.mdsource content
Community Ruby on Rails Development Best Practices
Comprehensive performance and maintainability optimization guide for Ruby on Rails applications, maintained by Community. Contains 45 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
- Writing new Rails controllers, models, or views
- Optimizing ActiveRecord queries and database access patterns
- Implementing caching strategies (fragment, Russian doll, low-level)
- Building or refactoring API endpoints
- Adding Turbo Frames and Streams for interactive UIs
- Reviewing code for N+1 queries and security vulnerabilities
- Designing background jobs with Sidekiq or Active Job
- Writing or reviewing database migrations
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Database & ActiveRecord | CRITICAL | |
| 2 | Controllers & Routing | CRITICAL | |
| 3 | Security | HIGH | |
| 4 | Models & Business Logic | HIGH | |
| 5 | Caching & Performance | HIGH | |
| 6 | Views & Frontend | MEDIUM-HIGH | |
| 7 | API Design | MEDIUM | |
| 8 | Background Jobs & Async | LOW-MEDIUM | |
Quick Reference
1. Database & ActiveRecord (CRITICAL)
- Eager load associations to eliminate N+1 queriesdb-eager-load-associations
- Add database indexes on queried columnsdb-add-database-indexes
- Select only needed columnsdb-select-specific-columns
- Use find_each for large dataset iterationdb-batch-processing
- Avoid database queries inside loopsdb-avoid-queries-in-loops
- Define reusable query scopes on modelsdb-use-scopes
- Write reversible zero-downtime migrationsdb-safe-migrations
- Use exists? instead of count for existence checksdb-exists-over-count
2. Controllers & Routing (CRITICAL)
- Keep controllers thin by delegating to models and servicesctrl-thin-controllers
- Always use strong parameters for mass assignmentctrl-strong-params
- Follow RESTful routing conventionsctrl-restful-routes
- Scope before_action callbacks with only/exceptctrl-before-action-scoping
- Use respond_to for multi-format responsesctrl-respond-to-format
- Handle errors with rescue_from in controllersctrl-rescue-from
3. Security (HIGH)
- Never interpolate user input in SQLsec-parameterized-queries
- Whitelist permitted params, never blacklistsec-strong-params-whitelist
- Authenticate before authorize on every requestsec-authenticate-before-authorize
- Enable CSRF protection for all form submissionssec-csrf-protection
- Scope queries to current user for authorizationsec-scope-queries-to-user
4. Models & Business Logic (HIGH)
- Validate data at the model levelmodel-validate-at-model-level
- Avoid side effects in model callbacksmodel-avoid-callback-side-effects
- Extract complex logic into service objectsmodel-use-service-objects
- Use scopes instead of class methods for query compositionmodel-scope-over-class-methods
- Use enums for finite state fieldsmodel-use-enums
- Use concerns for shared model behaviormodel-concerns-for-shared-behavior
- Extract complex queries into query objectsmodel-query-objects
5. Caching & Performance (HIGH)
- Use fragment caching for expensive view partialscache-fragment-caching
- Use Russian doll caching for nested collectionscache-russian-doll
- Use Rails.cache.fetch for computed datacache-low-level
- Use counter caches for association countscache-counter-cache
- Use conditional GET with stale? for HTTP cachingcache-conditional-get
6. Views & Frontend (MEDIUM-HIGH)
- Use collection rendering instead of loop partialsview-collection-rendering
- Use Turbo Frames for partial page updatesview-turbo-frames
- Use Turbo Streams for real-time page mutationsview-turbo-streams
- Use form_with instead of form_tag or form_forview-form-with
- Move display logic to helpers or presentersview-avoid-logic-in-views
7. API Design (MEDIUM)
- Use serializers for consistent JSON responsesapi-serializers
- Always paginate collection endpointsapi-pagination
- Version APIs from day oneapi-versioning
- Return structured error responsesapi-error-responses
- Avoid Jbuilder on high-traffic endpointsapi-avoid-jbuilder-hot-paths
8. Background Jobs & Async (LOW-MEDIUM)
- Design jobs to be idempotentjob-idempotent-design
- Pass IDs to jobs, not serialized objectsjob-small-payloads
- Configure retry and error handling for jobsjob-error-handling
- Prevent duplicate job enqueuingjob-unique-jobs
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |