Safe Refactoring with Code Intelligence
Before refactoring
- Run
codemap --deps . to understand the dependency graph
- Identify hub files in the refactoring scope: they need extra care
- Run
codemap --diff to see what's already changed on this branch
Refactoring checklist
- All tests pass before starting
- Hub files identified and dependents listed
- Public API changes planned (additive preferred)
- Import paths updated if moving files
- No circular dependencies introduced
Safe rename pattern
- Add the new name alongside the old (alias/wrapper)
- Update all callers to use the new name
- Remove the old name
- Run full test suite
Safe move pattern
- Create the new file with the same API
- Re-export from the old location (temporary)
- Update all importers to use the new path
- Remove the old file and re-export
After refactoring
- Run
codemap --deps . again to verify the graph is clean
- Run
codemap --importers <moved-file> to check nothing is broken
- Full test suite must pass