tdd-refactoring-agent

Refactor Rails code structure while keeping tests green.

Updated Nov 1, 2025
One-click install
npx skills add https://github.com/nschneble/rails-superstack --skill tdd-refactoring-agent-nschneble
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd-refactoring-agent
Source: https://github.com/nschneble/rails-superstack/tree/main/.agents/skills/tdd-refactoring-agent
Command: npx skills add https://github.com/nschneble/rails-superstack --skill tdd-refactoring-agent-nschneble

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill helps Rails teams apply the TDD REFACTOR phase to improve code structure without risking behavioral changes, ensuring tests remain green as refactors are introduced.

Core Features & Use Cases

  • Enforces a strict TDD cycle (RED → GREEN → REFACTOR) to guide incremental improvements.
  • Guides safe extraction of methods, reduction of complexity, and reorganization across models, controllers, and services.
  • Provides a repeatable workflow and guardrails so teams can refactor with confidence when addressing code smells or maintainability issues.

Quick Start

Provide a step-by-step refactoring plan for a Rails component that preserves behavior while keeping all tests green.

Frequently Asked Questions about tdd-refactoring-agent

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

FAQPage Schema
How do I safely refactor Rails code without changing behavior?

To safely refactor Rails code without changing behavior, apply the TDD REFACTOR phase by ensuring tests are green before making changes, then modify one step at a time to prevent altering functionality.

What is the TDD REFACTOR phase in Rails?

The TDD REFACTOR phase in Rails is the step following the RED and GREEN phases where you improve code structure, extract methods, and reduce complexity while keeping all tests green.

How do I extract methods in Rails while keeping RSpec tests green?

To extract methods in Rails while keeping RSpec tests green, follow a strict workflow: verify tests pass before changes, extract methods one step at a time, and run tests after each modification to ensure behavior remains unchanged.

Does this refactoring approach work across all Rails layers?

Yes, this refactoring approach works across Rails layers including models, controllers, and services, guiding safe method extractions and complexity reduction while enforcing a disciplined workflow to prevent behavior changes.

What are the limitations of refactoring with the TDD REFACTOR phase?

A limitation of refactoring with the TDD REFACTOR phase is that it requires green tests before any changes, meaning you cannot safely refactor if your existing test suite is failing or incomplete.

When do I need a step-by-step refactoring plan for Rails components?

You need a step-by-step refactoring plan for Rails components when addressing code smells or maintainability issues, ensuring you preserve behavior while keeping all tests green during structural improvements.