tdd-refactor-guard

Verify test coverage before applying AI-assisted code refactoring changes.

27|5|Updated Apr 18, 2026
One-click install
npx skills add https://github.com/bocan/bocan-music --skill tdd-refactor-guard-bocan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd-refactor-guard
Source: https://github.com/bocan/bocan-music/tree/main/.claude/skills/testing/tdd-refactor-guard
Command: npx skills add https://github.com/bocan/bocan-music --skill tdd-refactor-guard-bocan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactoring existing code without sufficient test coverage often leads to undetected regressions, broken functionality, and hours of debugging to identify what changed during the modification process.

Core Features & Use Cases

  • Pre-refactor coverage check: Scans for existing tests targeting code marked for refactoring, and assesses coverage levels for all public methods and edge cases.
  • Test quality validation: Flags low-value tests that verify implementation details instead of observable behavior, ensuring tests will actually catch regressions.
  • Characterization test guidance: Directs creation of missing tests to lock in current code behavior before any refactoring work begins, eliminating the risk of accidental functional changes.
  • Use case: If you are planning to refactor a legacy user authentication module in your iOS app, this skill first verifies you have tests covering all login success, failure, and edge cases, and helps you create missing tests if needed before you make any changes.

Quick Start

Use the tdd-refactor-guard skill to verify test coverage for the PaymentProcessor class before you refactor its refund handling logic.

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 refactoring code without test coverage?

Test coverage validation before refactoring involves scanning target code for existing tests, assessing public method coverage, and generating missing characterization tests to lock in current behavior. This prevents accidental functional changes by validating observable behavior prior to modifications.

What are characterization tests and when do I need them for code restructuring?

Characterization tests are tests created to lock in the current behavior of existing code before refactoring begins. You need them when restructuring methods or extracting logic without sufficient test coverage, ensuring the refactored output preserves the original observable behavior.

How do I check existing test quality before an AI-assisted framework migration?

To check test quality before an AI-assisted framework migration, validate that tests verify observable behavior rather than implementation details. Flagging low-value tests ensures your suite will actually catch regressions instead of passing trivial assertions during the migration.

Can I use this refactoring approach for legacy modules with missing tests?

Yes, this refactoring approach works for legacy modules by first identifying the target code scope, assessing existing test coverage, and generating missing tests to cover public methods and edge cases before any restructuring or method extraction begins.

Why does refactoring break functionality even when existing tests pass?

Refactoring breaks functionality when existing tests pass because low-value tests verify implementation details rather than observable behavior. Validating test quality and adding characterization tests prevents undetected regressions by ensuring tests actually catch functional changes.