Safely identifies and removes dead code with test verification at every step: unused exports, files, dependencies, helpers, wrappers, re-exports, and duplicates. Categorizes findings into safety tiers.
How this skill is triggered — by the user, by Claude, or both
Slash command
/julianromli-ai-skills:refactor-cleanThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use a conservative cleanup loop. Prefer keeping uncertain code over deleting something with hidden runtime or external consumers.
Use a conservative cleanup loop. Prefer keeping uncertain code over deleting something with hidden runtime or external consumers.
SAFE, CAUTION, or DANGER.SAFE item at a time.CAUTION items before touching them.DANGER items unless the user explicitly wants deeper investigation.Choose tools by ecosystem. Prefer the project's package manager and existing scripts where possible.
| 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 specialized tooling is unavailable, fall back to targeted search:
Assign every finding to a safety tier before editing.
| Tier | Typical examples | Default action |
|---|---|---|
SAFE | Unused internal utilities, private helpers, unused tests/helpers, wrapper functions with no callers | Delete with verification |
CAUTION | Components, hooks, API routes, middleware, server actions, jobs, CLI commands | Investigate runtime and indirect usage first |
DANGER | Config files, entry points, exported types, schema files, generated boundaries, public APIs | Skip unless the user asks for deeper work |
Escalate to a higher-risk tier when any of these are present:
For each SAFE item:
Keep deletions atomic. Do not batch multiple unrelated removals into a single verification cycle.
If a revert is needed:
Before deleting a CAUTION item, explicitly check for:
import() or require() usageDelete a CAUTION item only when indirect usage has been ruled out and verification still passes.
After dead-code removals are green, look for low-risk consolidation:
Keep this phase separate from dead-code deletion. If consolidation changes behavior, stop treating it as cleanup and call it out explicitly.
End with a short cleanup report that includes:
Use this format when it helps:
Dead Code Cleanup
----------------------------
Deleted: 12 unused functions
3 unused files
5 unused dependencies
Skipped: 2 items (verification failed)
Saved: ~450 lines removed
----------------------------
All tests passing
CAUTION or DANGER items remain.npx claudepluginhub joshuarweaver/cascade-code-general-misc-4 --plugin julianromli-ai-skillsIdentifies dead code and unused dependencies, then proposes safe removal. Use after refactors, before releases, or when auditing vulnerabilities.
Find and remove unreachable/unused code safely. Use during cleanup or before a refactor.
Identifies unused imports, variables, functions, unreachable code, dependencies, and CSS for safe removal. Generates reports categorizing safe-to-remove, potentially unused, and review-required items.