rails-expert
27
总安装量
27
周安装量
#7540
全站排名
安装命令
npx skills add https://github.com/404kidwiz/claude-supercode-skills --skill rails-expert
Agent 安装分布
claude-code
21
opencode
20
codex
18
cursor
14
github-copilot
13
Skill 文档
Rails Expert
Purpose
Provides expert Ruby on Rails development expertise specializing in Rails 7+ modern features, Hotwire stack (Turbo, Stimulus), and modern Rails patterns. Excels at building full-stack web applications with server-rendered HTML, real-time updates, and structured client-side behavior without heavy JavaScript frameworks.
When to Use
- Building modern Rails 7+ applications with Hotwire (Turbo, Stimulus)
- Implementing real-time features with Turbo Streams and Action Cable
- Migrating legacy Rails apps to modern Rails patterns and conventions
- Building API-first Rails applications with JSON:API or GraphQL
- Optimizing Rails application performance (database queries, N+1, caching)
- Implementing complex Rails patterns (Service Objects, Form Objects, Query Objects)
- Integrating Rails with modern frontend tools (Import Maps, esbuild, Vite)
Quick Start
Invoke this skill when:
- Building Rails 7+ apps with Hotwire/Turbo/Stimulus
- Implementing real-time features (Turbo Streams, Action Cable)
- Migrating legacy Rails to modern patterns
- Building API-first Rails (JSON:API, GraphQL)
- Optimizing performance (N+1, caching, eager loading)
- Using Rails patterns (Service Objects, Form Objects, Query Objects)
Do NOT invoke when:
- Only frontend development needed â Use frontend-developer or react-specialist
- Database-specific optimization â Use database-optimizer or postgres-pro
- Pure API design without Rails â Use api-designer
- DevOps/deployment only â Use devops-engineer
Core Capabilities
Rails 7+ Modern Features
- Hotwire: Turbo, Stimulus, and dynamic HTML updates without JavaScript frameworks
- Import Maps: JavaScript dependency management without build tools
- Rails 7 Action Text: Rich text editing with modern UI
- Encrypted Credentials: Enhanced security for sensitive data
- Async Query Loading: Improved database query performance
- Multi-DB Support: Primary/replica database configurations
- Parallel Testing: Faster test execution across processes
- Async Action Mailer: Non-blocking email delivery
Hotwire Stack
- Turbo Drive: Faster page navigation with automatic page caching
- Turbo Frames: Partial page updates without full reloads
- Turbo Streams: Real-time updates over WebSocket or SSE
- Stimulus Controllers: Structured client-side JavaScript behavior
- Turbo Morph: Smart DOM diffing for minimal re-renders
Modern Rails Patterns
- Service Objects: Extract business logic from controllers
- Query Objects: Complex database queries as reusable objects
- Form Objects: Handle complex form logic and validation
- Decorators: Presentational logic separation
- View Components: Reusable UI component architecture
- API Resources: Consistent API response formatting
Decision Framework
Rails Feature Selection
Rails Development Decision
ââ Need real-time updates
â ââ User-specific updates â Turbo Streams + Action Cable
â ââ Broadcast to multiple users â Action Cable channels
â ââ Simple form responses â Turbo Streams over HTTP
â
ââ Frontend architecture
â ââ Minimal JS, server-rendered â Hotwire (Turbo + Stimulus)
â ââ Complex client-side logic â Rails API + React/Vue
â ââ Hybrid approach â Turbo Frames for islands of interactivity
â
ââ Database strategy
â ââ Read-heavy workload â Multi-DB with read replicas
â ââ Complex queries â Query Objects + proper indexing
â ââ Caching needed â Russian doll caching + fragment caching
â
ââ Code organization
ââ Fat models â Extract Service Objects
ââ Complex validations â Form Objects
ââ Business logic in controllers â Move to services
Performance Optimization Matrix
| Issue | Solution | Implementation |
|---|---|---|
| N+1 queries | Eager loading | includes(:association) / preload |
| Slow counts | Counter caches | counter_cache: true on associations |
| Repeated queries | Fragment caching | cache @object do blocks |
| Large datasets | Pagination | Kaminari / Pagy gems |
| Slow API responses | JSON caching | stale? / fresh_when |
Best Practices
Rails 7+ Features
- Hotwire First: Use Turbo/Stimulus before reaching for JS frameworks
- Import Maps: Manage JS dependencies without complex bundlers
- Async Query Loading: Leverage parallel query execution
- Multi-DB: Use read replicas for read-heavy workloads
Code Organization
- Service Objects: Extract business logic from controllers
- Query Objects: Encapsulate complex database queries
- Form Objects: Handle complex form validation logic
- View Components: Create reusable, testable UI components
Performance
- Eager Loading: Always use includes/preload for associations
- Counter Caches: Pre-calculate counts for associations
- Caching Strategy: Implement multi-level caching
- Database Indexes: Add indexes based on query patterns
Testing
- System Tests: Use for critical user journeys
- Component Tests: Test View Components in isolation
- Request Tests: Test API endpoints comprehensively
- Model Tests: Test business logic at unit level
Anti-Patterns
Architecture Anti-Patterns
- Fat Controllers: Business logic in controllers – use Service Objects and POROs
- Massive Models: Models handling too many responsibilities – extract concerns
- Callback Spaghetti: Complex callback chains – use service objects
- Skinny Controller, Fat Model: All logic in model – balance distribution
Database Anti-Patterns
- N+1 Queries: Not using eager loading – use includes/joins/preload
- Missing Indexes: Slow queries without proper indexes – analyze and add
- Counter Cache Miss: Repeated count queries – use counter caches
- Migrations Without Down: Non-reversible migrations – ensure reversibility
Performance Anti-Patterns
- Eager Loading Excess: Over-eager loading causing memory issues
- Missing Caching: No caching strategy – implement appropriate levels
- Render Bloat: Heavy view rendering – use fragments and caching
- Job Queue Backlog: No background job processing – use Active Job
Additional Resources
- Detailed Technical Reference: See REFERENCE.md
- Code Examples & Patterns: See EXAMPLES.md