From majestic-rails
Reviews Rails code for simplicity, identifying anti-patterns, code smells, YAGNI violations, long methods, god objects, and unnecessary abstractions.
How this skill is triggered — by the user, by Claude, or both
Slash command
/majestic-rails:simplicity-reviewerThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Audience:** Rails developers reviewing code for unnecessary complexity
Audience: Rails developers reviewing code for unnecessary complexity Goal: Every line of code is a liability -- minimize them
# BEFORE: Defensive programming adding no value
def process(data)
return if data.nil?
return if data.empty?
return unless data.is_a?(Hash)
# actual processing
end
# AFTER: Trust your inputs at internal boundaries
def process(data)
# actual processing
end
users.index_by(&:id) # Instead of: users.each_with_object({}) { |u, h| h[u.id] = u }
user&.can_access? # Instead of: user && user.active? && user.subscription&.valid?
def process
return unless valid?
return unless authorized?
do_work
end
# BEFORE: Premature abstraction (only one implementation)
class PaymentProcessor
def initialize(gateway)
@gateway = gateway
end
end
# AFTER: Direct implementation until you need another
class PaymentProcessor
def charge(amount)
Stripe::Charge.create(amount: amount)
end
end
Eliminate: Configuration options nobody uses, extensibility points with one implementation, "just in case" error handling, commented-out code.
God Objects: Class doing authentication, email, reports, payment, analytics
Feature Envy: Method uses another object's data excessively
Inappropriate Intimacy: order.customer.address.city -> order.shipping_city
# Consolidate
scope :recently_active, -> { where(status: 'active').where('last_login > ?', 30.days.ago) }
scope :premium, -> { where(plan: 'premium') }
def active_users = User.recently_active
def premium_users = User.recently_active.premium
Search for: TODO, FIXME, HACK, XXX
Apply these lenses systematically:
## Simplification Analysis
### Complexity Score: X/10
(1=minimal, 10=severely over-engineered)
### Core Purpose
[What this code actually needs to do in 1-2 sentences]
### Findings (Priority Order)
| Priority | Location | Issue | Fix | Lines Saved |
|----------|----------|-------|-----|-------------|
| HIGH | file:line | [issue] | [fix] | ~N |
| MED | file:line | [issue] | [fix] | ~N |
### YAGNI Violations
- [Speculative code that should be removed]
### Reduction Estimate
- Current: X lines
- After simplification: Y lines
- **Reduction: Z% (~N lines)**
Remember: The simplest code that works is the best code.
npx claudepluginhub majesticlabs-dev/majestic-marketplace --plugin majestic-railsSimplifies complex/AI-generated code by removing duplication, dead code, over-engineering, and bloat patterns like verbose error handling. Use after features, on long functions (>40 lines), deep nesting (>3), or repeated patterns.
Reviews diffs for over-engineering: reinventing stdlib, unneeded deps, speculative abstractions, dead flexibility. One line per finding with suggested replacement. Complements correctness review.
Reviews Ruby, Rails, and JavaScript code in DHH style for convention violations, JavaScript framework contamination, and unnecessary complexity.