reversa-modularize

Splits oversized code sections into cohesive modules with defined responsibilities without changing observable behavior.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Legacy codebases accumulate large code sections that mix multiple responsibilities, making them hard to maintain and risky to change. This Skill divides such sections into smaller, cohesive modules with well-defined responsibilities while guaranteeing that observable behavior never changes.

Core Features & Use Cases

  • Responsibility Mapping: Analyzes the target code, maps mixed responsibilities, and proposes a module boundary with a single declared responsibility per part.
  • Gated Refactoring: Every code-touching step passes through an approval gate with a full diff of moved files, created interfaces, and updated imports before anything is applied.
  • Safety Net Enforcement: Requires test coverage of the affected behavior before moving code, offering characterization tests (Feathers-style) when coverage is missing, and reverts via diff if tests go red.
  • Use Case: A legacy service class handles validation, persistence, and notification in one 800-line method. The Skill proposes three modules with clear interfaces, generates a self-contained HTML plan for approval, applies the moves after gate approval, and proves behavior preservation with a green test run.

Quick Start

Run /reversa-modularize with an opportunity ID or a target code section to split it into cohesive modules under an approved, test-protected plan.

Frequently Asked Questions about reversa-modularize

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

FAQPage Schema
How do I split a large legacy code section into modules safely?

Run the modularize skill on the target section. It maps the mixed responsibilities, proposes module boundaries with single responsibilities, generates an HTML plan for approval, and only moves code after you approve the full diff, with tests proving behavior is preserved.

How to refactor code without changing its behavior?

This skill enforces behavior preservation by requiring a safety net of tests covering the affected behavior before any code is moved. If coverage is missing, it offers characterization tests first, and reverts via the recorded diff if tests fail after the change.

Does reversa-modularize work without running reversa-refactor first?

No. The skill reads control mode and safety net policy from the _reversa_refactor directory and aborts with an instruction to run /reversa-refactor first if that directory does not exist.

Can the modularization change internal method logic or dependencies?

No. The skill has a strict focus on module boundaries and responsibility distribution. It never modifies the internal logic of a method, never inverts dependencies one by one, and never breaks module boundaries defined by the project's soul specification.

What happens if I reject the refactoring plan or tests fail?

Nothing is applied without gate approval, so rejecting the plan leaves the code untouched. If the safety net tests go red after an approved change, the skill reverts the modification using the recorded diff.