qfai-tdd-refactor

Refactor codebases while preserving behavior and passing automated tests.

3|Updated Dec 24, 2025
One-click install
npx skills add https://github.com/aganesy/QFAI --skill qfai-tdd-refactor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: qfai-tdd-refactor
Source: https://github.com/aganesy/QFAI/tree/main/packages/qfai/assets/init/.qfai/assistant/skills/qfai-tdd-refactor
Command: npx skills add https://github.com/aganesy/QFAI --skill qfai-tdd-refactor

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enables the safe refactoring of existing code without altering its external behavior, ensuring that all tests remain green and the code's integrity is preserved.

Core Features & Use Cases

  • Behavior-Preserving Refactoring: Restructure code for better maintainability, readability, or performance without introducing regressions.
  • Test Alignment: Ensures that existing unit, integration, and end-to-end tests continue to pass after refactoring.
  • Use Case: A developer needs to improve the internal structure of a complex function to make it more testable and easier to understand. They use this Skill to perform the refactoring, confident that the function's behavior and test results will remain unchanged.

Quick Start

Use the qfai-tdd-refactor skill to refactor the code for spec-id 'spec-123'.

Frequently Asked Questions about qfai-tdd-refactor

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

FAQPage Schema
How do I refactor code without breaking existing tests?

Behavior-preserving refactoring is the process of restructuring code for better maintainability and readability without altering external behavior, ensuring automated tests continue to pass and functional equivalence is strictly maintained.

What is behavior-preserving refactoring?

Behavior-preserving refactoring is the process of restructuring code for better maintainability and readability without altering external behavior, ensuring automated tests continue to pass and functional equivalence is strictly maintained.

How do I improve code maintainability without altering specifications?

Improve code maintainability without altering specifications by orchestrating sub-agents to restructure code, run regression checks, and perform independent reviews while adhering to strict drift protocols and quality gates.

Do I need automated tests to use a TDD refactoring approach?

Yes, TDD refactoring requires existing automated tests because they validate functional equivalence and prevent regressions during structural improvements, ensuring the code's external behavior remains unchanged.

What is the best way to ensure functional equivalence during a code review?

The best way to ensure functional equivalence during a code review is to use automated regression checking and independent review sub-agents that enforce strict drift protocols and quality gates.

Why does refactoring cause test regressions?

Refactoring causes test regressions when structural changes inadvertently alter external behavior; enforcing strict drift protocols and quality gates during the refactor prevents these unintended specification changes.