knip

Identify unused files, dependencies, and exports in JavaScript/TypeScript projects.

68|1|Updated Jan 14, 2026
One-click install
npx skills add https://github.com/knoopx/pi --skill knip-knoopx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: knip
Source: https://github.com/knoopx/pi/tree/main/agent/skills/knip
Command: npx skills add https://github.com/knoopx/pi --skill knip-knoopx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers quickly identify and remove unused files, dependencies, and exports in JavaScript and TypeScript projects, reducing bundle size and technical debt.

Core Features & Use Cases

  • Code cleanup: Detect dead or unreferenced files and prune them from the repository.
  • Dependency hygiene: Find unused dependencies and prune package.json entries.
  • Export hygiene: Surface and remove unreferenced exports across modules in a codebase.
  • Use Case: In a large monorepo, scan all packages to reveal dead code and stale dependencies, then run automated fixes to clean up the project.

Quick Start

Use bunx knip to analyze a project. bunx knip # Analyze project bunx knip --production # Production only (no tests, devDeps) bunx knip --strict # Direct dependencies only bunx knip --fix # Auto-remove unused (use cautiously) bunx knip --include files # Only unused files bunx knip --include exports # Only unused exports bunx knip --include dependencies # Only unused deps

Frequently Asked Questions about knip

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

FAQPage Schema
How do I find unused dependencies and dead code in a JavaScript or TypeScript monorepo?

To find unused dependencies and dead code in a JavaScript or TypeScript monorepo, use a static analysis tool to scan project graphs. This identifies unreferenced files, stale dependencies, and unused exports across multiple workspaces.

What is the best way to prune unused exports from a TypeScript project?

The best way to prune unused exports from a TypeScript project is by running static analysis to surface unreferenced modules. You can then manually remove them or use automated flags to clean up the codebase.

Can I automatically remove unused files and dependencies from package.json?

Yes, you can automatically remove unused files and dependencies from package.json by running the analysis tool with an auto-fix flag. This prunes stale dependencies and dead files, though it should be used cautiously.

Does static analysis for dead code work with production builds and exclude devDependencies?

Static analysis for dead code does work with production builds by using a production-only flag. This excludes tests and devDependencies from the scan, focusing strictly on direct dependencies used in the live environment.

How do I only scan for unused dependencies without checking exports or files?

To only scan for unused dependencies without checking exports or files, run the analysis tool with an include flag specifically set for dependencies. This restricts the output to only show stale package.json entries.

Why should I use static analysis to detect unreferenced exports in Node.js?

You should use static analysis to detect unreferenced exports in Node.js because it reduces bundle size and technical debt. Scanning project graphs provides actionable results to safely clean up dead code across packages.