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.
npx skills add brianlovin/agent-config --skill knip -a claude-codeWhat 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.jsonafter 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
--productionand walk me through the findings
How to install knip
1Skills CLI (Vercel)
npx skills add brianlovin/agent-config --skill knip -a claude-code2Manually: put the files in place
~/.claude/skills/knip/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/knip/
1Skills CLI (Vercel)
npx skills add brianlovin/agent-config --skill knip -a codex2Manually: put the files in place
.agents/skills/knip/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add brianlovin/agent-config --skill knip -a cursor2Manually: put the files in place
.cursor/skills/knip/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install brianlovin/agent-config knip2Manually: put the files in place
.github/skills/knip/SKILL.md1Skills CLI (Vercel)
npx skills add brianlovin/agent-config --skill knip -a gemini-cli2Platform CLI
gemini skills install https://github.com/brianlovin/agent-config --path skills/knipManually: put the files in place
.devin/skills/knip/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add brianlovin/agent-config --skill knip -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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.