vulture-dead-code
Vulture and deadcode tools for detecting unused Python code (functions, classes, variables, imports). Use when cleaning up codebases, removing unused code, or enforcing code hygiene in CI. Triggered by: vulture, deadcode, dead code detection, unused code, code cleanup, remove unused.
What this skill does
# Vulture and deadcode - Dead Code Detection
Tools for finding unused Python code including functions, classes, variables, imports, and attributes.
## Quick Reference (30 seconds)
### Tool Comparison
| Feature | Vulture | deadcode |
| ------------ | ----------------------------------- | ------------------------------------ |
| **Approach** | Static analysis + confidence scores | AST-based detection |
| **Accuracy** | Confidence scores (60-100%) | High accuracy, fewer false positives |
| **Best For** | Large codebases, gradual cleanup | New projects, strict enforcement |
### Installation
```bash
uv add --dev vulture deadcode # Install both
```
### Basic Commands
```bash
# Vulture - confidence-based
vulture --min-confidence 80 .
vulture --make-whitelist > vulture_whitelist.py
# deadcode - AST-based
deadcode .
deadcode --show-unreachable .
```
---
## Implementation Guide (5 minutes)
### Vulture Configuration
**pyproject.toml:**
```toml
[tool.vulture]
min_confidence = 80
paths = ["src", "tests"]
exclude = ["**/migrations/*", "**/__pycache__/*", ".venv/*"]
ignore_decorators = ["@app.route", "@pytest.fixture", "@property", "@staticmethod", "@classmethod"]
ignore_names = ["test_*", "setUp*", "tearDown*"]
```
**Whitelist pattern** (`vulture_whitelist.py`):
```python
# Used by external code
_.used_by_external_lib # confidence: 60%
# Framework magic
class Meta: pass # Django/Flask metadata
# Plugin system
def plugin_hook(): pass # Called by plugin system
```
### deadcode Configuration
**pyproject.toml:**
```toml
[tool.deadcode]
paths = ["src"]
exclude = ["tests/*", "migrations/*"]
ignore_decorators = ["app.route", "pytest.fixture", "property"]
ignore_names = ["test_*", "*Factory", "*Schema"]
```
### Understanding Confidence Scores
| Score | Meaning | Action |
| ----- | ----------------- | ------------------------- |
| 100% | Definitely unused | Safe to remove |
| 80% | Likely unused | Review before removing |
| 60% | Possibly unused | Might be dynamic/external |
---
## Common Patterns
### Unused Imports
```python
import sys # FOUND: confidence 100%
import logging # USED: logger = logging.getLogger(__name__)
```
### Unused Functions
```python
def unused_helper(): pass # FOUND: never called
def used_helper(): pass # USED: result = used_helper()
```
### False Positive Handling
```python
# Dynamic access - whitelist needed
obj = getattr(module, 'dynamic_function')
# Framework callbacks - ignore decorator
@app.route('/api/endpoint')
def api_handler(): pass
# Test utilities - ignore pattern
def create_test_user(): pass # test_*
```
---
## CI Integration
### GitHub Actions
```yaml
name: Dead Code Check
on: [push, pull_request]
jobs:
deadcode:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v2
- run: uv python install 3.12
- run: uv sync --all-extras --dev
- run: uv run vulture . --min-confidence 80 vulture_whitelist.py
- run: uv run deadcode .
```
### Pre-commit Hook
```yaml
repos:
- repo: https://github.com/jendrikseipp/vulture
rev: v2.11
hooks:
- id: vulture
args: ['--min-confidence', '80']
files: ^src/
- repo: https://github.com/albertas/deadcode
rev: v2.0.0
hooks:
- id: deadcode
files: ^src/
```
---
## Best Practices
1. **Start with high confidence** (90%), gradually lower to 80%, then 70%
2. **Use whitelists** for framework callbacks, plugin hooks, dynamic access
3. **Document whitelist reasons** - explain WHY each item is whitelisted
4. **Integrate into CI** - catch dead code on every PR
5. **Review before removing** - verify no dynamic/external usage
### When to Choose
| Use Vulture | Use deadcode |
| -------------------------------- | -------------------------- |
| Large/mature codebases | New projects |
| Gradual cleanup | Strict enforcement |
| Complex dynamics (getattr, exec) | AST accuracy needed |
| Need whitelist management | Unreachable code detection |
### Hybrid Approach
```bash
vulture --min-confidence 80 . # Broad detection
deadcode . # Precise detection
# Compare results, whitelist false positives
```
---
## Works Well With
**Tools**: ruff (unused imports), mypy (type checking), pytest-cov (coverage)
**Skills**: python-optimization, linter-autofix, code-antipatterns-analysis
**Agents**: janitor, code-simplifier
---
## Reference
- [Vulture docs](https://github.com/jendrikseipp/vulture)
- [deadcode docs](https://github.com/albertas/deadcode)
- [Full configuration examples](reference.md)
Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.