fix-knip-unused-exports

Classifies and fixes TypeScript knip unused export violations in monaco repos.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/oElberte/dotfiles --skill fix-knip-unused-exports
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: fix-knip-unused-exports
Source: https://github.com/oElberte/dotfiles/tree/main/private_dot_factory/plugins/marketplaces/factory-plugins/plugins/typescript/skills/fix-knip-unused-exports
Command: npx skills add https://github.com/oElberte/dotfiles --skill fix-knip-unused-exports

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

knip reports “Unused exports” in TypeScript monorepos, and the underlying issue varies (test-only exports, dead barrel re-exports, or exports used only internally), so blindly changing code can break tests or lint rules.

Core Features & Use Cases

  • Classify each knip violation category by scanning the whole repo while excluding test files to determine the correct fix strategy.
  • Apply targeted fixes: extract test-only exports into a new file, remove unused re-exports from index.ts barrels, or un-export internally-only-used symbols by removing the export keyword.
  • Verify safely after each change by re-running knip plus compile, tests, and lint to catch secondary issues like filename-match-export and test-imports-source.

Quick Start

Run npm run knip, then for each flagged export decide whether it is test-only, a dead barrel re-export, or internally-only-used, apply the corresponding fix, and re-run knip, typecheck, test, and lint.

Frequently Asked Questions about fix-knip-unused-exports

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

FAQPage Schema
How do I fix knip unused exports in a TypeScript monorepo without breaking tests?▼

Fix knip unused exports by classifying each flagged symbol as test-only, dead barrel re-export, or internally-only-used, then applying the correct targeted transformation before re-running validation. This approach prevents breaking tests or lint rules caused by blindly changing exported code.

What is the best way to handle TypeScript exports only used in test files?▼

Handle TypeScript exports only used in test files by extracting them into a new dedicated file. This remediation strategy removes the unused export violation from knip while preserving the test-only references by keeping them in a separate, non-exported module.

How do I remove unused barrel re-exports from an index.ts file?▼

Remove unused barrel re-exports from index.ts files by deleting the specific re-export statements flagged by knip. This unclutters the barrel file and resolves the violation without affecting actively used exports within the TypeScript monorepo.

Does knip require repository-wide scanning to fix unused exports?▼

Knip requires repository-wide scanning to fix unused exports correctly. Grep the entire repository while excluding test files to classify whether a flagged symbol is test-only, a dead barrel re-export, or used only internally within the defining file.

Why do I need to run typecheck and lint after fixing knip violations?▼

You need to run typecheck and lint after fixing knip violations to catch secondary issues like filename-match-export and test-imports-source rules. Verifying safely after each refactoring change ensures the export removal did not introduce new compilation or linting errors.