# Knip — card for AI agents

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

Category: Linting and formatting · npm package `knip` · latest version 6.44.1 (checked 2026-11-01)
Install: `npm install knip`
License: ISC (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## 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.

## What it is
- Knip is a command-line tool for JavaScript and TypeScript projects. It finds unused files, unused exports and unused dependencies. The site says it "finds and fixes" them. The README argues that less code and fewer dependencies mean better performance, less maintenance and easier refactoring. Knip is ISC licensed, and the name is Dutch for "(to) cut".
- It works by following imports from entry points. The site describes analysis "starting from fine-grained entry points based on the actual frameworks and tooling in (mono)repos", and the maintainers say Knip ships with 190+ plugins for tools such as Next.js, Vite, Vitest, Jest, Storybook and Nx. A builder in our sources sums it up this way: it builds a graph from imports and config references, then compares that graph to `package.json`.
- Besides the CLI, the README lists separate packages for config setup, a language server and an MCP server, plus a VS Code and Open VSX extension. It suits teams cleaning up an old codebase, and teams that want CI to fail before new dead code or stray dependencies get merged.

## Caveats
- Expect false positives on a first scan: 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.
- Indirect usage slips past it: 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.
- Deleting dead code may not shrink the bundle: Goldberg removed everything Knip flagged in the Centered app. The bundle barely changed, and a Lighthouse audit showed the same score.
- Some layouts still need a config file: Even with framework detection, Goldberg added a `knip.json` to mark Next.js page files as entry points and to ignore `public`.

## Numbers (AgentGid data)
- Gid Score: 77.1 (#157 of all tools, 7 of 83 in its category)
- Used in 154 public projects set up for AI coding agents (2.5%)
- Downloads last week: 34,249,826 (as of 2026-11-24), +73.1% over 4 weeks
- GitHub stars: 12,715 (as of 2026-11-24)
- Last push: 2026-11-23

## Often used with
Vitest 63.6%, TypeScript 90.9%, Playwright (JavaScript) 50.0%, lint-staged 32.5%, Husky 35.7%, Turborepo 29.2%

## Checked alternatives (same job)
- ESLint: https://agentgid.com/tools/eslint/agent.md
- Biome: https://agentgid.com/tools/biomejs/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/knip/
- Homepage: https://knip.dev
- Repository: https://github.com/webpro-nl/knip
- Source: https://github.com/webpro-nl/knip#readme
- Source: https://github.com/webpro-nl/knip
- Source: https://github.com/webpro-nl/knip/releases
- Source: https://knip.dev

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
