refactor

Refactor code to remove structural, quality, and efficiency smells without changing behavior.

88|6|Updated Mar 25, 2026
One-click install
npx skills add https://github.com/heliohq/ship --skill refactor-heliohq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/heliohq/ship/tree/main/skills/refactor
Command: npx skills add https://github.com/heliohq/ship --skill refactor-heliohq

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill improves existing code by removing smells, simplifying logic, and reducing duplication while preserving behavior and keeping verification front and center.

Core Features & Use Cases

  • Structural Cleanup: Break up long methods, remove dead code, and consolidate repeated logic so the next change is easier.
  • Reuse and Quality Fixes: Replace hand-rolled helpers with existing utilities, normalize naming, and remove unnecessary comments or redundant state.
  • Verification Discipline: Refactor in small batches and validate each step so local edits stay safe and predictable.

Quick Start

Refactor the selected code path while preserving behavior, then run the repository's tests to confirm the result.

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 to remove duplication without changing behavior?

To refactor code without behavior drift, you must apply behavior-preserving edits in small batches, simplify functions, and verify the results with tests before and after each change. This ensures structural cleanup maintains predictable execution.

What is the best way to clean up dead code and simplify long methods in production repositories?

The best way to clean up dead code and simplify long methods is through evidence-based scanning and incremental edits. Breaking up logic and deleting unused state in small batches keeps production repositories stable and maintainable.

Can I consolidate cross-file duplication and reuse helpers without breaking my tests?

Yes, you can consolidate cross-file duplication and replace hand-rolled helpers with existing utilities by refactoring in small batches. Running tests before and after each change batch ensures behavior preservation and prevents test breakage.

How does behavior-preserving refactoring handle redundant state and unnecessary comments?

Behavior-preserving refactoring handles redundant state and unnecessary comments by normalizing naming conventions and removing obsolete inline documentation. It executes these quality fixes incrementally, validating each step with repository tests to prevent drift.

When should I avoid refactoring code in a production repository?

You should avoid refactoring code in a production repository when you lack sufficient test coverage for evidence-based scanning. Without tests to verify behavior before and after each change batch, structural edits risk introducing unpredictable behavior drift.

Does the refactor approach work for local file edits and broader module cleanup?

Yes, the refactor approach works for both local file edits and broader module cleanup. It applies evidence-based scanning to resolve structural, quality, and efficiency smells across varying scopes while requiring test verification to maintain behavior.