Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

knip-dead-code砍死代码

Agent Skill

knip-dead-code 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

941

周安装

40

GitHub Stars

28

下载量

330
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:knip-dead-code(砍死代码)
来源仓库:https://github.com/laurigates/claude-plugins
仓库路径:skills/knip-dead-code
安装命令:
npx skills add https://github.com/laurigates/claude-plugins --skill knip-dead-code
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/laurigates/claude-plugins --skill knip-dead-code

简介

knip-dead-code 用于查找、检索和筛选相关信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中根据关键词、任务场景或来源线索快速定位候选结果时使用。
  • 可结合来源仓库、安装命令和原始 README 继续核验具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

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

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.73%
按下载量换算128

Claude

29.17%
按下载量换算96

Cursor

17.5%
按下载量换算58

Gemini CLI

8.67%
按下载量换算29

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills