refactor-safe

Plan internal code refactoring while preserving public API signatures.

Updated Apr 21, 2026
One-click install
npx skills add https://github.com/li3p/skills --skill refactor-safe-li3p
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-safe
Source: https://github.com/li3p/skills/tree/main/skills/refactor-safe
Command: npx skills add https://github.com/li3p/skills --skill refactor-safe-li3p

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactor internal implementation without changing public API or behavior. Use when improving structure, readability, duplication, or complexity while preserving exported signatures, return shapes, errors, and tests.

Core Features & Use Cases

  • Preserve exported names, signatures, and return shapes while reorganizing internals.
  • Isolate changes to private helpers, reduce duplication, and simplify branches.
  • Maintain public routes, CLI flags, schemas, events, and config keys; ensure error messages and edge-case behavior stay intact unless explicitly approved.

Quick Start

Describe the internal changes you want to make while preserving the public API, and I will guide you through safe, incremental refactoring steps.

Frequently Asked Questions about refactor-safe

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

FAQPage Schema
How do I refactor internal code without changing the public API?

To refactor internal code without changing the public API, you must preserve exported names, signatures, return shapes, and error messages while isolating changes to private helpers and internal components.

What is the best way to reduce code duplication while preserving exported signatures?

The best way to reduce code duplication while preserving exported signatures is to isolate changes to private helpers, simplify internal branches, and maintain public routes and schemas without introducing new dependencies.

How do I plan safe structural improvements for my software library?

Plan safe structural improvements by describing the internal changes you want, then applying incremental refactoring steps that satisfy constraints to preserve tests, return shapes, and edge-case behavior across modules.

Can I simplify internal branches without breaking existing tests?

Yes, you can simplify internal branches without breaking existing tests by ensuring error messages and edge-case behavior stay intact, isolating modifications to private helpers rather than exported signatures.

What are the limitations when refactoring code to maintain public routes and CLI flags?

Limitations include avoiding new dependencies and ensuring error messages, config keys, and events stay intact unless explicitly approved, restricting modifications strictly to internal components and private helpers.

When do I need to preserve return shapes during a code maintenance refactor?

You need to preserve return shapes during a code maintenance refactor whenever you are reorganizing internals for readability or complexity reduction across modules, libraries, and tests without changing public behavior.