tdd-refactor

Refactor production code incrementally while preserving behavior and green tests.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/nikoheikkila/agents --skill tdd-refactor-nikoheikkila
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd-refactor
Source: https://github.com/nikoheikkila/agents/tree/main/skills/tdd-refactor
Command: npx skills add https://github.com/nikoheikkila/agents --skill tdd-refactor-nikoheikkila

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Improve code quality, apply best practices, and enhance design whilst maintaining green tests. Use after tests pass and the code needs cleanup, or when code smells need addressing, without changing behavior.

Core Features & Use Cases

  • Remove duplication and simplify long methods and large classes.
  • Apply SOLID principles to improve modularity and testability.
  • Ensure refactoring is incremental, with tests remaining green and behavior preserved.

Quick Start

Describe the code you want improved and initiate a safe, incremental refactor pass to reduce duplication and improve design while preserving behavior.

Frequently Asked Questions about tdd-refactor

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

FAQPage Schema
How do I refactor code safely without breaking existing behavior?

To refactor safely after tests pass, apply incremental changes to your codebase while continuously verifying tests stay green. This removes duplication and improves readability without altering behavior or public APIs.

What is the best way to apply SOLID principles during a TDD cycle?

The best way to apply SOLID principles during a TDD cycle is to refactor immediately after tests pass. This improves modularity and testability by incrementally simplifying large classes and long methods without changing functionality.

When should I perform code cleanup in a test-driven development workflow?

Code cleanup in a test-driven development workflow should be performed after tests pass and the code needs design improvements. It addresses code smells and duplication incrementally while ensuring the existing behavior remains unchanged.

Does incremental refactoring preserve public APIs in production codebases?

Yes, incremental refactoring preserves public APIs in production codebases. It applies safe techniques to modify internal structures, simplify methods, and update inline documentation without exposing breaking changes to external consumers.

Can I remove code duplication while keeping my test suite green?

Yes, you can remove code duplication while keeping your test suite green by executing small, incremental refactoring passes. These passes simplify long methods and large classes while continuously validating that behavior remains unchanged.