refactor

Generates incremental, behavior-preserving refactor plans for codebases and test suites.

30|2|Updated Apr 28, 2026
One-click install
npx skills add https://github.com/hawkyre/hawk-skills --skill refactor-hawkyre
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/hawkyre/hawk-skills/tree/main/skills/refactor
Command: npx skills add https://github.com/hawkyre/hawk-skills --skill refactor-hawkyre

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactor existing code to improve readability, modularity, performance, type safety, or reduce duplication without altering external behavior or breaking tests. It guides teams to plan, execute, and verify incremental changes that maintain the original contract.

Core Features & Use Cases

  • Incremental, safe steps: makes small, reviewable diffs that preserve behavior.
  • One-dimensional refactors: restricts each change to a single optimization goal to reduce risk.
  • Plan, execute, verify: loads standards, outlines steps, and validates with tests after each step.
  • Documentation & risk flags: records rationale, tradeoffs, and potential edge cases for reviewer awareness.

Quick Start

Provide the codebase, constraints, and testing context, and I will output an incremental refactor plan that preserves behavior.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I refactor code to improve readability and modularity without breaking existing tests?

Safe refactoring requires making small, incremental changes that preserve external behavior. By restricting each change to a single optimization goal like readability or modularity, you reduce risk and ensure tests pass after every step.

What is the safest way to reduce code duplication across a large codebase?

Reducing code duplication safely involves an incremental, one-dimensional approach where each step targets only deduplication while preserving the external API. You plan, execute, and verify each change with your test suite to catch behavior alterations early.

Can I improve type safety and performance in my codebase without altering its external contract?

Yes, you can improve type safety and performance by applying incremental refactors that isolate each optimization goal. This process maintains the original contract by validating every small diff against your test suite before moving forward.

How do I plan and execute incremental refactors that maintain the original API?

You plan and execute incremental refactors by loading standards, outlining steps, and validating with tests after each step. This ensures every small, reviewable diff preserves the external API and leaves tests passing.

What are the limitations of one-dimensional refactoring for code quality?

One-dimensional refactoring restricts each change to a single optimization goal to reduce risk, meaning you cannot address readability, performance, and type safety simultaneously. You must also document tradeoffs and flag potential edge cases for reviewer awareness.

Does the refactor approach work with any programming language and test suite?

Yes, the approach targets codebases across languages and test suites needing improved code quality. As long as you provide the codebase, constraints, and testing context, it generates a safe, incremental plan that preserves behavior.