- Home
- Skills
- Ag0os
- Rails Dev Plugin
- Ruby Refactoring
ruby-refactoring_skill
3
GitHub Stars
3
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill ag0os/rails-dev-plugin --skill ruby-refactoring- code-smells.md8.4 KB
- refactoring-patterns.md10.7 KB
- SKILL.md8.8 KB
Overview
This skill provides automated, pragmatic Ruby and Rails refactoring guidance based on Ruby Science principles. It identifies common code smells, prioritizes issues by impact, and proposes concrete refactoring patterns with before/after examples. It is designed to improve maintainability, readability, and testability for recently written code.
How this skill works
When invoked on Ruby or Rails code, the skill scans for known code smells (long methods, large classes, duplication, excessive parameters, feature envy, etc.). It ranks findings by severity and business impact, suggests specific refactor patterns (extract method/class, service objects, parameter objects, polymorphism), and outlines tests and migration steps. Recommendations emphasize small, verifiable changes and adherence to Ruby idioms and Rails conventions.
When to use it
- During code reviews or pull request analysis for newly written Ruby/Rails code
- When teams mention technical debt, code smells, or requests to refactor
- Before or during a planned refactor to prioritize low-risk, high-impact changes
- When tests are failing or coverage is unclear and refactoring must be safe
- To align code with Ruby idioms, SOLID principles, and Rails conventions
Best practices
- Start with high-impact, low-risk refactors and keep changes incremental
- Ensure tests cover behavior before refactoring and add tests where gaps exist
- Prefer descriptive, small methods and single-responsibility classes
- Use Ruby enumerables, symbols, and Rails scopes to simplify code
- Document trade-offs and performance considerations for each refactor step
Example use cases
- Convert a long controller action into a service object with transaction handling
- Extract methods from a 30-line model method and add private helpers to improve readability
- Replace a large case statement with polymorphic subclasses or strategy objects
- Introduce a parameter object when a constructor or method accepts more than three related parameters
- Split a fat User model into User, UserProfile, and a notifier class to separate concerns
FAQ
I prioritize by safety and impact: fix security and correctness issues first, then high-maintainability smells that are cheap to change (duplication, long methods). Large structural refactors follow once tests and low-risk edits are done.
Will refactoring change behavior?
Refactoring should preserve behavior. I require tests before refactoring, recommend adding coverage for edge cases, and propose small, test-backed steps to detect regressions early.