Tidy code, one safe change at a time
Prove one small cleanup is safe, make the smallest useful change, and keep it only after existing checks pass.
Use this when
Use this when a code project has accumulated small maintenance problems—unused code, stale files, duplicated logic, broken links, old comments, inconsistent names, or confusing organization—but broad deletion would be risky.
How it runs
- Inspect the current code-project state and identify active branches, uncommitted edits, generated files, configuration, and other work that must not be disturbed.
- Collect possible cleanups, then use code references, configuration, documentation, tests, or runtime behavior to prove one candidate is genuinely low risk.
- Make the smallest useful change and run the existing build, tests, application checks, and diff review; keep it only when behavior stays intact and no unrelated work changes.
- Repeat until no confirmed low-risk cleanup remains, progress stalls, verification is unavailable, or the next candidate needs approval.
Done when
✓ No confirmed low-risk cleanup remains, and existing behavior still passes. Every retained cleanup is supported by direct evidence, relevant builds and tests pass, the application still runs where applicable, unrelated work is untouched, and uncertain candidates are deferred rather than deleted.
Why it works
One proven cleanup at a time keeps the work easy to review and undo. Requiring evidence before deletion—and protecting uncertain files and edits—prevents a tidy-up pass from removing code that is active but poorly understood.
Implementation note
Here, repository means the code project and its files. This loop cleans source and project structure; the separate repository cleanup loop handles Git branches, pull requests, commits, and worktrees. Never delete something merely because its purpose is not immediately obvious.
Source: Forward Future ↗graded C · 63/100 — how grades work (Safety Score v2) →
Similar loops
All refactoring loops →Fix boolean naming across codebase
Scan, plan, and refactor all boolean naming violations across the codebase until 100% green without stopping.
Convert JavaScript to strict TypeScript
Convert all src/ JS files to TypeScript with strict annotations until npm test passes cleanly.
Dead code elimination
Hunt down unreferenced exports, unused files, and unreachable branches, deleting them in small verified steps until the analyzer reports clean.