Reduce Max Class/Module Lines

VerifiedSafe

Reduces the maximum lines threshold for classes and modules in RuboCop, identifies violations, and generates a refactoring plan with strategies to split oversized files.

Sby Skills Guide Bot
DevelopmentIntermediate
306/2/2026
Claude Code
#ruby#rubocop#refactoring#code-quality

Recommended for

Our review

This skill updates the RuboCop configuration to reduce the maximum lines threshold per class/module and fixes all resulting violations.

Strengths

  • Automates RuboCop configuration updates
  • Identifies classes and modules exceeding the new limit
  • Provides concrete refactoring strategies

Limitations

  • Requires the project to use RuboCop
  • Only creates a plan, does not modify source code directly
  • Assumes the user will review and execute the plan
When to use it

When you want to enforce a stricter line limit for classes/modules in a Ruby project.

When not to use it

If the project does not use RuboCop or if the target threshold is not yet finalized.

Security analysis

Safe
Quality score85/100

The skill only runs RuboCop via bundle exec with fixed options, reads local config files, and compiles a brief. No destructive, exfiltrating, or obfuscated actions. Standard development tool usage.

No concerns found

Examples

Reduce to 100 lines
Use plan-reduce-max-lines to reduce the class/module line limit to 100 and fix violations.
Target 80 lines
Reduce max class lines to 80 and generate a refactoring plan.
Apply new threshold
Run plan-reduce-max-lines with threshold 120.

name: plan-reduce-max-lines description: This skill should be used when reducing the maximum class/module lines threshold and fixing all violations. It updates the RuboCop configuration, identifies classes and modules exceeding the new limit, generates a brief with refactoring strategies, and creates a plan with tasks to split oversized files. allowed-tools: ["Read", "Bash", "Glob", "Grep"]


Reduce Max Lines

Target threshold: $ARGUMENTS lines per class/module

If no argument provided, prompt the user for a target.

Step 1: Gather Requirements

  1. Read current config from .rubocop.yml or .rubocop.local.yml (Metrics/ClassLength and Metrics/ModuleLength)
  2. Run RuboCop with the target threshold to find violations:
    bundle exec rubocop --only Metrics/ClassLength,Metrics/ModuleLength --format json 2>&1
    
  3. Note for each violation:
    • File path
    • Class/module name
    • Current line count

If no violations at $ARGUMENTS, report success and exit.

Step 2: Compile Brief and Delegate

Compile the gathered information into a structured brief:

Reduce max class/module lines threshold to $ARGUMENTS.

Classes/modules exceeding threshold (ordered by line count):
1. [file:ClassName] - [current] lines (target: $ARGUMENTS)
2. ...

Configuration change: .rubocop.local.yml, Metrics/ClassLength Max to $ARGUMENTS, Metrics/ModuleLength Max to $ARGUMENTS

Refactoring strategies: extract concerns, extract service objects, remove duplication, delete dead code, simplify logic

Verification: `bundle exec rubocop --only Metrics/ClassLength,Metrics/ModuleLength --format simple 2>&1 | grep "offense" | wc -l` -> Expected: 0

Invoke /plan-execute with this brief to create the implementation plan.

Related skills