Safely detects and removes dead code using tools like knip, ts-prune, vulture; verifies each deletion with full test suite; categorizes by risk and reports summary.
How this command is triggered — by the user, by Claude, or both
Slash command
/everything-claude-code:refactor-cleanThe summary Claude sees in its command listing — used to decide when to auto-load this command
# Refactor Clean Safely identify and remove dead code with test verification at every step. ## Step 1: Detect Dead Code Run analysis tools based on project type: | Tool | What It Finds | Command | |------|--------------|---------| | knip | Unused exports, files, dependencies | `npx knip` | | depcheck | Unused npm dependencies | `npx depcheck` | | ts-prune | Unused TypeScript exports | `npx ts-prune` | | vulture | Unused Python code | `vulture src/` | | deadcode | Unused Go code | `deadcode ./...` | | cargo-udeps | Unused Rust dependencies | `cargo +nightly udeps` | If no tool is availa...
Safely identify and remove dead code with test verification at every step.
Run analysis tools based on project type:
| Tool | What It Finds | Command |
|---|---|---|
| knip | Unused exports, files, dependencies | npx knip |
| depcheck | Unused npm dependencies | npx depcheck |
| ts-prune | Unused TypeScript exports | npx ts-prune |
| vulture | Unused Python code | vulture src/ |
| deadcode | Unused Go code | deadcode ./... |
| cargo-udeps | Unused Rust dependencies | cargo +nightly udeps |
If no tool is available, use Grep to find exports with zero imports:
# Find exports, then check if they're imported anywhere
Sort findings into safety tiers:
| Tier | Examples | Action |
|---|---|---|
| SAFE | Unused utilities, test helpers, internal functions | Delete with confidence |
| CAUTION | Components, API routes, middleware | Verify no dynamic imports or external consumers |
| DANGER | Config files, entry points, type definitions | Investigate before touching |
For each SAFE item:
git checkout -- <file> and skip this itemBefore deleting CAUTION items:
import(), require(), __import__After removing dead code, look for:
Report results:
Dead Code Cleanup
──────────────────────────────
Deleted: 12 unused functions
3 unused files
5 unused dependencies
Skipped: 2 items (tests failed)
Saved: ~450 lines removed
──────────────────────────────
All tests passing ✅
npx claudepluginhub tpavanipradeep/everything-claude-code/refactor-cleanSafely detects and removes dead code using tools like knip, ts-prune, vulture; verifies each deletion with full test suite; categorizes by risk and reports summary.
/refactor-cleanSafely identifies and removes dead code with test verification after each deletion. Runs language-specific analysis tools, categorizes findings by risk, and atomically deletes with rollback on test failure.
/refactor-cleanIdentifies and removes dead code using knip, depcheck, and ts-prune, with test verification before each deletion. Categorizes findings by severity and generates a report.
/cleanupSafely identifies and removes unused exports, files, dependencies, and dead code using knip/depcheck/grep. Risk-assesses items, verifies builds/tests, logs deletions to DELETION_LOG.md, and commits changes. Supports --dry-run|--aggressive.
/refactor-cleanSafely identifies and removes dead Python code using vulture, pyflakes, ruff, and pytest verification. Generates analysis report and cleanup summary.
/remove-dead-codeSafely removes high-confidence dead code from the codebase: loads report, checks side effects, runs linter/tests per file, cleans imports/files/dirs, and generates summary with git diff.