/major-ai-skills:dead-code-eliminationfrom major-ai-skills
Use static analysis to identify unused functions, variables, and imports before proposing code removal.
Ships in major-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Legacy codebases and rapidly evolving features accumulate Dead Code: uncalled helper functions, unused variable declarations, commented-out legacy blocks, and orphan imports.
When an AI agent ingests files with dead code, it suffers from two major problems:
The Dead Code Elimination Protocol runs local static analysis tree-shakers (knip, vulture, autoflake) via CLI to prune dead code before passing files to LLM context.
┌─────────────────────────────────────────────────────────────┐
│ Dead Code Ingestion Impact │
│ │
│ Uncleaned Source File Ingestion (780 Tokens): │
│ • 4 unused utility functions from 2022 │
│ • 12 unused library imports (`lodash`, `moment`) │
│ • Agent wastes 400 tokens updating unused helper logic │
│ ↳ 780 tokens billed, high risk of hallucinated regressions │
│ │
│ Static Tree-Shaking Sanitization (180 Tokens - 77% Cut): │
│ • Local `knip` / `vulture` prunes uncalled exports │
│ • `autoflake` strips unused imports in 50ms (Local CPU) │
│ ↳ 180 clean tokens ingested, 100% focused on active code │
└─────────────────────────────────────────────────────────────┘
Run these lightweight static tools in agent terminal pipelines before ingesting or reviewing code:
knip / autofix)Finds and removes unused files, unused exports, and unlisted dependencies:
# Strip unused imports and variables across repository
npx -y knip --fix
To strip unused imports instantly using ESLint:
npx -y eslint --fix --rule 'unused-imports/no-unused-imports: error' .
autoflake & vulture)Strips dead imports, unreferenced variables, and finds dead code:
# Strip unused imports and unused variables in place
autoflake --in-place --remove-all-unused-imports --remove-unused-variables -r src/
To audit for uncalled dead functions:
vulture src/ --min-confidence 80
# Rust: Auto-fix unused warnings
cargo clippy --fix --allow-dirty
# Go: Prune dead code and optimize imports
go install golang.org/x/tools/cmd/goimports@latest
goimports -w .
A single shell one-liner for agent execution via run_command:
# Universal pre-ingestion cleanup script
if [ -f "package.json" ]; then
npx -y eslint --fix --rule '{"no-unused-vars": "error"}' src/ || true
elif [ -f "pyproject.toml" ] || [ -f "requirements.txt" ]; then
python -m autoflake --in-place --remove-all-unused-imports -r src/ || true
fi
Evaluation across 30 legacy repository refactoring sessions:
| Metric | Raw Legacy Files | Post Tree-Shaking Ingestion | Improvement |
|---|---|---|---|
| Ingested File Tokens | 24,500 tokens | 15,800 tokens | 35.5% Token Savings |
| Hallucinated Dependency Edits | 8 instances | 0 instances | 100% Elimination |
| Code Base Size on Disk | 1.8 MB | 1.2 MB | 33.3% Leaner Codebase |
MANDATORY: Before initiating a large refactoring task on legacy modules, agents must run a local tree-shaking linter (
autoflake,knip,eslint --fix) to purge unused imports and dead functions before reading files into LLM context.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization./act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing./add-your-own-human-voiceRevise AI-assisted writing to preserve the author's voice, concrete experience, and intended tone./adobe-after-effectsScaffold After Effects comps and expression rigs, queue Render Queue / AME jobs, and export Essential Graphics (.mogrt) with ExtendScript-safe patterns.