Skip to main content
skill CX Codex

knip — Claude Code skill: find dead code and unused dependencies

This skill runs knip across your project and clears out unused files, dependencies and exports. Handy when a repo has collected leftovers.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add brianlovin/agent-config --skill knip -a claude-code
Open on GitHub

What knip does

The skill gives the agent an order of operations: understand the project first, clean second. It reads package.json, looks for an existing knip config (knip.json, knip.jsonc or a knip key in package.json), then runs npx knip. Configuration hints at the top of the output come first, because they cut down false positives. Run, adjust config, run again — that loop repeats until the hints stop appearing.

Reported issues come next, in a fixed order: unused files, then dependencies and devDependencies, then exports, then types. Knip gets re-run after each batch, since deleting files tends to expose exports and dependencies that just lost their last consumer. For production-only checks there is npx knip --production, which leaves out tests and configs. Safe fixes go through npx knip --fix; file deletion needs npx knip --fix --allow-remove-files.

One limit matters: knip does not touch unused imports or variables inside a file. That is a linter's territory — ESLint or Biome. The agent deletes some findings on its own and asks before the risky ones: possible entry points or dynamically imported files, exports from index.ts and lib/, dependencies used through a CLI or as peers. Exit code 2 sends the skill looking for a missing config and creating knip.json at the project root. Monorepos may need the --workspace flag.

Node.js is required.

What it helps with

  • track down files nothing imports
  • strip dependencies left behind in package.json after code was deleted
  • drop exports and types that lost their consumers
  • tune knip for a framework or monorepo so the report stays clean
  • check production code only, skipping tests and configs

Example prompts for the agent

  • Run knip on this project and list what can go
  • Clean up unused dependencies and exports, adjusting the config as you go
  • Run knip with --production and walk me through the findings

How to install knip

1Skills CLI (Vercel)

npx skills add brianlovin/agent-config --skill knip -a claude-code

2Manually: put the files in place

~/.claude/skills/knip/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/knip/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about knip

How do I install knip in Claude Code?

Run npx skills add brianlovin/agent-config --skill knip -a claude-code. The skill lands at ~/.claude/skills/knip/SKILL.md.

What does the knip skill do?

It runs knip and removes the unused files, dependencies and exports it reports. Config comes first, so the report is not full of noise.

Does knip catch unused variables inside a file?

No. That job belongs to a linter such as ESLint or Biome. Knip looks at files, dependencies and exports across the whole project.

Similar skills

All skills for Code review and refactoring →

From the same set15

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor