tdd-refactoring-agent

Refactor Ruby on Rails code while keeping RSpec tests green.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/mlbright/notes --skill tdd-refactoring-agent
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd-refactoring-agent
Source: https://github.com/mlbright/notes/tree/main/.github/skills/tdd-refactoring-agent
Command: npx skills add https://github.com/mlbright/notes --skill tdd-refactoring-agent

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill automates the process of improving code quality during the REFACTOR phase of Test-Driven Development (TDD), ensuring that code structure is enhanced without altering existing functionality.

Core Features & Use Cases

  • Automated Refactoring: Applies proven refactoring patterns to improve code readability, maintainability, and structure.
  • Test Suite Integration: Runs the full test suite before and after each refactoring step to guarantee that all tests remain green.
  • Use Case: You have a complex method in a Rails model that violates the Single Responsibility Principle. Use this Skill to automatically extract the logic into smaller, more focused private methods, ensuring all RSpec tests continue to pass.

Quick Start

Use the tdd-refactoring-agent skill to refactor the app/services/user_service.rb file by extracting methods.

Frequently Asked Questions about tdd-refactoring-agent

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor Rails code while keeping RSpec tests green?

To refactor Rails code while keeping RSpec tests green, apply established refactoring patterns during the TDD REFACTOR phase and run the full test suite after each incremental change to verify all tests still pass.

What is the best way to extract methods from a complex Rails model without breaking functionality?

The best way to extract methods from a complex Rails model without breaking functionality is to extract logic into smaller, focused private methods and run RSpec tests before and after each change to guarantee the behavior remains unchanged.

Can I use this TDD refactoring approach on Rails controllers and services, or only models?

You can use this TDD refactoring approach on Rails controllers, services, and models. It targets multiple Ruby on Rails components, applying incremental structural improvements while ensuring all RSpec tests remain green.

When should I perform refactoring in the TDD cycle?

You should perform refactoring during the REFACTOR phase of the TDD cycle, which follows the RED and GREEN phases. This ensures the code structure is improved only after the tests are written and passing.

Does automated refactoring violate the Single Responsibility Principle in Ruby on Rails?

Automated refactoring resolves Single Responsibility Principle violations in Ruby on Rails by extracting complex logic from large methods into smaller, more focused private methods, improving overall code readability and maintainability.