Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Detects and safely removes unused code (imports, functions, classes) across multiple languages. Use after refactoring, when removing features, or before production deployment. Includes safety checks and validation.
.claude/skills/aiskillstore-dead-code-removal/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-05 | ✗→✓ | ▲ Improved | 1096% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 108% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 54% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 157% | 0% |
| case-06 | ✓→✓ | = Same ✓ | 61% | 0% |
This skill safely identifies and removes unused code across multiple programming languages. It includes comprehensive safety checks to prevent removing code that's actually needed.
This skill includes Python helper scripts in scripts/:
find_unused_imports.py: Uses AST parsing to accurately detect unused imports in Python files. Outputs JSON with unused imports and line numbers.bash python scripts/find_unused_imports.py src/utils.py src/services.py
Find and remove unused imports and functions in this projectClean up dead code in src/ directory, but be conservativeCheck for unused functions in src/utils/ and remove them safelyIdentify Project Type:
pyproject.toml, setup.py, requirements.txtpackage.json, tsconfig.jsonpom.xml, build.gradlego.modCargo.tomlDetect Entry Points:
main.py, __main__.py, app.py, run.pyindex.js, main.js, server.js, app.jsMain.java, *Application.java, *Controller.java*.config.*, settings.*, setup.*test_*.py, *.test.js, *.spec.jsCross-File Dependencies:
Framework Patterns:
Using Helper Script:
The skill includes a Python helper script for finding unused imports:
bash# Find unused imports in Python files python scripts/find_unused_imports.py src/utils.py src/services.py
Unused Imports:
python# Python: AST-based analysis import ast # Track: Import statements vs actual usage # Skip: Dynamic imports (importlib, __import__)
javascript// JavaScript: Module analysis // Track: import/require vs references // Skip: Dynamic imports, lazy loading
Unused Functions/Classes:
Never Remove If:
getattr(), eval(), globals() usage detectedwindow[], this[], dynamic import() usage@Component, @Service)Framework Preservation:
Python:
JavaScript:
Java:
Backup Creation:
bashbackup_dir="./unused_code_backup_$(date +%Y%m%d_%H%M%S)" cp -r . "$backup_dir" 2>/dev/null || mkdir -p "$backup_dir" && rsync -a . "$backup_dir"
Incremental Removal:
Validation:
bash# Python python -m py_compile file.py python -m pytest # JavaScript npx eslint file.js npm test # Java javac -Xlint file.java mvn test
Input: Clean up unused imports in src/utils/helpers.py
Output:
markdown## Dead Code Removal: src/utils/helpers.py ### Analysis - **File**: `src/utils/helpers.py` - **Total imports**: 8 - **Unused imports**: 3 ### Unused Imports Found 1. `import os` - Line 2 (not used anywhere) 2. `import json` - Line 3 (not used anywhere) 3. `from datetime import timedelta` - Line 5 (not used anywhere) ### Safe to Remove ✅ All 3 imports are safe to remove (no dynamic usage detected) ### Changes
import os import json from datetime import datetime, timedelta import requests
from datetime import datetime import requests
### Validation
- ✅ Syntax check passed
- ✅ Tests pass
- ✅ No dynamic imports detected
Input: Find unused functions in src/services/
Output:
markdown## Dead Code Removal: src/services/ ### Analysis - **Files analyzed**: 12 - **Functions found**: 45 - **Unused functions**: 2 ### Unused Functions **1. `formatOldDate()` in `src/services/utils.js`** - **Location**: Line 34-42 - **Status**: ✅ Safe to remove - **Reason**: No references found, not exported, not used in tests **2. `legacyAuth()` in `src/services/auth.js`** - **Location**: Line 78-95 - **Status**: ⚠️ Preserved (framework pattern) - **Reason**: Referenced in route configuration (line 12) ### Summary - **Removed**: 1 function (`formatOldDate`) - **Preserved**: 1 function (framework usage) - **Lines removed**: 9 - **Size reduction**: ~300 bytes
Do:
Don't:
Static Analysis:
Validation:
Report Should Include:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 3,411 | 6,534 | +92% | 1 | 1 | 0% | 333 | 2,033 | +511% | 0 | 0 | — |
case-02 | fail→fail | 4,766 | 4,846 | +2% | 1 | 1 | 0% | 271 | 2,105 | +677% | 0 | 0 | — |
case-03 | fail→fail | 2,555 | 7,914 | +210% | 1 | 1 | 0% | 200 | 2,774 | +1287% | 0 | 0 | — |
case-04 | pass→pass | 6,628 | 5,979 | -10% | 1 | 1 | 0% | 1,136 | 2,921 | +157% | 0 | 0 | — |
case-05 | fail→pass | 2,347 | 10,420 | +344% | 1 | 1 | 0% | 324 | 3,875 | +1096% | 0 | 0 | — |
case-06 | pass→pass | 15,662 | 8,394 | -46% | 1 | 1 | 0% | 1,927 | 3,098 | +61% | 0 | 0 | — |
case-07 | pass→pass | 10,710 | 11,279 | +5% | 1 | 1 | 0% | 1,796 | 3,628 | +102% | 0 | 0 | — |
case-08 | pass→pass | 10,179 | 8,397 | -18% | 1 | 1 | 0% | 1,664 | 3,148 | +89% | 0 | 0 | — |
case-09 | pass→pass | 12,022 | 10,274 | -15% | 1 | 1 | 0% | 1,795 | 3,570 | +99% | 0 | 0 | — |
case-10 | fail→pass | 7,709 | 2,931 | -62% | 1 | 1 | 0% | 1,077 | 2,239 | +108% | 0 | 0 | — |
case-11 | pass→pass | 6,973 | 3,054 | -56% | 1 | 1 | 0% | 1,188 | 2,220 | +87% | 0 | 0 | — |
case-12 | pass→pass | 10,647 | 7,385 | -31% | 1 | 1 | 0% | 1,726 | 2,996 | +74% | 0 | 0 | — |
case-13 | pass→pass | 11,101 | 9,851 | -11% | 1 | 1 | 0% | 1,761 | 3,256 | +85% | 0 | 0 | — |
case-14 | pass→pass | 14,432 | 5,218 | -64% | 1 | 1 | 0% | 1,689 | 2,686 | +59% | 0 | 0 | — |
case-15 | pass→pass | 14,898 | 10,667 | -28% | 1 | 1 | 0% | 2,454 | 3,717 | +51% | 0 | 0 | — |
case-16 | pass→pass | 7,807 | 4,821 | -38% | 1 | 1 | 0% | 1,229 | 2,604 | +112% | 0 | 0 | — |
case-17 | pass→pass | 12,914 | 11,527 | -11% | 1 | 1 | 0% | 1,824 | 2,740 | +50% | 0 | 0 | — |
case-18 | fail→pass | 14,914 | 13,023 | -13% | 1 | 1 | 0% | 2,291 | 3,533 | +54% | 0 | 0 | — |
case-19 | pass→pass | 13,050 | 15,249 | +17% | 1 | 1 | 0% | 2,124 | 4,151 | +95% | 0 | 0 | — |
case-20 | pass→pass | 10,179 | 6,969 | -32% | 1 | 1 | 0% | 1,643 | 2,875 | +75% | 0 | 0 | — |
case-21 | pass→pass | 13,314 | 7,701 | -42% | 1 | 1 | 0% | 2,067 | 2,965 | +43% | 0 | 0 | — |
case-22 | pass→pass | 8,940 | 7,164 | -20% | 1 | 1 | 0% | 1,336 | 2,822 | +111% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 20 counted toward the lift figure. The other 2 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +14 percentage points is the difference between those two pass rates over the 20 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.