From ruby-rails
Reviews Ruby and Rails code changes using Sandi Metz rules, SOLID principles, rubycritic, and simplecov. Detects OOP violations, Rails anti-patterns, security issues, code smells, and test coverage gaps. Outputs REVIEW.md with VSCode links.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ruby-rails:review-ruby-codeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Review Ruby/Rails code changes against Sandi Metz rules, SOLID principles, Rails best practices, and security standards. Generate a structured REVIEW.md with clickable VSCode links.
Review Ruby/Rails code changes against Sandi Metz rules, SOLID principles, Rails best practices, and security standards. Generate a structured REVIEW.md with clickable VSCode links.
# Auto-detect base branch
git remote show origin | grep 'HEAD branch' | cut -d' ' -f5
# Get changed Ruby files (added/changed/modified/renamed only)
git diff --name-only --diff-filter=ACMR base-branch...HEAD | grep '\.rb$'
If not on a feature branch, review files specified by the user.
# RubyCritic on changed files
rubycritic --format json --no-browser $(git diff --name-only base...HEAD | grep '\.rb$')
# SimpleCov coverage run
COVERAGE=true bundle exec rspec
Parse rubycritic JSON for complexity/smells/duplication. Read coverage/.resultset.json for per-file coverage and uncovered lines. If tools aren't configured, invoke their respective skills for setup guidance.
Optionally run the bundled static analyzer:
ruby scripts/code_reviewer.rb <file.rb>
Review in this order for each file:
OOP Design — Apply Sandi Metz rules and SOLID principles:
Code Smells — Check for the 18 canonical smells:
Rails Patterns — Detect anti-patterns:
includes/preload/eager_load)Security — Flag vulnerabilities:
html_safe/raw on user input)permit!)Test Coverage — Cross-reference with simplecov:
Before making suggestions, understand existing patterns:
ls app/services/ app/queries/ app/decorators/ app/presenters/ app/policies/ 2>/dev/null
Ensure recommendations align with established patterns (naming conventions, abstraction layers, test framework usage). Don't suggest decorators if the codebase uses presenters.
Every code reference MUST use VSCode-compatible links:
[description](file:///absolute/path/to/file.rb#L42)
See references/vscode-links.md for format details.
Use severity levels for findings:
# Code Review - [Branch Name]
**Base Branch**: [detected-branch]
**Changed Files**: [count]
**Review Date**: [date]
---
## Summary
[High-level overview of changes and main findings]
## Critical Issues
[Security vulnerabilities, major bugs requiring immediate attention]
## Design & Architecture
### OOP Violations
[Sandi Metz rule and SOLID violations with VSCode links and severity]
### Code Smells
[Detected smells with specific refactoring suggestions]
### Rails Patterns
[N+1 queries, callback issues, anti-patterns with VSCode links]
## Security Concerns
[Vulnerabilities with VSCode links]
## Test Coverage
[Coverage gaps, missing tests, quality issues with VSCode links]
## Tool Reports
### RubyCritic Summary
- **Complexity**: [score]
- **Duplication**: [score]
- **Code Smells**: [count]
### SimpleCov Summary
- **Total Coverage**: [percentage]
- **Files with < 90% coverage**: [list]
---
## Recommendations
[Prioritized improvements aligned with codebase patterns]
## Positive Observations
[Well-designed code, good patterns, improvements from previous reviews]
Before finalizing:
npx claudepluginhub el-feo/ai-context --plugin ruby-railsAnalyzes Ruby and Rails code quality using RubyCritic. Scores files A-F, detects smells/complexity/duplication/churn, compares branches, prioritizes refactoring.
Guides users through code review by asking Socratic questions about design, security, and correctness, then suggests concrete refactoring steps. Useful for reviewing PRs, inherited code, or your own work.
Runs RubyCritic to analyze Ruby code quality, detecting code smells, complexity, and duplication. Use for Ruby projects when creating/editing files, refactoring, or reviewing quality.