Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component...
npx skills add Kavin-Kannan/rails-best-practices-skill
Or install specific skill: npx add-skill https://github.com/Kavin-Kannan/rails-best-practices-skill
# Description
A Claude Agent Skill providing comprehensive Rails best practices from rails-bestpractices.com
# SKILL.md
Rails Best Practices Skill
A comprehensive skill that helps Claude review, analyze, and generate Ruby on Rails code according to established best practices.
Purpose
This skill provides Claude with expert knowledge of Rails best practices sourced from rails-bestpractices.com. This skill is automatically invoked for both code review and code generation - when enabled, Claude will:
- Review code against established Rails conventions
- Generate code following Rails best practices
- Identify Rails anti-patterns and suggest improvements
- Flag security vulnerabilities and performance issues
- Ensure code follows Rails community standards
- Provide detailed code review feedback with specific recommendations
- Apply best practices automatically when writing new Rails code
When to Use
This skill is automatically invoked and prioritized when Claude is:
- Reviewing Ruby on Rails code
- Generating or writing Ruby on Rails code
- Analyzing Rails code for best practices
- Performing code reviews on Rails applications
- Refactoring Rails applications
- Debugging Rails issues
- Explaining Rails concepts
Capabilities
Time and Timezone
- Enforces use of
Time.zone.nowinstead ofTime.now - Recommends client-side time display instead of
time_ago_in_words
ActiveRecord
- Ensures
savereturn values are checked orsave!is used - Warns against
default_scopeusage - Recommends batched finders for large datasets
- Identifies and fixes N+1 query problems
Controllers
- Prevents modification of params hash
- Recommends route restrictions
- Enforces strong parameters usage
Error Handling
- Ensures
StandardErroris rescued, notException - Recommends specific exception handling
Code Organization
- Applies "Tell, don't ask" principle
- Recommends namespaced models
- Identifies empty helpers
Views
- Recommends local variables in partials
- Avoids instance variable dependencies
Migrations
- Recommends
sayandsay_with_timefor logging
Security
- Checks for SQL injection risks
- Identifies XSS vulnerabilities
- Ensures CSRF protection
- Validates authentication/authorization
Code Quality
- Enforces DRY principle
- Ensures single responsibility
- Removes trailing whitespace
Performance
- Optimizes database queries
- Recommends appropriate eager loading
- Suggests caching strategies
Resources
This skill includes:
- Comprehensive best practices documentation organized by category
- Code examples for each practice
- Common anti-patterns to avoid
- Reference links to source material
Usage Examples
Code Review
When reviewing Rails code, Claude will:
- Comprehensively analyze code against Rails best practices
- Identify N+1 query problems and suggest optimizations
- Flag params hash modifications and security issues
- Suggest eager loading opportunities
- Recommend security improvements
- Check for proper error handling patterns
- Verify adherence to Rails conventions
- Provide actionable feedback with code examples
Code Generation
When generating Rails code, Claude will automatically:
- Follow Rails best practices from the start
- Use Time.zone.now instead of Time.now
- Check save return values or use save!
- Avoid default_scope anti-patterns
- Use strong parameters in controllers
- Prevent N+1 queries with proper eager loading
- Apply proper error handling patterns
- Follow Rails naming conventions and structure
- Implement security best practices
Refactoring
When refactoring, Claude will:
- Extract repeated code
- Apply "Tell, don't ask" principle
- Improve query performance
- Enhance code organization
Categories
The skill covers practices in:
- Timezone handling
- ActiveRecord patterns
- Controller design
- Error handling
- Code organization
- View patterns
- Migrations
- Security
- Code quality
- Performance optimization
- Testing
- General Rails conventions
Source and Attribution
This skill is based on concepts from rails-bestpractices.com,
a community-driven collection of Rails best practices.
Important: Content is rewritten in our own words, not copied verbatim. We provide
attribution and source links throughout. See COPYRIGHT.md for copyright
information and legal considerations.
Version
Current version: 1.0.0
Maintenance
This skill is maintained and updated as new Rails best practices emerge. Categories are organized for easy reference and extension.
Attribution
This skill is based on publicly available best practices from rails-bestpractices.com. The practices themselves are community knowledge. This skill structure, organization, and documentation are original work.
License
MIT License - See LICENSE file for details.
Contributing
See CONTRIBUTING.md for how to contribute improvements, new practices, or documentation updates.
# README.md
Rails Best Practices Skill
A Claude Agent Skill that provides comprehensive Rails best practices sourced from rails-bestpractices.com.
What is This?
This is a Claude Agent Skill - a specialized knowledge package that helps Claude review, analyze, and generate Ruby on Rails code following community best practices. This skill is automatically invoked for both code review and code generation when Claude is working with Ruby on Rails code.
Quick Start
Install for Claude Code
mkdir -p ~/.claude/skills
cp -r rails_best_practices ~/.claude/skills/rails-best-practices
See QUICK_START.md for 3-step installation.
Features
When enabled, Claude will automatically:
- β
Use Time.zone.now instead of Time.now
- β
Check save return values or use save!
- β
Avoid default_scope anti-patterns
- β
Prevent N+1 query problems
- β
Use strong parameters in controllers
- β
Follow Rails conventions
- β
Apply security best practices
- β
Optimize database queries
- β
And much more!
Installation
- Claude Code: See INSTALL.md
- Claude Apps: Enable in Settings β Skills
- API: Include in Messages API requests
Sharing with Community
Want to share this skill with other developers?
See HOW_TO_SHARE.md for complete step-by-step instructions!
Quick version:
1. Create GitHub repository
2. Submit to Anthropic Skills Marketplace (when available)
3. Share with Rails community
Documentation
- SKILL.md - Main skill description
- QUICK_START.md - 3-step installation
- INSTALL.md - Detailed installation guide
- HOW_TO_SHARE.md - Complete sharing guide β
- DEVELOPER_GUIDE.md - Developer contribution guide
- CONTRIBUTING.md - How to contribute improvements
- INDEX.md - Complete practices index
- USAGE.md - Usage across projects
- COPYRIGHT.md - Copyright and legal information βοΈ
- LEGAL_GUIDANCE.md - Legal guidance and recommendations βοΈ
- ATTRIBUTION_TEMPLATE.md - Template for practice file attribution
Structure
rails-best-practices/
βββ SKILL.md # Main skill description (required)
βββ README.md # This file
βββ INDEX.md # Practices index
βββ LICENSE # MIT License
βββ timezone/ # Time/timezone practices
βββ active_record/ # ActiveRecord practices
βββ controllers/ # Controller practices
βββ error_handling/ # Error handling practices
βββ code_organization/ # Code organization practices
βββ views/ # View practices
βββ migrations/ # Migration practices
βββ security/ # Security practices
βββ code_quality/ # Code quality practices
βββ performance/ # Performance practices
βββ testing/ # Testing practices
βββ general/ # General Rails conventions
Categories Covered
- Timezone: Time handling best practices
- ActiveRecord: Database and model patterns
- Controllers: Controller design patterns
- Error Handling: Exception handling
- Code Organization: Structure and patterns
- Views: View and partial patterns
- Migrations: Database migration practices
- Security: Security best practices
- Code Quality: DRY, SOLID, clean code
- Performance: Query optimization, caching
- Testing: Test coverage and quality
- General: Rails conventions and standards
Source and Attribution
All practices are based on concepts from rails-bestpractices.com,
a community-driven collection of Rails best practices created by Richard Huang and contributors.
Important: This skill does NOT copy verbatim text from rails-bestpractices.com. All content
is rewritten in our own words, organized for Claude Skill format, with proper attribution.
See COPYRIGHT.md for detailed copyright information.
Contributing
We welcome contributions! See CONTRIBUTING.md for:
- How to add new Rails practices
- Contribution guidelines (follows Claude's standards)
- AI usage disclosure requirements
- Pull request process
- Code of conduct
Important: All contributions must follow Claude's contribution guidelines, including disclosure of AI tool usage and human verification of all changes.
License
MIT License - See LICENSE file for details.
Version
Current version: 1.0.0
Support
- Installation Issues: See INSTALL.md
- Sharing Questions: See HOW_TO_SHARE.md
- Contributing: See CONTRIBUTING.md
- General Questions: Open an issue on GitHub
Ready to share? β See HOW_TO_SHARE.md for complete instructions!
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.