The Package You're Afraid to Delete Is Steering Your Roadmap
Photo: software engineer drawing dependency graph on glass whiteboard with package boxes, via l450v.alamy.com
Ask a room of engineers which dependency they would remove if nobody complained. Watch the silence. That silence is the real dependency problem. Most teams audit packages for vulnerabilities because security dashboards make it easy. Few teams ask which branches are dead, duplicated, or propped up by a single forgotten import. That is the work that actually keeps a dependency tree healthy.
Your lockfile is not an org chart
A security scan tells you whether a package has a known CVE. It does not tell you whether the package deserves to be in your build. Those are different questions. A package can be perfectly safe and still be deadweight. It can be a duplicate of something you already have. It can exist because one developer needed one function in 2019 and nobody has touched the import since.
Dependency hygiene is less about dashboards and more about pruning. That means learning to remove packages without treating every deletion as a potential incident. It also means admitting that the hardest part is often social, not technical. Removing a package feels like telling a coworker their contribution was unnecessary. Removing a package also feels like volunteering to break production. Both feelings are real. Neither is a good reason to keep dead branches.
Map the tree before you cut
You need a picture of direct and transitive dependencies. Use the tools your ecosystem gives you: npm ls, pnpm why, pipdeptree, cargo tree, go mod graph, or whatever your platform provides. Then answer a few practical questions.
Which packages are imported in exactly one place? Which are imported nowhere but still listed? Which duplicate functionality you already have, like two date libraries or three HTTP clients? Which are dev dependencies that no script actually uses? Which are transitive dependencies that only exist because of a package you already plan to remove?
Do not trust the manifest alone. Search the codebase for dynamic imports, plugin loaders, and string-based requires. Check build scripts and CI configs. The dependency you cannot find is usually the one that breaks the build at the worst possible time.
The fear is social, not technical
Engineers do not keep unused packages because they love clutter. They keep them because removal has a social cost. Someone might ask why you deleted their package. Someone might remember an outage from five years ago. Someone might worry that the next vulnerability scan will look worse if the package count drops and then something breaks.
Make removal reversible and you lower that cost. Run a deletion experiment on a branch. Remove one package. Run the test suite, the build, and a canary deploy. Watch error rates for a couple of days. If nothing breaks, merge. If something breaks, restore the lockfile and write down what you learned. The point is not to be reckless. The point is to stop treating every removal as a permanent architectural decision.
Run a safe deletion experiment
Pick a low-risk target first. A dev dependency with one obvious import is a good start. Remove it, run the full pipeline, and deploy to a staging environment or a small canary slice. Keep a rollback plan that takes minutes, not days. If your team uses feature flags, put the dependency-backed feature behind one for the experiment. If not, rely on the lockfile and a clean revert.
Document the result in a removal ledger. Date, package, reason, outcome. Over time that ledger becomes institutional memory. It tells you which packages are safe to remove and which ones are load-bearing in ways nobody expected. It also makes pruning feel routine instead of heroic.
What earns a spot
A dependency earns its place when it saves more maintenance than it creates. That is a judgment call, but you can use heuristics. No direct import in the last 90 days is a candidate. One call site with no tests is a candidate. A duplicate of the standard library is a candidate. A package kept alive only by a type definition is a candidate. A transitive dependency left behind by a removed parent is a candidate.
Be careful with the opposite mistake: removing something because it is small. Small packages can be the glue that keeps a build simple. The goal is not zero dependencies. The goal is a tree where every branch has a reason to be there.
Make pruning boring
Put a thirty-minute dependency thinning slot on the calendar once a month. Rotate who runs it. Track the package count, but do not make it a vanity metric. Celebrate a clean removal the same way you celebrate a feature launch. A smaller tree is not a weaker tree. It is a tree that can still get light to the leaves.
The package you are afraid to delete is probably making every other decision harder. You do not have to cut it today. You do have to stop pretending the fear is a technical requirement.