reversa-restructure

Refactors internal method and class structure using Fowler catalog refactorings with gated diffs.

1.5k|405|Updated Apr 26, 2026
One-click install
npx skills add https://github.com/sandeco/reversa --skill reversa-restructure
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: reversa-restructure
Source: https://github.com/sandeco/reversa/tree/main/agents/reversa-restructure
Command: npx skills add https://github.com/sandeco/reversa --skill reversa-restructure

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Legacy code often contains tangled methods and classes that are risky to clean up because there is no safety net proving behavior stays intact. This Skill applies named Fowler refactorings in small, reversible steps while mechanically proving the observable behavior never changes.

Core Features & Use Cases

  • Named Fowler Refactorings: Identifies code smells and applies catalog refactorings such as Extract Method, Rename, Decompose Conditional, and Remove Duplication, one named step at a time.
  • Mandatory Safety Net: Verifies existing test coverage before touching code, and offers to generate Feathers-style characterization tests that pin current behavior when coverage is missing.
  • Gated Control Mode: Every code change passes through an approval gate showing the before/after diff, and any red test run triggers an automatic revert instead of silent persistence.
  • Use Case: You inherit a legacy module with a 200-line method full of conditionals. The Skill plans a sequence of Extract Method and Decompose Conditional steps, generates an HTML plan for approval, applies each step behind a diff gate, and proves the test suite stays green before and after.

Quick Start

Ask the agent to run /reversa-restructure on a specific opportunity ID or describe a method you want cleaned up, then approve the plan and each diff as it is presented.

Frequently Asked Questions about reversa-restructure

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

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

Apply named Fowler refactorings in small reversible steps while a test safety net proves behavior stays intact. This Skill identifies code smells, plans the refactoring sequence, and gates every code change behind an approved diff with green test evidence.

What are characterization tests and when do I need them?

Characterization tests (Feathers-style) pin the current observable behavior of code, including behavior that looks wrong, before refactoring. This Skill offers to generate them when the target lacks coverage, so refactoring only proceeds with mechanical proof of preservation.

Can this Skill move modules or change dependencies?

No. Its scope is strictly internal structure of a method or class. Targets involving module redistribution or dependency topology changes are rejected and redirected to the appropriate refactoring verb in the reversa framework.

What happens if tests fail after a refactoring step?

The change is reverted via its diff and the Skill does not silently persist. Every step must show the safety net green before and after; anything that cannot prove preservation stops at the approval gate.

Do I need to run anything before using reversa-restructure?

Yes. You must run /reversa-refactor first to inventory refactoring opportunities, since this Skill reads the _reversa_refactor/ directory for control mode and safety net policy. Without it, the Skill aborts with instructions to run the inventory step.