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
fix-review-before-commit - Review auto-fix changes before commit
fix-update-deps-after - Update package manager after dependency fix
fix-use-fix-type - Use fix type for targeted cleanup
8. Performance Optimization (LOW-MEDIUM)
perf-filter-issue-types - Filter issue types for focused analysis
perf-limit-output - Limit output for large codebases
perf-profile-performance - Profile performance for slow analysis
perf-use-bun-runtime - Use Bun runtime for faster analysis
perf-use-cache-flag - Enable cache for repeated analysis
perf-use-workspace-filter - Filter workspaces for faster monorepo analysis
How to Use
Read individual reference files for detailed explanations and code examples:
Section definitions - Category structure and impact levels
Rule template - Template for adding new rules
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
1---2name: knip-deadcode3description: Community Knip Dead Code Detection Best Practices4---5# Community Knip Dead Code Detection Best Practices67Comprehensive 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.89## When to Apply1011Reference these guidelines when:12- Configuring Knip for a new project or monorepo13- Investigating false positives or false negatives14- Setting up CI pipelines to prevent dead code regressions15- Using auto-fix to clean up unused code16- Optimizing Knip performance for large codebases1718## Rule Categories by Priority1920| Priority | Category | Impact | Prefix |21|----------|----------|--------|--------|22| 1 | Configuration Foundations | CRITICAL | `config-` |23| 2 | Entry Point Strategy | CRITICAL | `entry-` |24| 3 | Workspace & Monorepo | HIGH | `workspace-` |25| 4 | Dependency Analysis | HIGH | `deps-` |26| 5 | Export Detection | MEDIUM-HIGH | `exports-` |27| 6 | CI Integration | MEDIUM | `ci-` |28| 7 | Auto-Fix Workflow | MEDIUM | `fix-` |29| 8 | Performance Optimization | LOW-MEDIUM | `perf-` |3031## Quick Reference3233### 1. Configuration Foundations (CRITICAL)3435- [`config-avoid-broad-ignore`](references/config-avoid-broad-ignore.md) - Avoid broad ignore patterns36- [`config-configure-path-aliases`](references/config-configure-path-aliases.md) - Configure path aliases in Knip37- [`config-enable-plugins-explicitly`](references/config-enable-plugins-explicitly.md) - Enable framework plugins explicitly38- [`config-run-without-config`](references/config-run-without-config.md) - Run without config first for baseline39- [`config-separate-entry-project`](references/config-separate-entry-project.md) - Separate entry files from project files40- [`config-use-json-schema`](references/config-use-json-schema.md) - Use JSON schema for configuration validation41- [`config-use-negation-patterns`](references/config-use-negation-patterns.md) - Use negation patterns for exclusions42- [`config-use-production-mode`](references/config-use-production-mode.md) - Use production mode for shipping code analysis4344### 2. Entry Point Strategy (CRITICAL)4546- [`entry-add-dynamic-imports`](references/entry-add-dynamic-imports.md) - Add dynamic import targets as entry points47- [`entry-exclude-test-files`](references/entry-exclude-test-files.md) - Exclude test files from production entries48- [`entry-include-all-entry-points`](references/entry-include-all-entry-points.md) - Include all application entry points49- [`entry-include-bin-scripts`](references/entry-include-bin-scripts.md) - Include binary scripts as entry points50- [`entry-use-compilers`](references/entry-use-compilers.md) - Use compilers for non-standard file types51- [`entry-use-plugin-entries`](references/entry-use-plugin-entries.md) - Use plugin entry points for frameworks52- [`entry-verify-with-debug`](references/entry-verify-with-debug.md) - Verify entry points with debug mode5354### 3. Workspace & Monorepo (HIGH)5556- [`workspace-configure-root-workspace`](references/workspace-configure-root-workspace.md) - Configure root workspace explicitly57- [`workspace-ignore-specific`](references/workspace-ignore-specific.md) - Ignore specific workspaces when needed58- [`workspace-isolate-for-strict`](references/workspace-isolate-for-strict.md) - Isolate workspaces for strict dependency checking59- [`workspace-list-cross-deps`](references/workspace-list-cross-deps.md) - List cross-workspace dependencies explicitly60- [`workspace-per-workspace-plugins`](references/workspace-per-workspace-plugins.md) - Configure plugins per workspace61- [`workspace-use-workspace-globs`](references/workspace-use-workspace-globs.md) - Use workspace globs for consistent configuration6263### 4. Dependency Analysis (HIGH)6465- [`deps-add-unlisted-deps`](references/deps-add-unlisted-deps.md) - Add unlisted dependencies to package.json66- [`deps-avoid-transitive-reliance`](references/deps-avoid-transitive-reliance.md) - Avoid relying on transitive dependencies67- [`deps-configure-plugin-deps`](references/deps-configure-plugin-deps.md) - Configure plugins for tool-specific dependencies68- [`deps-fix-files-first`](references/deps-fix-files-first.md) - Fix unused files before dependencies69- [`deps-ignore-conditional-deps`](references/deps-ignore-conditional-deps.md) - Ignore conditionally loaded dependencies70- [`deps-remove-obsolete-types`](references/deps-remove-obsolete-types.md) - Remove obsolete type definition packages7172### 5. Export Detection (MEDIUM-HIGH)7374- [`exports-check-class-members`](references/exports-check-class-members.md) - Check class members for unused code75- [`exports-enable-entry-exports`](references/exports-enable-entry-exports.md) - Enable entry export checking for private packages76- [`exports-handle-reexports`](references/exports-handle-reexports.md) - Handle re-exports in barrel files77- [`exports-ignore-same-file`](references/exports-ignore-same-file.md) - Ignore exports used in same file78- [`exports-tag-public-api`](references/exports-tag-public-api.md) - Tag public API exports with JSDoc79- [`exports-trace-usage`](references/exports-trace-usage.md) - Trace export usage before removal80- [`exports-use-include-libs`](references/exports-use-include-libs.md) - Use include libs for type-based consumption8182### 6. CI Integration (MEDIUM)8384- [`ci-add-to-pipeline`](references/ci-add-to-pipeline.md) - Add Knip to CI pipeline85- [`ci-separate-production-check`](references/ci-separate-production-check.md) - Separate production and default mode checks86- [`ci-use-cache`](references/ci-use-cache.md) - Enable cache for faster CI runs87- [`ci-use-max-issues`](references/ci-use-max-issues.md) - Use max issues for gradual adoption88- [`ci-use-reporters`](references/ci-use-reporters.md) - Use appropriate reporters for CI output89- [`ci-watch-mode-local`](references/ci-watch-mode-local.md) - Use watch mode for local development9091### 7. Auto-Fix Workflow (MEDIUM)9293- [`fix-allow-remove-files`](references/fix-allow-remove-files.md) - Explicitly allow file removal94- [`fix-format-after-fix`](references/fix-format-after-fix.md) - Format code after auto-fix95- [`fix-review-before-commit`](references/fix-review-before-commit.md) - Review auto-fix changes before commit96- [`fix-update-deps-after`](references/fix-update-deps-after.md) - Update package manager after dependency fix97- [`fix-use-fix-type`](references/fix-use-fix-type.md) - Use fix type for targeted cleanup9899### 8. Performance Optimization (LOW-MEDIUM)100101- [`perf-filter-issue-types`](references/perf-filter-issue-types.md) - Filter issue types for focused analysis102- [`perf-limit-output`](references/perf-limit-output.md) - Limit output for large codebases103- [`perf-profile-performance`](references/perf-profile-performance.md) - Profile performance for slow analysis104- [`perf-use-bun-runtime`](references/perf-use-bun-runtime.md) - Use Bun runtime for faster analysis105- [`perf-use-cache-flag`](references/perf-use-cache-flag.md) - Enable cache for repeated analysis106- [`perf-use-workspace-filter`](references/perf-use-workspace-filter.md) - Filter workspaces for faster monorepo analysis107108## How to Use109110Read individual reference files for detailed explanations and code examples:111112- [Section definitions](references/_sections.md) - Category structure and impact levels113- [Rule template](assets/templates/_template.md) - Template for adding new rules114115## Reference Files116117| File | Description |118|------|-------------|119| [references/_sections.md](references/_sections.md) | Category definitions and ordering |120| [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules |121| [metadata.json](metadata.json) | Version and reference information |
Run npx skillmds@latest add comeonoliver/knip-deadcode in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Community Knip Dead Code Detection Best Practices It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.