refactor

Refactor code while preserving public APIs and passing tests.

Updated Feb 13, 2026
One-click install
npx skills add https://github.com/g-zenr/relay-api --skill refactor-g-zenr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/g-zenr/relay-api/tree/main/.claude/skills/refactor
Command: npx skills add https://github.com/g-zenr/relay-api --skill refactor-g-zenr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers refactor code by ensuring that all tests and type safety are maintained throughout the process, preventing regressions and upholding architectural standards.

Core Features & Use Cases

  • Preserves Public API: Ensures function signatures and return types remain unchanged.
  • Maintains Layer Boundaries: Adheres to architectural layers (Core, Service, API) and dependency flow.
  • Ensures Test Coverage: Verifies that all existing tests pass after refactoring.
  • Use Case: When a new feature requires restructuring existing code, this Skill guides the developer to refactor safely, ensuring no existing functionality breaks and the codebase remains maintainable.

Quick Start

Use the refactor skill to refactor the user authentication module.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I refactor code without breaking existing tests or type safety?

To refactor code without breaking tests or type safety, you need a process that verifies all existing tests pass and introduces no new type errors. This approach analyzes dependency graphs and maps architectural layers to prevent regressions while you restructure.

What is the safest way to restructure code across different architectural layers?

Safely restructuring code across architectural layers requires maintaining strict layer boundaries, such as Core, Service, and API. The refactoring process ensures dependency flow adheres to these architectural standards while preserving public APIs during the modification.

How do I maintain public API signatures when modifying underlying code?

Maintaining public API signatures during code modifications requires verifying that function signatures and return types remain unchanged. Safe refactoring practices explicitly check these public interfaces against dependency graphs to ensure external contracts are preserved.

Can I refactor a specific module like user authentication without causing regressions?

Yes, you can refactor a module like user authentication without regressions by ensuring all existing tests pass and type safety is maintained. The process analyzes module dependency graphs to guide safe structural changes without breaking existing functionality.

When should I use an automated refactoring process instead of manual code restructuring?

You should use an automated refactoring process when a new feature requires restructuring existing code and upholding architectural standards is critical. It prevents regressions by systematically verifying tests and types, which manual restructuring often misses.

Does safe refactoring work with existing test suites to verify code quality?

Yes, safe refactoring works directly with existing test suites to verify code quality by ensuring all tests pass after code modifications. It integrates type safety checks and architectural layer mapping to guarantee the codebase remains maintainable.