Dead code elimination
Hunt down unreferenced exports, unused files, and unreachable branches, deleting them in small verified steps until the analyzer reports clean.
/goal `npx knip` reports no unused files or exports — remove one cluster of dead code at a time, run the full test suite and typecheck after each removal, and revert any deletion that breaks them; stop after 15 turns
claude-code · codex · cursor
Implementation note
The delete-verify-revert rhythm makes this safe on codebases with good test coverage; be more cautious on repos with reflection or dynamic imports.
More refactoring loops
Migrate an API import by import
Sweep a codebase from a legacy API to its v2 replacement with tests and typecheck as the safety net, capped at 30 turns.
/goal every file importing from `./legacy-api` now imports from `./v2-api`, all tests pass, and `npm run typecheck` is clean — stop after 30 turns
refactoringmedium risk
Clean out stale repo state
Audit branches, PRs, commits, and worktrees; rescue anything valuable; then delete what's provably stale.
Inspect local and remote branches, pull requests, commits, and worktrees. Recover valuable work and clean everything stale until the repository is current and organized.
refactoringmedium risk
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.
Review [repository or code project] for dead code, meaning unreachable or unused code; stale files or comments; unused dependencies; duplication; broken links; inconsistent names; and confusing structure. Protect unrelated, active, uncommitted, generated, and uncertain work. Prove one low-risk cleanup, make the smallest coherent change, then rerun the build, tests, runtime checks, and diff review. Keep only verified improvements. Stop when none remain, progress stalls, verification is unavailable, or approval is required. Return changes, evidence, and deferred candidates.
refactoringmedium risk