install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/knip-deadcode" ~/.claude/skills/comeonoliver-skillshub-knip-deadcode && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/knip-deadcode/SKILL.mdsource content
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 | |
| 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 | |
Quick Reference
1. Configuration Foundations (CRITICAL)
- Avoid broad ignore patternsconfig-avoid-broad-ignore
- Configure path aliases in Knipconfig-configure-path-aliases
- Enable framework plugins explicitlyconfig-enable-plugins-explicitly
- Run without config first for baselineconfig-run-without-config
- Separate entry files from project filesconfig-separate-entry-project
- Use JSON schema for configuration validationconfig-use-json-schema
- Use negation patterns for exclusionsconfig-use-negation-patterns
- Use production mode for shipping code analysisconfig-use-production-mode
2. Entry Point Strategy (CRITICAL)
- Add dynamic import targets as entry pointsentry-add-dynamic-imports
- Exclude test files from production entriesentry-exclude-test-files
- Include all application entry pointsentry-include-all-entry-points
- Include binary scripts as entry pointsentry-include-bin-scripts
- Use compilers for non-standard file typesentry-use-compilers
- Use plugin entry points for frameworksentry-use-plugin-entries
- Verify entry points with debug modeentry-verify-with-debug
3. Workspace & Monorepo (HIGH)
- Configure root workspace explicitlyworkspace-configure-root-workspace
- Ignore specific workspaces when neededworkspace-ignore-specific
- Isolate workspaces for strict dependency checkingworkspace-isolate-for-strict
- List cross-workspace dependencies explicitlyworkspace-list-cross-deps
- Configure plugins per workspaceworkspace-per-workspace-plugins
- Use workspace globs for consistent configurationworkspace-use-workspace-globs
4. Dependency Analysis (HIGH)
- Add unlisted dependencies to package.jsondeps-add-unlisted-deps
- Avoid relying on transitive dependenciesdeps-avoid-transitive-reliance
- Configure plugins for tool-specific dependenciesdeps-configure-plugin-deps
- Fix unused files before dependenciesdeps-fix-files-first
- Ignore conditionally loaded dependenciesdeps-ignore-conditional-deps
- Remove obsolete type definition packagesdeps-remove-obsolete-types
5. Export Detection (MEDIUM-HIGH)
- Check class members for unused codeexports-check-class-members
- Enable entry export checking for private packagesexports-enable-entry-exports
- Handle re-exports in barrel filesexports-handle-reexports
- Ignore exports used in same fileexports-ignore-same-file
- Tag public API exports with JSDocexports-tag-public-api
- Trace export usage before removalexports-trace-usage
- Use include libs for type-based consumptionexports-use-include-libs
6. CI Integration (MEDIUM)
- Add Knip to CI pipelineci-add-to-pipeline
- Separate production and default mode checksci-separate-production-check
- Enable cache for faster CI runsci-use-cache
- Use max issues for gradual adoptionci-use-max-issues
- Use appropriate reporters for CI outputci-use-reporters
- Use watch mode for local developmentci-watch-mode-local
7. Auto-Fix Workflow (MEDIUM)
- Explicitly allow file removalfix-allow-remove-files
- Format code after auto-fixfix-format-after-fix
- Review auto-fix changes before commitfix-review-before-commit
- Update package manager after dependency fixfix-update-deps-after
- Use fix type for targeted cleanupfix-use-fix-type
8. Performance Optimization (LOW-MEDIUM)
- Filter issue types for focused analysisperf-filter-issue-types
- Limit output for large codebasesperf-limit-output
- Profile performance for slow analysisperf-profile-performance
- Use Bun runtime for faster analysisperf-use-bun-runtime
- Enable cache for repeated analysisperf-use-cache-flag
- Filter workspaces for faster monorepo analysisperf-use-workspace-filter
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 |