| name | redesign |
| description | Refactor and improve existing code while preserving behavior, using incremental, verifiable changes to reduce complexity and improve maintainability. Use when updating existing implementations, simplifying architecture, or restructuring legacy code without changing external contracts unless explicitly requested. |
Redesign Workflow
Inputs
scope: existing file(s), module, package, or subsystem to refactor.
constraints (optional): compatibility, performance, rollout, or deadline constraints.
aggressiveness (optional): conservative (default), moderate, or broad.
References
For design implementation, invoke the $design skill
Procedure
- Establish baseline behavior (tests, interfaces, invariants, runtime expectations).
- Identify design debt in existing code (complexity, coupling, unclear boundaries, naming issues).
- Build a refactor sequence of small reversible steps.
- Apply steps incrementally while preserving behavior.
- Validate after each step (tests/lint and focused runtime checks).
- Update docs/comments for changed structure or rationale.
- Summarize improvements and remaining debt.
Refactor Priorities
- Reduce nesting and mixed abstraction levels.
- Split oversized functions/modules.
- Clarify boundaries and ownership of side effects.
- Improve naming consistency and intent clarity.
- Remove dead code and redundant indirection.
Rules
- Preserve external behavior unless change is explicitly requested.
- Prefer incremental, verifiable refactors over broad rewrites.
- Keep compatibility constraints explicit.
- Stop and call out risks when safe migration path is unclear.
Output Contract
- Refactor plan (baseline + sequence of steps).
- Structural changes made and why.
- Validation evidence and compatibility status.
- Remaining technical debt or next-step recommendations.