skills/knip/SKILL.md
Run knip to find and remove unused files, dependencies, and exports. Use for cleaning up dead code and unused dependencies.
npx skillsauth add fantomsuj/notion knipInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Run knip to find and remove unused files, dependencies, and exports from this codebase.
Check if knip is available:
npx knip --version to testknip is in package.json devDependenciesnpm install -D knip (or pnpm/yarn/bun equivalent based on lockfile present)Knip does NOT remove unused imports/variables inside files — that's a linter's job. Knip finds unused files, dependencies, and exports across the project.
Always follow this configuration-first workflow. Even for simple "run knip" or "clean up codebase" prompts, configure knip properly before acting on reported issues.
knip.json, knip.jsonc, or knip key in package.json)npx knip
Focus on configuration hints before anything else. These appear at the top of the output and suggest config adjustments to reduce false positives.
Fix configuration hints before addressing reported issues. Common adjustments:
Re-run knip after each config change. Repeat until configuration hints are resolved and false positives are minimized.
Once the configuration is settled, work through reported issues. Prioritize in this order:
ignoreExportsUsedInFile (see below)Re-run knip after each batch of fixes. Removing unused files often exposes newly-unused exports and dependencies.
When reviewing or creating a knip config, follow these rules:
ignore patterns — ignore hides real issues and should almost never be used. Always prefer specific solutions. Other ignore* options (like ignoreDependencies, ignoreExportsUsedInFile) are fine because they target specific issue types.ignoreExportsUsedInFile: { interface: true, type: true } — this handles the common case of types only used in the same file. Prefer this over broader ignore options..gitignore, so ignoring node_modules, dist, build, .git is redundant.vite.config.ts) — Enable or disable the corresponding plugin explicitly rather than ignoring the file.buffer, process) — Add to ignoreDependencies.paths to knip config (uses tsconfig.json semantics).Use --production to focus on production code only:
npx knip --production
This excludes test files, config files, and other non-production entry points. Do NOT use project or ignore patterns to exclude test files — use --production instead.
src/index, lib/, or files with "public" or "api" in the nameUse the AskUserQuestion tool to clarify before deleting these.
Once configuration is settled and you're confident in the results:
# Auto-fix safe changes (removes unused exports and dependencies)
npx knip --fix
# Auto-fix including file deletion
npx knip --fix --allow-remove-files
Only use --fix after the configuration-first workflow is complete.
If knip exits with code 2 (unexpected error like "error loading file"):
knip.json in the project root# Basic run
npx knip
# Production only (excludes test/config entry points)
npx knip --production
# Auto-fix what's safe
npx knip --fix
# Auto-fix including file deletion
npx knip --fix --allow-remove-files
# JSON output for parsing
npx knip --reporter json
--workspace flagdevelopment
Workflow orchestration for complex coding tasks. Use for ANY non-trivial task (3+ steps or architectural decisions) to enforce planning, subagent strategy, self-improvement, verification, elegance, and autonomous bug fixing. Triggers: multi-step implementation, bug fixes, refactoring, architectural changes, or any task requiring structured execution.
development
Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
tools
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
development
Simplify and refine recently modified code for clarity and consistency. Use after writing code to improve readability without changing functionality.