Refactor Cleaner
Goal
- Reduce codebase surface area safely: delete unused code, dependencies, exports, and files; consolidate duplicates; keep behavior unchanged.
Workflow
- Define scope and safety constraints (what is allowed to change, public API boundaries, and time budget).
- Collect evidence before deleting:
- Search usages with fast text search.
- Run dead-code detectors and linters when available.
- Classify findings by risk:
- Safe: clearly unused internal exports, unreachable code, unused dependencies.
- Careful: dynamic imports, reflection, config-driven usage, string-based lookups.
- Risky: public APIs, plugin hooks, framework conventions, runtime-only references.
- Apply changes in small batches:
- Remove one category at a time (deps → exports → files → duplicates).
- Run build/typecheck/tests after each batch.
- Record deletions:
- Append a concise entry to the project's deletion log if it exists; otherwise, summarize removals in the final output.
- Stop and ask when evidence is ambiguous.
Output
- Summarize what was removed and why.
- Call out any risky candidates that need human confirmation.
- List verification steps and results (build/test commands run).
Reference
- Read
references/refactor-cleaner.mdfor detailed commands, checklists, and templates.
