Use this skill after a monolithic file has been split into smaller modules.
Objective
Complete cleanup without changing behavior:
- Archive the original monolithic file
- Remove redundant module paths
- Preserve existing public API access patterns
- Verify the refactor tree is stable and buildable
Required Cleanup Steps
- Archive the original monolithic file before deleting it:
- Copy or move it to
src/_archive/ - Rename with
.baksuffix (example:src/_archive/foo.rs.bak)
- Copy or move it to
- Delete (cull) the original monolithic source file from
src/once replacement modules are in place. - Avoid duplicate module paths:
- Do not keep both
foo.rsandfoo/mod.rs - Keep only one module path strategy for each module
- Do not keep both
- Keep public APIs stable by re-exporting from
mod.rs(or equivalent index file) as needed.
Cleanup Checklist
- Remove unused imports introduced during the split.
- Verify
mod.rs(or index file) re-exports all intended public items. - Update
lib.rsor parent module declarations to point to the new module path. - Confirm only the archived
.bakfile remains from the original monolith. - Run a quick build or targeted tests related to the refactored module.
Scope Guardrails
- Do not change runtime behavior unless explicitly requested.
- Keep cleanup focused on module-path consistency and API continuity.
- Avoid broad opportunistic refactors while performing cleanup.