Dead code elimination
Skill dgabreuu/react-skill-pack/skills/dead-code-elimination
Use when a React + Vite project needs an advisory scan for unreachable modules, unused imports or unreferenced dependencies before a manually reviewed cleanup.From its SKILL.md
npx -y skills add dgabreuu/react-skill-pack --skill dead-code-eliminationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.2 KB, 676 tokens by cl100k_base, as published. Nobody here has run it
Dead Code Elimination
Purpose
Find cleanup candidates without automatically removing code. The analysis uses the static module graph, HTML and Vite entries, package.json, dynamic imports, workers, and known glob patterns. Reflection, runtime-generated imports, and external contracts still require human review.
Memory and patterns
Read the local MEMORY.md and follow ../.shared/SKILL-MEMORY-PROTOCOL.md; use node "<skills-root>/.shared/src/memory-cli.js" append ... for actionable results. The utility validates, renumbers, and retains up to 12 entries.
Before making decisions influenced by existing code, follow ../.shared/PATTERN-LEARNING-PROTOCOL.md and query the repository catalog with node "<skills-root>/.shared/src/pattern-learning/pattern-cli.js" query ...; after confirming a new or refined pattern in the code, consolidate it with node "<skills-root>/.shared/src/pattern-learning/pattern-cli.js" upsert ....
Usage
Compatible with React 18/19, Vite 7/8, and Node 22.13+.
node "<skill-dir>/scripts/scan-dead-code.js" \
--project-dir <project> --format json --dry-run
Output flags and behavior follow the shared CLI contract in ../.shared/README.md.
When not to use
- The goal is shrinking a measured bundle; use the bundle-optimization skill (tree shaking may already eliminate the code).
- Findings would be removed without manual confirmation; this skill is advisory and authorizes no automatic removal.
Interpretation
highidentifies strong local evidence, such as an import whose binding is never read.mediumidentifies a graph candidate, such as a file that is unreachable from discovered entries.confidenceandaction: revieware required: no finding authorizes automatic removal.peerDependencies, public exports, scripts, configuration files, HTML entries, tests, stories, workers, and polyfills are preserved or treated as roots.- A clean result does not prove a bundle improvement; Vite or Rolldown may already remove the code through tree shaking.
Safe process
- Run the scanner in JSON mode and preserve the report.
- Review each finding against
package.jsonexports, HTML, scripts, aliases, glob patterns, and dynamic loading. - Remove only items confirmed manually.
- Run functional tests and a production build.
- Compare raw, gzip, and Brotli bytes for the initial entry. Record
0 Bwhen cleanup does not change the artifact.
Limitations
The scanner does not execute vite.config, interpret reflection or complex shadowing, or cover every glob variant. tsconfig.json aliases and common queries are resolved; aliases defined only in Vite, conditional exports, and advanced patterns require manual review. Use Knip, ESLint, or bundler analysis as complementary checks when the project requires coverage beyond the static graph.
Files
scripts/scan-dead-code.js: advisory scanner and CLI.checklists/dead-code-checklist.md: manual review.examples/: illustrative examples; they do not authorize removal.
What ships with it: 29 files
21.0 KB alongside SKILL.md, 21 of them executable
checklists/
- dead-code-checklist.md1.0 KB
examples/
- after/index.jsruns41 B
- after/UnusedStuff.jsx331 B
- before/helpers.jsruns54 B
- before/index.jsruns95 B
- before/UnusedStuff.jsx617 B
- before/useOldData.jsruns128 B
scripts/
- scan-dead-code.jsruns12.6 KB
tests/
- fixtures/negative/package.json251 B
- fixtures/negative/src/internal.jsruns27 B
- fixtures/negative/src/public-api.jsruns48 B
- fixtures/positive/index.html116 B
- fixtures/positive/package.json184 B
- fixtures/positive/scripts/generate-icons.mjsruns22 B
- fixtures/positive/src/barrel.jsruns50 B
- fixtures/positive/src/consumer.jsruns69 B
- fixtures/positive/src/lazy.jsruns50 B
- fixtures/positive/src/main.jsx713 B
- fixtures/positive/src/modules/one.jsruns22 B
- fixtures/positive/src/orphan.jsruns35 B
- fixtures/positive/src/public-index.jsruns50 B
- fixtures/positive/src/reachable.jsruns77 B
- fixtures/positive/src/service-worker.jsruns44 B
- fixtures/positive/src/shared.jsruns48 B
- fixtures/positive/src/shared-worker.jsruns27 B
- fixtures/positive/src/worker.jsruns47 B
- fixtures/positive/vite.config.jsruns47 B
- scan-dead-code.test.jsruns4.1 KB
- MEMORY.md135 B