skills/89jobrien/dead-code-removal/SKILL.md
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.
npx skillsauth add aiskillstore/marketplace dead-code-removalInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
python scripts/find_unused_imports.py src/utils.py src/services.py
Find and remove unused imports and functions in this project
Clean up dead code in src/ directory, but be conservative
Check for unused functions in src/utils/ and remove them safely
Identify 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:
# Find unused imports in Python files
python scripts/find_unused_imports.py src/utils.py src/services.py
Unused Imports:
# Python: AST-based analysis
import ast
# Track: Import statements vs actual usage
# Skip: Dynamic imports (importlib, __import__)
// 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:
backup_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:
# 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:
## 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
```python
# Before
import os
import json
from datetime import datetime, timedelta
import requests
# After
from datetime import datetime
import requests
### Example 2: Remove Unused Functions
**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:
development
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.