Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
laurigates avatar

Knip Dead Code

  • 42 installs
  • 49 repo stars
  • Updated August 4, 2026
  • laurigates/claude-plugins

Helps with ai & agent building tasks.

About

knip-dead-code is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.

  • knip-dead-code
  • AI & Agent Building
  • AI-coding skill

Knip Dead Code by the numbers

  • 42 all-time installs (skills.sh)
  • Ranked #8,070 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/laurigates/claude-plugins --skill knip-dead-code

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs42
repo stars49
Last updatedAugust 4, 2026
Repositorylaurigates/claude-plugins

What it does

Helps with ai & agent building tasks.

Files

SKILL.mdMarkdownGitHub ↗

Knip Dead Code Detection

Knip is a comprehensive tool for finding unused code, dependencies, and exports in JavaScript and TypeScript projects. It helps maintain clean codebases and catch dead code before it accumulates.

When to Use This Skill

Use this skill when...Use another approach when...
Finding unused dependenciesRemoving unused CSS (use PurgeCSS)
Detecting unused exports in librariesFinding runtime dead code paths
Cleaning up codebases after refactorsOptimizing bundle size (use bundler tree-shaking)
Enforcing dependency hygiene in CIDetecting duplicate dependencies (use npm-dedupe)

Core Expertise

What is Knip?

  • Unused detection: Files, dependencies, exports, types, enum members
  • Plugin system: Supports 80+ frameworks and tools
  • Fast: Analyzes large codebases in seconds
  • Actionable: Clear reports with file locations
  • CI-ready: Exit codes for failing builds

Installation

# Project-local (recommended)
bun add --dev knip

# Verify installation
bunx knip --version

Basic Usage

# Run Knip (scans entire project)
bunx knip

# Show only unused dependencies
bunx knip --dependencies

# Show only unused exports
bunx knip --exports

# Show only unused files
bunx knip --files

# Production mode (only check production dependencies)
bunx knip --production

# Exclude specific issue types
bunx knip --exclude-exports-used-in-file

# Output JSON (for CI)
bunx knip --reporter json

# Debug mode (show configuration)
bunx knip --debug

Configuration

Auto-detection (Zero Config)

Knip automatically detects:

  • Entry points (package.json main, exports, bin)
  • Frameworks (Next.js, Vite, Remix, etc.)
  • Test runners (Vitest, Jest, Playwright)
  • Build tools (ESLint, TypeScript, PostCSS)

No configuration needed for standard projects.

knip.json (Explicit Configuration)

{
  "$schema": "https://unpkg.com/knip@latest/schema.json",
  "entry": ["src/index.ts", "src/cli.ts"],
  "project": ["src/**/*.ts"],
  "ignore": ["**/*.test.ts", "scripts/**"],
  "ignoreDependencies": ["@types/*"],
  "ignoreBinaries": ["npm-check-updates"]
}

knip.ts (TypeScript Configuration)

// knip.ts
import type { KnipConfig } from 'knip';

const config: KnipConfig = {
  entry: ['src/index.ts', 'src/cli.ts'],
  project: ['src/**/*.ts', 'scripts/**/*.ts'],
  ignore: ['**/*.test.ts', '**/*.spec.ts', 'tmp/**'],
  ignoreDependencies: [
    '@types/*', // Type definitions
    'typescript', // Always needed
  ],
  ignoreExportsUsedInFile: true,
  ignoreWorkspaces: ['packages/legacy/**'],
};

export default config;

Common Patterns

Check Only Unused Dependencies

# Fastest check - only dependencies
bunx knip --dependencies

# Exit with error if any unused dependencies
bunx knip --dependencies --max-issues 0

Use in CI to enforce strict dependency hygiene.

Check Only Exports (Library Development)

# Check for unused exports
bunx knip --exports

# Allow exports used in same file
bunx knip --exports --exclude-exports-used-in-file

Use for libraries to ensure clean public API.

Production vs Development Dependencies

# Check production code only
bunx knip --production

# Check everything (including dev dependencies)
bunx knip

Interpreting Results

Example Output

No unused files
No unused dependencies
2 unused exports

src/utils.ts:
  - calculateTax (line 42)
  - formatDate (line 58)

src/types.ts:
  - UserRole (line 12)

Issue Types

TypeDescriptionAction
Unused fileFile not imported anywhereDelete or add to entry points
Unused dependencyPackage in package.json not usedRemove from dependencies
Unused exportExported but never importedRemove export or make private
Unused typeType/interface exported but unusedRemove or make internal
Unused enum memberEnum member never referencedRemove member
Duplicate exportSame export from multiple filesConsolidate exports

Agentic Optimizations

ContextCommand
Quick scanbunx knip
Dependencies onlybunx knip --dependencies
Exports onlybunx knip --exports
CI strict modebunx knip --max-issues 0
Production checkbunx knip --production
JSON outputbunx knip --reporter json
Debug configbunx knip --debug
Changed filesbunx knip --changed --base main

Quick Reference

FlagDescription
--dependenciesCheck only unused dependencies
--exportsCheck only unused exports
--filesCheck only unused files
--productionProduction dependencies only
--max-issues NFail if more than N issues
--reporter jsonJSON output for CI
--reporter compactCompact output
--debugShow configuration details
--changedCheck only changed files
--changed --base mainChanged files since main
--workspace NAMECheck specific workspace
--exclude-exports-used-in-fileIgnore same-file exports

For detailed examples, advanced patterns, and best practices, see REFERENCE.md.

References

  • Official docs: https://knip.dev
  • Configuration: https://knip.dev/reference/configuration
  • Plugins: https://knip.dev/reference/plugins
  • CLI reference: https://knip.dev/reference/cli
  • FAQ: https://knip.dev/reference/faq

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.