tdd-refactor-guard

Verify test coverage and generate characterization tests before code refactors.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/mazicimert/RunDom --skill tdd-refactor-guard-mazicimert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd-refactor-guard
Source: https://github.com/mazicimert/RunDom/tree/main/.claude/skills/testing/tdd-refactor-guard
Command: npx skills add https://github.com/mazicimert/RunDom --skill tdd-refactor-guard-mazicimert

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pre-refactor safety checklist verifies that tests exist before AI modifies existing code, preventing regressions and unknown behavior during automated refactors.

Core Features & Use Cases

  • Identifies the scope of the code to be refactored by asking or inferring from context.
  • Checks existing test coverage and assesses quality to determine readiness for refactoring.
  • Generates characterization tests when coverage is insufficient and provides guidance for safe changes.

Quick Start

Before refactoring any class, run the Refactor Guard to assess test coverage and generate characterization tests if needed.

Frequently Asked Questions about tdd-refactor-guard

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

FAQPage Schema
How do I prevent regressions when using AI to refactor code?

To prevent regressions during AI-assisted refactoring, enforce a safety gate that verifies existing test coverage before modifying code. This ensures baseline behavior is documented and protected against unknown changes.

What are characterization tests and when do I need them for a refactor?

Characterization tests capture the current behavior of existing code before refactoring. You need them when test coverage is insufficient, ensuring safe modifications by establishing a behavioral baseline to detect regressions.

How do I check if my code has enough test coverage for a safe refactor?

Assess test coverage readiness by checking existing tests and evaluating their quality. If coverage is insufficient for the refactoring scope, generate characterization tests to establish behavioral safeguards before modifying code.

Can I use a safety checklist before refactoring public API or behavior?

Yes, a pre-refactor safety checklist is specifically applicable when planning code restructures or migrations that affect public API or behavior. It enforces guardrails and guides safe changes to prevent regressions.

What is the best way to automate test generation for a code migration?

Automate test generation by identifying the refactor scope, checking existing coverage, and generating characterization tests where coverage is insufficient. This provides a safety net to guide safe code migrations.

What happens if I skip test coverage checks before an AI-assisted refactor?

Skipping test coverage checks before AI-assisted refactoring risks introducing regressions and unknown behavior changes. Without characterization tests, there is no baseline to verify that the refactored code preserves original functionality.