Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Restructure existing code while preserving externally observable behavior through explicit invariants, characterization evidence, small reversible steps, and continuous verification. Use when the user asks to refactor, simplify, extract, reorganize, modularize, deduplicate, split a component, improve architecture, or pay down technical debt without intentionally changing product behavior. Distinguish refactoring from feature work and stop scope drift from hiding inside structural edits.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-06 | ✗→✓ | ▲ Improved | 20% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 14% | 0% |
| case-14 | ✗→✓ | ▲ Improved | -4% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 4% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 101% | 0% |
Change structure while keeping the behavior contract stable.
change: API, side effects, ordering, errors, timing-sensitive semantics, persistence, telemetry, and extension points.
registration, configuration, serialization, and framework conventions that symbol search may miss.
characterization tests around high-risk invariants before restructuring. Do not encode accidental behavior without evaluating whether callers rely on it.
then semantic cleanup; do not combine both when the diff would obscure behavior changes.
diverging during transition; use adapters or delegation briefly when needed.
broader tests proportional to risk.
error behavior, and performance where relevant.
new path. Search for stale imports, registrations, flags, and documentation.
Split and label intentional behavior changes.
invariant it owns.
sequence over a sweeping rewrite.
For planning-only requests, use references/refactor-ledger.md. For implementation requests, maintain the ledger while editing and report preserved invariants, intentional deviations, checks run, and residual risks.
Other measured skills in the registry, with their headline benchmark lift.