refactor

Refactor code iteratively with test-gated validation after each step.

198|19|Updated May 7, 2026
One-click install
npx skills add https://github.com/testdouble/han --skill refactor-testdouble
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/testdouble/han/tree/main/han-coding/skills/refactor
Command: npx skills add https://github.com/testdouble/han --skill refactor-testdouble

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Restructure existing code without changing its behavior through a bounded, test-gated refactoring loop. It enables safer design improvements, readability enhancements, and cleanup after feedback from reviews or architectural analyses.

Core Features & Use Cases

  • Named refactor steps with a green-to-green discipline to preserve behavior.
  • A plan-driven workflow that bounds scope and records evidence for each change.
  • Use after code reviews or architecture analyses to apply targeted improvements without feature changes.

Quick Start

Start a safe refactor session by outlining a target, run the green suite, and proceed with one named refactoring at a time.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I refactor existing code without changing its behavior?

To refactor code without changing behavior, apply a green-to-green discipline by running your test suite before and after each named refactoring step. This iterative, test-gated loop ensures observable behavior remains unchanged while you restructure the internal design.

What's the best way to plan a safe code refactor?

The best way to plan a safe code refactor is using a plan-then-execute workflow that bounds the scope of changes. Outline a target refactoring goal, record evidence for each step, and proceed one named refactoring at a time to avoid unintended behavior changes.

When do I need a stepwise refactoring workflow?

You need a stepwise refactoring workflow after code reviews or architecture analyses to apply targeted improvements safely. It bounds the scope of cleanup tasks, ensuring readability enhancements and design improvements do not accidentally alter production features.

Can I use this refactoring approach on both production and test code?

Yes, this refactoring approach applies to both existing production and test code. It guides you through named refactorings within a bounded scope, ensuring static checks and tests run alongside edits to preserve observable behavior across the entire codebase.

How does the green-to-green refactoring process work?

The green-to-green refactoring process works by validating a passing test suite before and after every individual code change. This enforces a bounded, iterative loop where named refactorings are applied sequentially, ensuring behavior remains unchanged throughout the restructuring.

What are the limitations of bounded scope refactoring?

Bounded scope refactoring limits changes to predefined targets, preventing large-scale architectural overhauls within a single session. You should not use this approach for feature additions; it is strictly for design improvements and cleanup where preserving exact observable behavior is required.