# knip

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

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3900 installs · ★ 379
- Author: brianlovin
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/brianlovin/agent-config/tree/HEAD/skills/knip/SKILL.md
- Updated: 2026-03-25
- HTML: https://affpapa.org/en/nevibecode/skills/knip

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

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add brianlovin/agent-config --skill knip -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/knip/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/knip/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add brianlovin/agent-config --skill knip -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/knip/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add brianlovin/agent-config --skill knip -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/knip/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install brianlovin/agent-config knip
```

2. **Manually: put the files in place**
- File: `.github/skills/knip/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add brianlovin/agent-config --skill knip -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/brianlovin/agent-config --path skills/knip
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/knip/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add brianlovin/agent-config --skill knip -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/brianlovin/agent-config/tree/HEAD/skills/knip/SKILL.md

## When to use it
- 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
- 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

## Similar
- [improve-codebase-architecture](https://affpapa.org/en/nevibecode/skills/improve-codebase-architecture.md) — skill · 1163035 installs
- [tdd](https://affpapa.org/en/nevibecode/skills/tdd.md) — skill · 1141062 installs
- [triage](https://affpapa.org/en/nevibecode/skills/triage.md) — skill · 990453 installs
- [codebase-design](https://affpapa.org/en/nevibecode/skills/codebase-design.md) — skill · 850344 installs
- [code-review](https://affpapa.org/en/nevibecode/skills/code-review.md) — skill · 789521 installs
- [implement](https://affpapa.org/en/nevibecode/skills/implement.md) — skill · 774700 installs

From the same set: [brianlovin/agent-config](https://affpapa.org/en/nevibecode/by/brianlovin/agent-config.md) — 15 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
