Knip
Find and fix unused dependencies, exports and files in TypeScript/JavaScript projects.
3. Used by agents' projects
Dependency in 154 public GitHub projects set up for AI coding agents that we scanned (2.5%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Knip does
Knip starts from entry points it reads off the frameworks and tools in your repo, including monorepos, and reports the files, exports and npm dependencies nothing reaches; builders who used it say it finds a lot, but some of the "unused" list is still wrong.
Knip popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Knip is used
- Knip is a dependency in 154 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (3.2% of the 4,867 JavaScript/TypeScript ones), #6 of 83 in linting and formatting.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 321; those are left out of every share on this page.
- The most used alternative in our scan is ESLint (2,282 projects).
- Projects that use it most often also use Vitest (63.6%), TypeScript (90.9%), Playwright (JavaScript) (50.0%).
- It is more common in projects set up for OpenAI Codex (8.5%) than for GitHub Copilot (2.4%).
By coding agent
Often used with
Knip in practice
Strengths
Knip does not ask you to list every root file. It works out entry points from the frameworks and tooling it detects, and the site says this applies in monorepos too.
The maintainers list 190+ plugins, covering tools from Astro and Cypress to GitHub Actions and Webpack. Each plugin teaches Knip where that tool's files and dependencies are used.
Josh Goldberg ran <code>npx knip</code> on a Next.js package with a two-line config. It reported unused files, dependencies, devDependencies, unlisted dependencies, exports and exported types.
In an Nx repo, John James used a <code>workspaces</code> map to give each app or package its own <code>ignoreDependencies</code> list, and skipped a whole workspace with <code>ignoreWorkspaces</code>.
Watch out for
In one Nx monorepo, about 40% of the packages Knip flagged were actually in use. The builder treated the list as a hint and checked each removal with builds and tests.
The same builder found Knip weak where a package is used only by name in config files, in scripts, in CI or through plugin discovery. Those packages needed entries in the ignore list.
Goldberg removed everything Knip flagged in the Centered app. The bundle barely changed, and a Lighthouse audit showed the same score.
More about Knip
Funding
- GitHub Sponsors: https://github.com/webpro
- Open Collective: https://opencollective.com/knip
- 13 GitHub sponsors
Packages around it
- vitest: Unit test runner
- @playwright/test: End-to-end browser tests
- typescript: Type checker and compiler
- husky: Git hooks
- @testing-library: Component testing helpers
- lint-staged: Run checks on staged files
More in Linting and formatting
Alternatives
Knip This page
Linter that finds and fixes JavaScript code patterns based on AST analysis.
Fast web toolchain providing linting, formatting and code quality all in one.
Get started
Install it.
npm install knipRules for your agent
## Knip
- Start with a plain `npx knip` (or `yarn dlx knip`) run before writing any config, and read the report by category: files, dependencies, devDependencies, unlisted dependencies, exports, types.
- Treat every "unused" item as a hint. Remove it, then run build, test, lint and e2e, and boot the owning app before you commit.
- If a removal breaks something, restore the package and add it to `ignoreDependencies` with a one-line comment explaining why, for example "referenced by name in jest config" or "scripts only".
- In monorepos, put workspace-specific ignores under `workspaces` in the config instead of one global list, and use `ignoreWorkspaces` for packages such as a shared ESLint config.
- When framework detection misses entry points, set `entry` explicitly (for a Next.js pages app: `pages/**/*.tsx`) and use `ignore` for public assets referenced by URI.
- Add Knip to CI as a report first. Tune the ignore list for a while, then fail the build on new unused dependencies.