Analyze Ruby and Rails code quality with RubyCritic. Identifies code smells, complexity issues, and refactoring opportunities. Provides detailed metrics, scores files A-F, compares branches, and prioritizes high-churn problem areas. Use when analyzing Ruby code quality, reviewing PRs, or identifying technical debt.
Analyzes Ruby/Rails code quality using RubyCritic to identify code smells, complexity issues, and refactoring opportunities. Triggers when reviewing PRs, analyzing code quality, or identifying technical debt in Ruby projects.
/plugin marketplace add esparkman/claude-rubycritic-skill/plugin install rubycritic-skill@rubycritic-skillThis skill inherits all available tools. When active, it can use any tool Claude has access to.
A Claude Code skill for analyzing Ruby and Rails code quality using RubyCritic.
This skill integrates RubyCritic to provide comprehensive code quality analysis for Ruby and Rails projects. It helps identify code smells, complexity issues, and areas for refactoring with detailed metrics and actionable insights.
/rubycritic [path]Analyze code quality for the specified path or entire project.
Options:
path (optional): Specific file or directory to analyze. Defaults to current directory.Examples:
/rubycritic
/rubycritic app/models
/rubycritic app/controllers/users_controller.rb
/rubycritic-summaryGet a quick summary of code quality metrics without detailed file breakdowns.
/rubycritic-worstShow only the worst-rated files that need immediate attention.
Options:
--limit N: Number of worst files to show (default: 10)Examples:
/rubycritic-worst
/rubycritic-worst --limit 5
/rubycritic-compare [branch]Compare code quality between current branch and specified branch.
Options:
branch: Branch to compare against (default: main/master)Examples:
/rubycritic-compare main
/rubycritic-compare develop
Score Ranges:
Key Metrics:
The skill automatically checks for RubyCritic and installs it if needed:
gem install rubycritic
Create a .rubycritic.yml in your project root for custom settings:
# Minimum score for a file to be considered acceptable
minimum_score: 80.0
# Paths to exclude from analysis
paths:
- 'db/schema.rb'
- 'db/migrate/**/*'
- 'config/**/*'
- 'bin/**/*'
- 'spec/factories/**/*'
# Enable/disable specific analyzers
analyzers:
- flay # Structural duplication
- flog # ABC complexity
- reek # Code smells
- rubocop # Style issues (if available)
# Format for output
formats:
- console
- html
# Branch for comparison mode
branch: main
The skill provides:
Pre-Commit Analysis:
/rubycritic $(git diff --name-only --cached | grep '\.rb$')
CI/CD Integration:
Performance Considerations:
Solution: Narrow the scope
/rubycritic app/models/user.rb
/rubycritic app/controllers
Solution: Configure .rubycritic.yml to exclude problematic analyzers or paths
Solution: RubyCritic uses multiple analyzers; check individual metric breakdowns
Set quality gates for your team:
# In your CI/CD pipeline
if average_score < 75
puts "Code quality below threshold!"
exit 1
end
Target specific code smells:
/rubycritic app/models --smells "LongMethod,FeatureEnvy"
Compare against previous commits:
/rubycritic-compare HEAD~5
RubyCritic Analysis Results
===========================
Project Score: B (82.5)
Top Issues:
1. app/models/user.rb (Score: 65.2, Grade: D)
- Long Method: #calculate_permissions (complexity: 18)
- Feature Envy: accessing order.items repeatedly
- Duplication: 3 similar conditional blocks
2. app/controllers/orders_controller.rb (Score: 71.3, Grade: C)
- Long Method: #create (complexity: 15)
- Too Many Instance Variables: 6 ivars in #index
Recommendations:
- Extract #calculate_permissions into a service object
- Use Law of Demeter for order.items access
- Refactor conditional logic in User model
- Slim down OrdersController#create method
When using this skill, Claude should:
Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.