Procedure
- •Identify the refactoring goal (clarity, modularity, performance, API stability).
- •Ensure tests exist for current behavior (add if missing).
- •Refactor in small steps; run tests after each step.
- •Remove dead code (trust git history).
- •Run
ruffand ensure the pipeline still runs. - •Update docs if interfaces change.
Guardrails
- •Do not change scientific behavior unless requested.
- •If behavior must change, document the change and update tests.