python-dead-code
/python-dead-code
Find and remove unused variables, functions, classes and unreachable branches with vulture and ruff, filtering framework false positives (Django, FastAPI, pytest, click). TRIGGER WHEN: cleaning up Python codebases, enforcing import hygiene, or integrating dead code checks into CI.
- Author
- acaprino ↗
- Repository
- alfio-claude-plugins ↗
- Licence
- MIT
- Last repository change
- 27.10.2026
Assessment and security
- Files in this package
- 3
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Find and remove unused variables, functions, classes and unreachable branches with vulture and ruff, filtering framework false positives (Django, FastAPI, pytest, click). TRIGGER WHEN: cleaning up Python codebases, enforcing import hygiene, or integrating dead code checks into CI.
Original author description
Find and remove unused variables, functions, classes and unreachable branches with vulture and ruff, filtering framework false positives (Django, FastAPI, pytest, click). TRIGGER WHEN: cleaning up Python codebases, enforcing import hygiene, or integrating dead code checks into CI.
How it works
- Reference router
- 1. Installation and CLI Usage
- 2. Framework False Positives and Whitelists
- 3. Configuration (pyproject.toml)
- 4. Safest-First Cleanup Order
SKILL.md preview
--- name: python-dead-code description: > Find and remove unused variables, functions, classes and unreachable branches with vulture and ruff, filtering framework false positives (Django, FastAPI, pytest, click). TRIGGER WHEN: cleaning up Python codebases, enforcing import hygiene, or integrating dead code checks into CI. --- # Python Dead Code Detection Detect and remove unused code in Python projects using `ruff` (fast lint-level checks for imports and local variables) and `vulture` (AST analysis for unused functions, classes, properties, and unreachable branches), with framework-aware false-positive filtering. ## Reference router | Task | Reference | |---|---| | GitHub Actions, pre-commit hooks, monorepo/library workflows, and false-positive troubleshooting | `references/ci-and-troubleshooting.md` | ## 1. Installation and CLI Usage ```bash # Install via uv (recommended) or pip uv tool install vulture uv tool install ruff # Ruff: unused imports (F401), redefined names (F811), unused local variables (F841) ruff check [target] --select F401,F811,F841 ruff check [target] --select F401 --fix --diff # Vulture: deep unused code detection (60% default, 80%+ recommended) vulture [target] --min-confidence 80 --exclude "venv,.venv,__pycache__,.git,migrations" vulture [target] whitelist.py --min-confidence 80 --sort-by-size ``` | Category | Tool | Rule / Confidence | |---|---|---| | Unused imports / redefined names / unused locals | `ruff` | `F401`, `F811`, `F841` | | Unused functions, classes, properties, unreachable code | `vulture` | `90-100%` almost certain; `80-89%` likely; `60-79%` verify dynamic usage | ## 2. Framework False Positives and Whitelists Do not treat framework-wired symbols as dead code without checking their registration surface: - **Django**: Views referenced as strings in `urls.py`, ORM model/form/serializer fields, `@receiver` signal handlers, management command `handle()`, `@admin.register` classes, `MIDDLEWARE` entries, template tags/filters. - **FastAPI / Flask**: `@app.get`/`@app.post` route handlers, `Depends()` callables, lifecycle and exception handlers. - **pytest**: `@pytest.fixture` functions (including `conftest.py`), `pytest_*` hooks. - **click / typer / Celery**: `@cli.command()` callbacks, `@app.task` / `@shared_task` workers. - **General Python**: `__all__` public exports, dunder methods, `getattr`/`importlib` targets, abstract method implementations, Pydantic fields and validators (`@field_validator`, `@model_validator`). Generate and curate a whitelist for intentional dynamic symbols: ```bash vulture [target] --make-whitelist > whitelist.py ``` ## 3. Configuration (`pyproject.toml`) ```toml [tool.ruff.lint] select = ["F401", "F811", "F841"] [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] "conftest.py" = ["F401"] "*.pyi" = ["F401"] [tool.vulture] min_confidence = 80 exclude = ["venv/", ".venv/", "__pycache__/", "migrations/", "node_modules/"] paths = ["src/", "app/"] ``` ## 4. Safest-First Cleanup Order 1. **Unused imports (`F401`)**: run `ruff check [target] --select F401 --fix` (preserving `__init__.py` re-exports) and verify module imports still succeed. 2. **Unused variables (`F841`)**: replace unused tuple unpacking targets with `_`. 3. **Unreachable code**: remove dead statements after unconditional `return`, `raise`, `break`, or `continue`. 4. **Unused functions and classes (`vulture >= 80%`)**: search for string/dynamic references across the codebase, check `__all__` and framework decorators, and remove only after confirming no runtime caller exists.
Files in this package (3)
- SKILL.md 4 KB
- SKILL.toml 1 KB
- references/ci-and-troubleshooting.md 2 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · acaprino/alfio-claude-plugins | 100 | MIT |
| acaprino/alfio-claude-plugins | 100 | MIT |
| acaprino/alfio-claude-plugins | 100 | MIT |
| acaprino/alfio-claude-plugins | 100 | MIT |
| acaprino/alfio-claude-plugins | 100 | MIT |
| acaprino/alfio-claude-plugins | 100 | MIT |
Identical content appears in 1 other GitHub folders. We show one copy with the highest score.
Database snapshot: 13.11.2026 · package version 3f2ff4596d84 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 95vulture-dead-code
Vulture and deadcode tools for detecting unused Python code (functions, classes, imports). Use when cleaning up codebases or removing dead code. Triggers vulture, deadcode. - 100find-dead-code
Find unused functions, classes, imports, and unreachable code paths. Use when the user asks to find dead code, unused code, cleanup candidates, or wants to reduce codebase size. - 100find-dead-code
Find unused code — functions, classes, variables, imports, constants, types, and more. Use when the user asks to "find dead code", "find unused code", "clean up unused imports", "find unreachable code", or "find what can be deleted". Accounts for dependency injection frameworks… - 100fai-dead-code-removal
Identify and remove dead code in Python/TypeScript — unused exports, unreachable branches, and orphaned files, verified by tooling. Use this skill when cleaning up a codebase, reducing bundle size, or before a refactor — even if the user only says "remove unused code". - 100python-scaffold-method
Generate a fresh project skeleton, tests and lint config included. TRIGGER WHEN: `/daodan:init-project` runs without an application scaffold and the user wants a Python project, or the user asks to start a new Python project, bootstrap FastAPI/Django/CLI/library structure, or… - 84analyze-dead-code
Find and remove dead code — unused exports, unreachable modules, and stale files. Always use this skill whenever the user says "find dead code", "remove unused code", "clean up unused exports", "what code can we delete", "detect unreachable code", "what files are no longer…