Comprehensive Ruby and Rails code review using Sandi Metz rules and SOLID principles. Automatically runs rubycritic and simplecov, analyzes changed files in current branch vs base branch, identifies OOP violations, Rails anti-patterns, security issues, and test coverage gaps. Outputs REVIEW.md with VSCode-compatible file links. Use when reviewing Ruby/Rails code, conducting code reviews, checking for design issues, or when user mentions code review, pull request review, or code quality analysis.
Performs comprehensive Ruby/Rails code reviews on changed files in your branch vs base. Automatically runs rubycritic and simplecov, detects OOP violations, Rails anti-patterns, security issues, and coverage gaps, then generates REVIEW.md with clickable VSCode links.
/plugin marketplace add el-feo/ai-context/plugin install ruby-rails@jebs-dev-toolsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/rails-patterns.mdreferences/sandi-metz-rules.mdreferences/security-checklist.mdreferences/solid-principles.mdreferences/vscode-links.md<quick_start> <basic_usage>
git fetch to update remote refsgit diff --name-only base-branch...HEAD<vscode_link_format> Every code reference must use this format:
[description](file:///absolute/path/to/file.rb#L42)
Example:
[UserService#create_user violates SRP](file:///Users/dev/app/services/user_service.rb#L15)
Clicking opens the file at the specified line in VSCode. </vscode_link_format> </quick_start>
<workflow> <step_1_detect_base_branch> Auto-detect the base branch using git configuration:# Get default branch from remote
git remote show origin | grep 'HEAD branch' | cut -d' ' -f5
# Or detect from common naming
git branch -r | grep -E 'origin/(main|master|develop)' | head -n1
If detection fails, default to main.
</step_1_detect_base_branch>
<step_2_identify_changes> Get list of changed Ruby files:
git diff --name-only --diff-filter=ACMR base-branch...HEAD | grep '\.rb$'
Focus only on added, changed, modified, or renamed files (exclude deleted). </step_2_identify_changes>
<step_3_run_analysis_tools> Execute rubycritic and simplecov:
# Run rubycritic on changed files
rubycritic $(git diff --name-only base-branch...HEAD | grep '\.rb$' | tr '\n' ' ')
# Run test suite with simplecov
COVERAGE=true bundle exec rspec
Parse output to extract:
<step_4_analyze_each_file> For each changed file, review in this order:
1. OOP Design Review (see references/sandi-metz-rules.md and references/solid-principles.md)
2. Rails Patterns Review (see references/rails-patterns.md)
3. Security Review (see references/security-checklist.md)
4. Test Coverage Review
<step_5_analyze_codebase_patterns> Before making suggestions, understand larger patterns:
# Find similar patterns in codebase
grep -r "class.*Service" app/services/
grep -r "include Concerns" app/models/
# Check existing architectural patterns
ls app/services/ app/queries/ app/decorators/ app/presenters/
Ensure suggestions align with established patterns:
<step_6_generate_review_md> Create REVIEW.md with this structure:
# 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
[Issues requiring immediate attention - security, major bugs]
## Design & Architecture
### OOP Violations
[Sandi Metz and SOLID violations with VSCode links]
### Rails Patterns
[N+1 queries, callback issues, anti-patterns with VSCode links]
## Security Concerns
[Security vulnerabilities with VSCode links]
## Test Coverage
[Coverage gaps and missing tests 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 list of improvements considering codebase patterns]
## Positive Observations
[Well-designed code, good patterns, improvements from previous reviews]
Every code reference MUST include VSCode-compatible link. </step_6_generate_review_md> </workflow>
<tool_integration> <rubycritic_integration> RubyCritic analyzes code quality and complexity.
Run on changed files only:
rubycritic --format json --no-browser $(git diff --name-only base...HEAD | grep '\.rb$')
Extract from JSON output:
Incorporate findings into "Tool Reports" section of REVIEW.md. </rubycritic_integration>
<simplecov_integration> SimpleCov tracks test coverage.
Trigger coverage run:
COVERAGE=true bundle exec rspec
Read from coverage/.resultset.json:
Cross-reference with changed files to identify coverage gaps.
If simplecov not configured, check for existing skill:
# Check if simplecov skill exists
ls ~/.claude/skills/simplecov/
Use Skill tool to invoke simplecov skill for setup guidance if needed. </simplecov_integration>
<skill_invocation> If rubycritic or simplecov skills exist, invoke them:
Skill(rubycritic) # For RubyCritic setup and advanced usage
Skill(simplecov) # For SimpleCov setup and configuration
These skills provide deeper integration patterns and troubleshooting. </skill_invocation> </tool_integration>
<review_areas> <oop_design_review> Apply both Sandi Metz rules and SOLID principles:
Sandi Metz Rules:
SOLID Principles:
See detailed guides:
<rails_patterns_review> Check for Rails-specific issues:
Performance:
includes, preload, eager_load)Patterns:
Best Practices:
See: references/rails-patterns.md </rails_patterns_review>
<security_review> Check for common vulnerabilities:
SQL Injection:
where clausessanitize_sql_arrayXSS:
html_safe or raw on user inputMass Assignment:
permit! usageAuthorization:
See: references/security-checklist.md </security_review>
<test_coverage_review> Assess test quality and completeness:
Coverage Analysis:
Test Quality:
Recommendations:
<codebase_pattern_recognition> <understanding_context> Before making recommendations, understand existing patterns:
Architectural Layers:
# Discover what layers exist
find app -type d -maxdepth 1 | sort
Common patterns:
/services - Business logic extraction/queries - Complex database queries/decorators or /presenters - View logic/policies - Authorization logic/forms - Form objects for complex validations/serializers - API response formattingNaming Conventions:
# Understand naming patterns
ls app/services/ | head -10
ls app/models/concerns/ | head -10
Check for patterns like:
UserCreationService vs. Users::CreatorAuthenticatable vs. Authentication<matching_suggestions_to_patterns> Rule: Recommendations must match existing codebase patterns.
Examples:
/services with VerbNounService naming → recommend similarAnti-pattern: Suggesting decorator pattern when codebase has no decorators. Better: Suggest service object if that's the established pattern. </matching_suggestions_to_patterns> </codebase_pattern_recognition>
<validation> Before finalizing REVIEW.md, validate:Link Format:
file:///absolute/path#L42Content Completeness:
Quality:
<success_criteria> A successful review has:
<reference_guides> Core Principles:
Domain-Specific:
Technical Reference:
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.