Find and delete dead code in the codebase. Vibe coding leaves unused imports, functions, variables, and entire modules behind. Clean them out.
Python projects
Run in this order:
Ruff: unused imports, variables, and simple dead code
ruff check --select F401,F841,F601,F602,F811,F821,F823,F841 --fix .
F401: unused imports
F841: unused local variables
F811: redefinitions
- Auto-fixes most issues
Vulture: unused functions, classes, attributes, methods
vulture . --min-confidence 80
- 80+ confidence is usually safe to delete
- Review 60-80 range manually (may be called via reflection, plugins, fixtures, or public API)
- Add genuinely-used-but-dynamic items to a
.vulture_whitelist.py
Unreachable code
ruff check --select B018,ARG001,ARG002,ARG003,ARG004,ARG005 .
Orphan files: use git log --diff-filter=A to find files never referenced after creation
TypeScript/JavaScript projects
ts-prune or knip
npx knip
- Reports unused files, exports, dependencies, types
ESLint
npx eslint --rule "no-unused-vars: error" --rule "@typescript-eslint/no-unused-vars: error" --fix .
depcheck for unused npm dependencies
npx depcheck
Rules for deletion
- Delete, don't comment out. Git has history. Commented-out code is worse than deleted code.
- One commit per category. Separate commits for unused imports, unused functions, unused deps: makes review and rollback easy.
- Run the full test suite after each batch. If tests break, something was called dynamically. Investigate before re-deleting.
- Watch out for false positives:
- Code called via reflection, string-based dispatch, or plugin loaders
- Public API surface consumed by downstream users
- Fixtures, conftest.py contents, framework hooks
- CLI entry points registered via setup.py/pyproject.toml
- Template-referenced functions (Jinja, Django templates)
- Dynamically imported modules
- Whitelist the ambiguous. Don't delete things you're unsure about: add them to a whitelist and move on.
Before declaring done
Output format
## Dead code removed
| Category | Count | Notes |
|-------------------|-------|-------|
| Unused imports | 42 | ruff --fix auto-applied |
| Unused functions | 8 | vulture >80% confidence |
| Unused files | 3 | orphan modules, no inbound imports |
| Unused deps | 5 | depcheck / pip-audit |
| Total lines | 380 | |
## Whitelisted (kept)
- `handlers/webhook_stripe.py::_refund_callback`: called via Stripe webhook string dispatch
- ...
## Test results
- pytest: 312 passed
- app smoke test: ok
Target: $ARGUMENTS
If no target specified, run against the current working directory.
1---2name: delete-dead-code3description: Find and delete dead code using ruff and vulture (Python) or equivalents4---56Find and delete dead code in the codebase. Vibe coding leaves unused imports, functions, variables, and entire modules behind. Clean them out.78## Python projects910Run in this order:11121. **Ruff: unused imports, variables, and simple dead code**13 ```bash14 ruff check --select F401,F841,F601,F602,F811,F821,F823,F841 --fix .15 ```16 - `F401`: unused imports17 - `F841`: unused local variables18 - `F811`: redefinitions19 - Auto-fixes most issues20212. **Vulture: unused functions, classes, attributes, methods**22 ```bash23 vulture . --min-confidence 8024 ```25 - 80+ confidence is usually safe to delete26 - Review 60-80 range manually (may be called via reflection, plugins, fixtures, or public API)27 - Add genuinely-used-but-dynamic items to a `.vulture_whitelist.py`28293. **Unreachable code**30 ```bash31 ruff check --select B018,ARG001,ARG002,ARG003,ARG004,ARG005 .32 ```33344. **Orphan files**: use `git log --diff-filter=A` to find files never referenced after creation3536## TypeScript/JavaScript projects37381. **ts-prune or knip**39 ```bash40 npx knip41 ```42 - Reports unused files, exports, dependencies, types43442. **ESLint**45 ```bash46 npx eslint --rule "no-unused-vars: error" --rule "@typescript-eslint/no-unused-vars: error" --fix .47 ```48493. **depcheck** for unused npm dependencies50 ```bash51 npx depcheck52 ```5354## Rules for deletion5556- **Delete, don't comment out.** Git has history. Commented-out code is worse than deleted code.57- **One commit per category.** Separate commits for unused imports, unused functions, unused deps: makes review and rollback easy.58- **Run the full test suite after each batch.** If tests break, something was called dynamically. Investigate before re-deleting.59- **Watch out for false positives:**60 - Code called via reflection, string-based dispatch, or plugin loaders61 - Public API surface consumed by downstream users62 - Fixtures, conftest.py contents, framework hooks63 - CLI entry points registered via setup.py/pyproject.toml64 - Template-referenced functions (Jinja, Django templates)65 - Dynamically imported modules66- **Whitelist the ambiguous.** Don't delete things you're unsure about: add them to a whitelist and move on.6768## Before declaring done6970- [ ] All three tools ran clean (or flagged items are whitelisted with reason)71- [ ] Full test suite passes72- [ ] Application starts and basic smoke test passes73- [ ] Commits are grouped by category, not one mega-commit74- [ ] Report: X imports, Y functions, Z files, N lines removed7576## Output format7778```79## Dead code removed8081| Category | Count | Notes |82|-------------------|-------|-------|83| Unused imports | 42 | ruff --fix auto-applied |84| Unused functions | 8 | vulture >80% confidence |85| Unused files | 3 | orphan modules, no inbound imports |86| Unused deps | 5 | depcheck / pip-audit |87| Total lines | 380 | |8889## Whitelisted (kept)9091- `handlers/webhook_stripe.py::_refund_callback`: called via Stripe webhook string dispatch92- ...9394## Test results9596- pytest: 312 passed97- app smoke test: ok98```99100---101102Target: $ARGUMENTS103104If no target specified, run against the current working directory.