knip-cleanup

Removes dead exports and pass-through barrel files from TypeScript projects using knip.

73|19|Updated Mar 22, 2026
One-click install
npx skills add https://github.com/suxrobGM/jobpilot --skill knip-cleanup-suxrobgm
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: knip-cleanup
Source: https://github.com/suxrobGM/jobpilot/tree/main/.claude/skills/knip-cleanup
Command: npx skills add https://github.com/suxrobGM/jobpilot --skill knip-cleanup-suxrobgm

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? TypeScript codebases accumulate unused exports, redundant barrel files, and over-exported symbols that bloat the public API and slow refactors. This Skill sets up knip correctly and walks through a phased cleanup that deletes dead code without breaking builds. ## Core Features & Use Cases - Accurate knip baseline: Configures a single root-level knip config for monorepos, handles entry points, wildcard package exports, and framework-indirect dependencies so the report contains only real findings. - Phased dead code removal: Deletes unused exports, collapses pass-through barrels, and narrows exports to what other files actually import, re-running knip between phases since each deletion exposes more dead code. - Automated barrel rewriting: Ships a references/debarrel.py script that classifies barrels as keep or drop, rewrites importers to the declaring module, and refuses to delete anything still referenced or pinned by package.json exports. - Use Case: In a monorepo with 168 barrel files, classify them with the script, keep only genuine public API aggregators, rewrite importers, and verify with typecheck, tests, and a production build. ## Quick Start Ask the agent to add knip to this TypeScript repo and remove all dead exports and pass-through barrel files.

Frequently Asked Questions about knip-cleanup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find and remove unused exports in a TypeScript project?▼

Install knip at the repo root with one config covering all workspaces, then iterate until the report shows only real findings. Delete exports whose only grep hit is the declaration, and re-run knip after each deletion since removing code orphans its helpers.

How to clean up barrel files and export * in TypeScript?▼

Keep a barrel only when it aggregates multiple files with multiple outside importers or is pinned by package.json exports. Use the debarrel.py script to rewrite importers to the declaring module, then delete the pass-through barrel and verify with a real build.

Why does knip report false positives in a monorepo?▼

Per-workspace knip configs cannot see cross-workspace imports, so shared exports read as dead. Use one root config, list every compiled entrypoint, enable includeEntryExports for wildcard package exports, and ignore framework-indirect dependencies.

Can I delete a barrel file that package.json exports points to?▼

No. Deleting a barrel addressed by package.json exports breaks every consumer, and typecheck inside that package still passes. The debarrel.py script refuses to delete such pinned barrels automatically.

Why is typecheck not enough after removing dead code?▼

Typecheck passes on a deleted package entry point and cannot see bundler or server/client boundaries. Always run the formatter, full typecheck, tests, and a real production build after each cleanup phase.