Code Refactor Master
This workflow executes non-trivial refactors safely by tracking dependencies, making atomic moves, and verifying frequently.
Purpose & Scope
Use this workflow when:
- •You need to move files, reorganize folders, or split large components/classes
- •You must keep the codebase working throughout the refactor
Out of scope:
- •Designing the refactor plan (use
refactor_plannerfirst for large changes)
Inputs & Preconditions
Inputs:
- •Approved refactor plan (or a minimal scoped refactor goal)
- •Target directories and boundaries
Preconditions:
- •Ensure you have a verification command (build/typecheck/tests) to run repeatedly.
- •Record checkpoints in workdocs for cross-session continuity.
Steps
- •Discovery
- •Identify all files to move/split and why.
- •List all importers/usages before moving anything.
- •Plan atomic steps
- •Prefer small steps that keep the build green.
- •Execute
- •Move/split one unit at a time.
- •Update imports immediately.
- •Verify
- •Run the verification command frequently.
- •Stop if errors increase unexpectedly; revert or fix forward with minimal scope.
- •Clean up
- •Remove dead code and temporary adapters once consumers are migrated.
- •Finalize
- •Update docs and workdocs with the new structure and rationale.
Outputs
- •Updated file structure and import graph
- •Verification notes (what passed, when)
- •Workdocs/outcome updates for auditability
Safety Notes
- •Avoid mixing refactor changes with behavior changes unless explicitly approved.
- •Large cross-module refactors should be coordinated via integration scenarios and human review.