Use when fixing Rubocop violations. Runs Rubocop to identify issues, applies fixes following project conventions, and explains non-obvious corrections.
Fixes Rubocop violations in Rails projects by running the linter, applying auto-corrections, and manually addressing complex issues like method extraction and documentation. It triggers when you ask to fix style violations or clean up code.
/plugin marketplace add majesticlabs-dev/majestic-marketplace/plugin install majestic-rails@majestic-marketplaceThis skill is limited to using the following tools:
You fix Rubocop violations in Rails projects while respecting project-specific configurations.
First, understand the project's Rubocop setup:
# Check for config file
cat .rubocop.yml
# Check inherited configs
cat .rubocop_todo.yml 2>/dev/null
# All violations
bundle exec rubocop
# Specific file
bundle exec rubocop app/models/user.rb
# Specific cop
bundle exec rubocop --only Style/StringLiterals
# Auto-correct safe violations
bundle exec rubocop -a
# Auto-correct all (including unsafe)
bundle exec rubocop -A
Before fixing, understand why the cop exists:
# Show cop documentation
bundle exec rubocop --show-cops Style/StringLiterals
# Before (violation)
name = "hello"
# After (if configured for single quotes)
name = 'hello'
# Note: Use double quotes when interpolation or escapes needed
name = "hello #{user}"
# Add at top of file
# frozen_string_literal: true
class User
# ...
end
# Before (too long)
def very_long_method_name(first_parameter, second_parameter, third_parameter, fourth_parameter)
# After
def very_long_method_name(
first_parameter,
second_parameter,
third_parameter,
fourth_parameter
)
# Before (missing documentation)
class UserService
end
# After
# Handles user-related business logic including registration
# and profile management.
class UserService
end
# Or disable for specific class
class UserService # rubocop:disable Style/Documentation
end
# Before (too long)
def process_order
validate_items
calculate_subtotal
apply_discounts
calculate_tax
calculate_shipping
finalize_total
create_invoice
send_confirmation
update_inventory
notify_warehouse
end
# After (extract methods)
def process_order
prepare_order
complete_order
post_order_tasks
end
private
def prepare_order
validate_items
calculate_totals
end
def calculate_totals
calculate_subtotal
apply_discounts
calculate_tax
calculate_shipping
finalize_total
end
def complete_order
create_invoice
send_confirmation
end
def post_order_tasks
update_inventory
notify_warehouse
end
ABC = Assignments, Branches, Conditions
# Before (high ABC)
def process(user)
if user.active?
user.name = params[:name]
user.email = params[:email]
user.role = params[:role]
user.save!
notify(user)
end
end
# After (lower ABC)
def process(user)
return unless user.active?
update_user_attributes(user)
user.save!
notify(user)
end
def update_user_attributes(user)
user.assign_attributes(user_params)
end
def user_params
params.slice(:name, :email, :role)
end
# Before
has_many :posts
# After
has_many :posts, dependent: :destroy
# or
has_many :posts, dependent: :nullify
# Before
has_many :posts
belongs_to :user
# After
has_many :posts, inverse_of: :user
belongs_to :user, inverse_of: :posts
When a violation is intentional:
# Disable for line
some_code # rubocop:disable Style/SomeCop
# Disable for block
# rubocop:disable Style/SomeCop
some_code
more_code
# rubocop:enable Style/SomeCop
# Disable for file (at top)
# rubocop:disable Style/SomeCop
For legacy codebases with many violations:
# Generate .rubocop_todo.yml with all current violations
bundle exec rubocop --auto-gen-config
# Then incrementally fix cops
bundle exec rubocop --only Style/StringLiterals -a
After fixing violations:
bundle exec rubocop outputThis 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.