dead-dependencies

Detect and safely remove unused npm dependencies using grep, leaf checks, and build verification.

8.8k|490|Updated Jul 30, 2021
One-click install
npx skills add https://github.com/redis/RedisInsight --skill dead-dependencies
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dead-dependencies
Source: https://github.com/redis/RedisInsight/tree/main/.ai/skills/dead-dependencies
Command: npx skills add https://github.com/redis/RedisInsight --skill dead-dependencies

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Static analysis tools like knip and depcheck over-report unused packages in monorepos with mega-manifests, config-string references, and ambient types, making it risky to know whether an npm dependency is truly dead and safe to remove.

Core Features & Use Cases

  • Grep-based usage detection: Search the entire repo for imports, requires, dynamic imports, and bare references to a candidate package.
  • No-import usage checks: Rule out config string references in webpack, Vite, ESLint, Jest, and Babel configs, plus package.json scripts and runtime preloads.
  • Leaf verification and classification: Use npm ls to confirm nothing depends on the package, then classify it as deletable, relocatable, ambient, or a false positive.
  • Build gate validation: Uninstall the package, reinstall, and run type-check, tests, and build to prove removal is safe before committing.
  • Use Case: After a webpack-to-Vite migration, sweep leftover build tooling by enumerating all declared dependencies, filtering zero-hit candidates, and confirming each removal with the build gate.

Quick Start

Check whether the npm package jsonpath is still used anywhere in this repo and safely remove it if it is dead.

Frequently Asked Questions about dead-dependencies

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find unused npm dependencies in a monorepo?

Grep the entire repo for the package name across imports, requires, and dynamic imports, then check config files and package.json scripts for string references. Confirm it is a leaf with npm ls before removing it and running the build gate.

Why do knip and depcheck report false positives for unused dependencies?

Static tools miss packages referenced without an import, such as webpack loaders, ESLint plugins, and Jest reporters named by string in config files. They also flag ambient @types packages and tools invoked from package.json scripts as unused.

How do I verify an npm package is safe to remove?

Uninstall the package with npm uninstall, reinstall dependencies, then run type-check, tests, and build for the affected workspace. If all checks pass, the removal is safe; if anything fails, restore the package.

When should I keep an @types package that appears unused?

Keep @types packages that are ambient or global-only, such as @types/webpack-env, since they are never imported by design. Delete them only when the base package bundles its own types via a types or typings field in its package.json.

What should I do if a dependency is declared in multiple workspaces but used in one?

Remove only the unused declaration from the workspace where nothing references it, and keep the copy in the workspace that actually uses it. Never delete the used declaration during deduplication.