返回 Skill 列表
extension
分类: 开发与工程无需 API Key

knip-deadcode-best-practices

Knip死代码检测最佳实践,适用于JavaScript和TypeScript项目。在配置Knip、分析未使用的代码、设置CI集成或清理代码库时使用。触发条件包括knip.json、死代码、未使用的导出、未使用的依赖项、包优化。

person作者: jakexiaohubgithub

Community Knip Dead Code Detection Best Practices

Comprehensive guide for detecting and removing dead code in JavaScript and TypeScript projects using Knip. Contains 43 rules across 8 categories, prioritized by impact to guide configuration, CI integration, and cleanup workflows.

When to Apply

Reference these guidelines when:

  • Configuring Knip for a new project or monorepo
  • Investigating false positives or false negatives
  • Setting up CI pipelines to prevent dead code regressions
  • Using auto-fix to clean up unused code
  • Optimizing Knip performance for large codebases

Rule Categories by Priority

| Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | Configuration Foundations | CRITICAL | config- | | 2 | Entry Point Strategy | CRITICAL | entry- | | 3 | Workspace & Monorepo | HIGH | workspace- | | 4 | Dependency Analysis | HIGH | deps- | | 5 | Export Detection | MEDIUM-HIGH | exports- | | 6 | CI Integration | MEDIUM | ci- | | 7 | Auto-Fix Workflow | MEDIUM | fix- | | 8 | Performance Optimization | LOW-MEDIUM | perf- |

Quick Reference

1. Configuration Foundations (CRITICAL)

2. Entry Point Strategy (CRITICAL)

3. Workspace & Monorepo (HIGH)

4. Dependency Analysis (HIGH)

5. Export Detection (MEDIUM-HIGH)

6. CI Integration (MEDIUM)

7. Auto-Fix Workflow (MEDIUM)

8. Performance Optimization (LOW-MEDIUM)

How to Use

Read individual reference files for detailed explanations and code examples:

Reference Files

| File | Description | |------|-------------| | references/_sections.md | Category definitions and ordering | | assets/templates/_template.md | Template for new rules | | metadata.json | Version and reference information |