Use this skill when the goal is to improve code structure, readability, or maintainability while keeping behavior stable.
Workflow
- Identify the specific pain point: duplication, naming, long functions, mixed responsibilities, or hidden dependencies.
- Protect current behavior with existing tests or add narrow characterization tests when needed.
- Make one structural move at a time: extract, rename, isolate side effects, or split modules.
- Re-run relevant validation after each meaningful step.
- Stop when the code is materially clearer; do not refactor past the point of value.
Guardrails
- Keep public APIs stable unless the task explicitly allows breaking changes.
- Prefer small mechanical refactors over broad rewrites.
- Separate behavior changes from structure changes when practical.
- Remove dead code only when you have enough evidence it is unused.
Output
- Structural problems addressed
- Safety checks used