knip

Runs Knip to find and remove unused files, dependencies, and exports in JavaScript and TypeScript projects to reduce bundle size, maintenance burden, and the dependency attack surface.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "knip" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-752990b7e06b55175b763f8d93db7cb929db59cb1fee286b78c244f0ac096040. Verify the upstream source and version against https://skillhub.cn/skills/user_3c6cb52e/knip-unused-code-dependency-finder before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Runs Knip to find and remove unused files, dependencies, and exports in JavaScript and TypeScript projects to reduce bundle size, maintenance burden, and the dependency attack surface.

0 Downloads

Introduction source: third_party · user_3c6cb52e · 1.0.0 Reference

SkillPi interpretation

Tasks
Not specified in the source documentation.
Audience
Cleaning up a codebase that's accumulated dead code over time Auditing npm dependencies (unused, unlisted, or duplicate) Reducing bundle size by removing unused exports Pre-refactoring analysis to identify what can be safely deleted CI gate to prevent new unused code from being merged
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
```bash npx knip # Zero config — works out of the box
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: knip
description: >-
  Find and remove unused files, dependencies, and exports in JavaScript/TypeScript
  projects with Knip. Use when someone asks to "find unused code", "clean up
  dependencies", "remove dead code", "find unused exports", "Knip", "reduce
  bundle size by removing unused files", or "audit npm dependencies". Covers
  unused files, dependencies, exports, types, and CI integration.
license: Apache-2.0
compatibility: "Node.js 18+. TypeScript/JavaScript projects."
metadata:
  author: terminal-skills
  version: "1.0.0"
  category: devops
  tags: ["unused-code", "dependencies", "knip", "cleanup", "dead-code"]

Knip

Overview

Knip finds unused files, dependencies, and exports in your TypeScript/JavaScript project. It understands your project structure — framework entry points, config files, scripts — and reports what's truly unused. Unlike ESLint's no-unused-vars (which only checks within files), Knip works across the entire project: unused exports, orphan files, unlisted dependencies, and packages in package.json that no code actually imports.

When to Use

  • Cleaning up a codebase that's accumulated dead code over time
  • Auditing npm dependencies (unused, unlisted, or duplicate)
  • Reducing bundle size by removing unused exports
  • Pre-refactoring analysis to identify what can be safely deleted
  • CI gate to prevent new unused code from being merged

Instructions

Setup

npx knip  # Zero config — works out of the box

# Or install
npm install -D knip

What Knip Detects

# Run a full analysis
npx knip

# Output:
# Unused files (2)
#   src/utils/legacy-helper.ts
#   src/components/OldBanner.tsx
#
# Unused dependencies (3)
#   lodash
#   moment
#   chalk
#
# Unused exports (5)
#   src/lib/api.ts: formatDate, parseResponse
#   src/types/index.ts: LegacyUser, OldConfig
#   src/utils/math.ts: calculateTax
#
# Unlisted dependencies (1)
#   dotenv (used in src/config.ts but not in package.json)

Configuration

// knip.json — Customize detection
{
  "entry": ["src/index.ts", "src/server.ts"],
  "project": ["src/**/*.{ts,tsx}"],
  "ignore": ["**/*.test.ts", "**/*.spec.ts"],
  "ignoreDependencies": ["@types/node"],
  "ignoreBinaries": ["docker"],
  // Framework plugins (auto-detected)
  "next": { "entry": ["pages/**/*.tsx", "app/**/*.tsx"] },
  "vitest": { "entry": ["**/*.test.ts"] }
}

CI Integration

# .github/workflows/knip.yml — Fail CI on unused code
name: Unused Code Check
on: [pull_request]

jobs:
  knip:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm ci
      - run: npx knip

Fix Mode

# Auto-remove unused exports (adds underscore prefix)
npx knip --fix

# Remove unused files
npx knip --fix --allow-remove-files

# Dry run — see what would change
npx knip --fix --dry-run

Examples

Example 1: Audit a legacy project

User prompt: "This project has 200+ files and we're not sure what's still used. Find all dead code."

The agent will run Knip to identify unused files, exports, and dependencies, then categorize results by confidence level and provide a cleanup plan.

Example 2: Add to CI pipeline

User prompt: "Prevent new dead code from being merged. Add a CI check."

The agent will configure Knip with the project's entry points, add a GitHub Actions workflow, and set up framework plugins for accurate detection.

Guidelines

  • Zero config works — Knip auto-detects frameworks (Next.js, Remix, Vite, etc.)
  • Framework plugins are key — they tell Knip about framework-specific entry points
  • Start with npx knip — see what it finds before configuring
  • --fix is cautious — it prefixes unused exports with _, doesn't delete
  • --allow-remove-files for cleanup — actually removes orphan files
  • Ignore test files in ignore — tests reference things that aren't "used" by app code
  • ignoreDependencies for false positives — runtime-only deps that Knip can't trace
  • Run before major refactors — know what's dead before restructuring
  • CI enforcement prevents regression — new dead code fails the build

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 Knip 工具的使用指南,用于查找和删除 JavaScript/TypeScript 项目中未使用的文件、依赖项和导出,具有明确的开发运维场景和广泛受众的实用价值。
Trigger Precision95/100

Highlights

  • 触发词精准完整,覆盖多种变体,如 'find unused code', 'clean up dependencies', 'remove dead code' 等,边界清晰。
Structure and Standards95/100

Highlights

  • 结构清晰,包含 Overview、When to Use、Instructions、Examples、Guidelines 等章节,步骤划分明确,有端到端示例,frontmatter 完整。
Execution Reliability75/100

Areas to improve

  • 未覆盖主要异常处理 Reported severity: Minor

    Skill 提供了 Knip 的安装、运行、配置、CI 集成和修复模式的详细命令和示例,但未明确提及如何处理 Knip 执行过程中可能出现的错误(如配置文件错误、权限问题等),也未说明在哪些情况下 Knip 可能产生误报或漏报。

    Recommendation: 建议补充 Knip 执行过程中常见错误的处理方法,以及误报/漏报的识别和应对策略,以提高执行可靠性。

Highlights

  • 工具来源明确(npx knip),参数正确,覆盖了主要使用场景。
Evidence Verifiability (mean of the first four)88/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

```bash npx knip # Zero config — works out of the box

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.