# fix-knip-unused-exports

fix-knip-unused-exports resolves knip “Unused exports” violations by removing or relocating exports that have no production consumers. Use when npm run knip reports unused code.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 147 installs · ★ 129 repo stars
- Author: Factory-AI
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/Factory-AI/factory-plugins/tree/HEAD/plugins/typescript/skills/fix-knip-unused-exports/SKILL.md
- Updated: 2026-10-25
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/fix-knip-unused-exports

## What it does

When running `npm run knip`, the tool flags four categories of violations: exports used only in tests (extract to a separate file), re-exports through a barrel index.ts with no consumers (delete from index.ts), exports used only within their own file (drop the `export` keyword), and completely unused code (remove). The skill classifies each violation by searching the entire repository to find all call sites, then recommends the right fix strategy.

For test-only exports, the skill helps plan safe extraction: determine which helper functions move with the export, check for circular dependency risks, and decide whether constants need a separate file. For dead barrel re-exports, it can suggest adding a subpath export to `package.json` so tests in other packages still have an import path.

After each fix, run the full verification suite: `npm run knip`, tests, and type checking. This matters because one fix sometimes exposes a new violation downstream.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Factory-AI/factory-plugins --skill fix-knip-unused-exports -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Factory-AI/factory-plugins --skill fix-knip-unused-exports -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Factory-AI/factory-plugins --skill fix-knip-unused-exports -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Factory-AI/factory-plugins plugins/typescript/skills/fix-knip-unused-exports
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Factory-AI/factory-plugins --skill fix-knip-unused-exports -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Factory-AI/factory-plugins --path plugins/typescript/skills/fix-knip-unused-exports
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Factory-AI/factory-plugins --skill fix-knip-unused-exports -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/Factory-AI/factory-plugins/tree/HEAD/plugins/typescript/skills/fix-knip-unused-exports/SKILL.md

## When to use it
- Extract an export that is used only by test files
- Remove a re-export from index.ts when production code imports via relative paths
- Convert an export to a private const if nothing outside the file needs it
- Plan extraction of a function to a new file without introducing circular dependencies

## Example prompts
- npm run knip reported an unused export — help me figure out which category it is and how to fix it
- I need to extract a test-only function into its own file — check the structure and watch for circular imports
- Remove this re-export from index.ts and add a subpath export to package.json if needed

## Similar
- [knip-deadcode](https://affpapa.org/en/nevibecode/skills/knip-deadcode.md) — skill · 405 installs
- [refactor-cleaner](https://affpapa.org/en/nevibecode/agents/refactor-cleaner.md) — subagent · ★ 880 repo stars
- [dead-code-detector](https://affpapa.org/en/nevibecode/skills/dead-code-detector.md) — skill · 150 installs
- [checking-changes](https://affpapa.org/en/nevibecode/skills/checking-changes.md) — skill · 122 installs
- [validate-and-fix](https://affpapa.org/en/nevibecode/commands/validate-and-fix.md) — command · ★ 763 repo stars
- [ruff-recursive-fix](https://affpapa.org/en/nevibecode/skills/ruff-recursive-fix.md) — skill · 1500 installs

From the same set: [factory-ai/factory-plugins](https://affpapa.org/en/nevibecode/by/factory-ai/factory-plugins.md) — 17 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
