Engineering
refactoring-patterns avatar

refactoring-patterns

Apply safe, incremental refactoring patterns to improve code maintainability and reduce technical debt while strictly preserving existing behavior through automated test verification.

Introduction

The refactoring-patterns skill provides a rigorous framework for software agents to improve code quality without introducing regressions. Designed for developers and quality engineers, this skill emphasizes a disciplined, test-first approach to technical debt reduction. It guides agents through the lifecycle of identifying code smells, proposing structural improvements, and verifying that the system's output remains identical before and after each transformation. By strictly enforcing the Rule of Three and ensuring that tests remain green, this skill prevents the common pitfalls of premature abstraction and 'big bang' rewrites, favoring small, incremental steps that minimize risk in complex codebases.

  • Automated identification of code smells such as long methods, large classes, and deep nesting.

  • Support for standard refactoring patterns including Extract Method, Extract Class, Introduce Parameter Object, Decompose Conditional, and Replace Loop with Pipeline.

  • Integration with test-executor agents to provide a safety net for every atomic change.

  • Orchestration with fleet-level agents like qe-quality-analyzer and qe-test-refactorer to enable TDD-style refactoring cycles.

  • Semantic management of technical debt through a dedicated memory namespace for tracking smells, suggestions, and verification logs.

  • Always ensure a comprehensive test suite exists before starting any refactoring task; if tests are missing, focus on test generation first.

  • Use atomic git commits for each distinct refactoring step to simplify potential rollbacks.

  • Avoid refactoring code that is stable, well-understood, or nearing critical project deadlines.

  • Expected input includes a target codebase, module, or specific function needing cleanup; outputs consist of refactored code blocks and verification reports from test suites like Jest, Vitest, or pytest.

  • The skill strictly forbids behavioral changes, performance-only tuning, or feature additions during refactoring sessions.

Repository Stats

Stars
329
Forks
65
Open Issues
4
Language
TypeScript
Default Branch
main
Sync Status
Idle
Last Synced
Apr 28, 2026, 12:45 PM
View on GitHub