knip-dead-code skill
✓ VerifiedDetects unused files, dependencies, exports, types, and members in JavaScript and TypeScript projects.
- GitHub stars
- 13
- Files
- 2
- Last commit
- Nov 12, 2026
- License
- MIT
- Allowed tools
- —
What does the knip-dead-code skill do?
knip-dead-code detects unused files, dependencies, exports, types, and members in JavaScript and TypeScript projects.
Summary generated from the skill's SKILL.md.
About the knip-dead-code skill
Cleaning up JavaScript and TypeScript projects by identifying dead code is what this skill enables. Developers use it to find unused files, dependencies, exports, types, and members within their codebase. It is particularly useful after deleting features or when trying to reduce bundle sizes and security risks by removing unnecessary npm dependencies.
An agent should load this tool when tasked with codebase maintenance or preparing a project for a pull request. The skill relies on the Knip engine and requires Node version 20.19.0 or Bun. It works by walking an import graph starting from defined entry points to see which files in the project are unreachable. It supports various framework plugins for Next.js, Remix, Astro, Vite, Storybook, Playwright, and Jest to ensure routes and test files are correctly recognized.
While it handles most static analysis, it cannot track dynamic imports with computed paths or reflection-heavy dependency injection containers. Users can manage large amounts of technical debt by using the --max-show-issues flag or by creating a baseline to prevent new dead code from being merged into a repository.
What an agent can do with it
- 1Remove unused project dependenciesIdentify npm packages that are no longer being used in the codebase to improve security and bundle size.
- 2Clean up after feature deletionFind orphaned files and exports that remain in the project after a feature or route has been removed.
- 3Prevent dead code in CISet up a gate in your continuous integration pipeline to fail builds when new unused exports are introduced.
- 4Manage large existing technical debtCreate a baseline of current unused items so that the tool only flags new issues in a brownfield project.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the knip-dead-code skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the knip-dead-code skill in Plugin
/plugin marketplace add testland/qa /plugin install qa-code-quality@testland-qa
Install the knip-dead-code skill in Claude Code
~/.claude/skills/knip-dead-code/SKILL.md
$ npx degit testland/qa/plugins/qa-code-quality/skills/knip-dead-code ~/.claude/skills/knip-dead-codeInstall the knip-dead-code skill in Claude Code (project)
.claude/skills/knip-dead-code/SKILL.md
$ npx degit testland/qa/plugins/qa-code-quality/skills/knip-dead-code .claude/skills/knip-dead-codeInstall the knip-dead-code skill in Codex
~/.agents/skills/knip-dead-code/SKILL.md
$ npx degit testland/qa/plugins/qa-code-quality/skills/knip-dead-code ~/.agents/skills/knip-dead-codeInstall the knip-dead-code skill in Gemini CLI
~/.gemini/skills/knip-dead-code/SKILL.md
$ npx degit testland/qa/plugins/qa-code-quality/skills/knip-dead-code ~/.gemini/skills/knip-dead-codeInstall the knip-dead-code skill in Claude.ai
npx degit testland/qa/plugins/qa-code-quality/skills/knip-dead-code knip-dead-code && zip -r knip-dead-code.zip knip-dead-code # claude.ai → Customize → Skills → + → Create skill → Upload a skill → knip-dead-code.zip
Automated checks
Ran Nov 15, 2026Full report →Passed our automated checks. That is not a security audit: read the scripts before you let an agent run them. How checks work · What to fix for more points
- Source repository linked and reachabletestland/qa/plugins/qa-code-quality/skills/knip-dead-code is public and reachablegithub.com/testland/qa/tree/HEAD/plugins/qa-code-quality/ski ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit 2026-11-12github.com/testland/qa/commits ↗Pass
- No download-and-run or credential theft in scriptsNo scripts in the skill folderPass
- No hidden instructions in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/testland/qa/blob/HEAD/plugins/qa-code-quality/ski ↗Pass
- Pre-approved tools are scopedNo pre-approved tools; the agent asks before using onegithub.com/testland/qa/blob/HEAD/plugins/qa-code-quality/ski ↗Pass
- SKILL.md follows the Agent Skills formatthe description does not say when to use the skillgithub.com/testland/qa/blob/HEAD/plugins/qa-code-quality/ski ↗Finding
SKILL.md
View on GitHubknip-dead-code
Knip detects unused files, dependencies, exports, types, enum members, and class members in JS/TS projects per the Knip docs. Requires Node ≥ 20.19.0 (or Bun).
When to use
- After a feature deletion when "everything still compiles" but you suspect dead code.
- Periodic cleanup to remove unused npm dependencies (security + bundle-size win).
- Pre-merge gate to prevent new dead exports from accumulating.
Step 1 - Install
# Recommended: setup wizard (auto-detects framework)
npm init @knip/config
# Manual
npm install -D knip typescript @types/node
Add package.json script:
{
"scripts": {
"knip": "knip"
}
}
Per the Knip docs.
Step 2 - Configure entry points
knip.json:
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"entry": [
"src/index.ts",
"src/cli.ts",
"scripts/**/*.ts"
],
"project": ["src/**/*.{ts,tsx}"],
"ignore": ["src/**/*.generated.ts"],
"ignoreDependencies": [
"@types/node"
],
"ignoreExportsUsedInFile": true
}
Or knip.config.ts for typed config.
Entry vs project: entry = files Knip starts walking the import
graph from. project = the universe of files it considers reachable.
Anything in project not reached from entry is unused.
Step 3 - First run
npx knip
Exit code: 0 if clean, non-zero if unused items found. Shows:
Unused files (3)
Unused dependencies (2)
Unused exports (12)
Unused exported types (4)
Unused exported enum members (1)
Step 4 - Use framework plugins
For framework-aware scanning, enable plugins (auto-detected by npm init @knip/config):
{
"next": {
"entry": ["next.config.{js,ts,cjs,mjs}", "app/**/page.{js,ts,tsx}"]
},
"playwright": {
"config": "playwright.config.ts",
"entry": ["e2e/**/*.spec.ts"]
}
}
Plugin list (Next.js, Remix, Astro, Vite, Storybook, Playwright, Jest, etc.) - see the Knip plugins page.
Step 5 - Limit output during cleanup
# Show only top 5 of each issue type - useful when first adopting
npx knip --max-show-issues 5
Per the Knip docs for overwhelming output.
Step 6 - CI gate
# GitHub Actions
- name: Knip dead-code check
run: npx knip
Fails build on any new dead code. For brownfield rollout, baseline existing dead code first:
# Snapshot current findings; CI only fails on additions
npx knip --no-exit-code > knip-baseline.txt
Step 7 - Per-issue triage
| Reported as | True positive? | Action |
|---|---|---|
| Unused file | Usually yes | Delete |
| Unused dependency | Usually yes | npm uninstall |
| Unused export | Sometimes (public API) | Mark with JSDoc @public + tags: ["public"] config |
| Unused enum member | Usually yes | Delete |
| Unused class member | Sometimes (public API) | Same as unused export |
Anti-patterns
| Anti-pattern | Why it fails | Fix |
|---|---|---|
| Run without entry points | Everything looks orphaned | Always set entry (Step 2) |
| Treat "unused export" as "delete now" | Public library APIs flag as unused | Use tags: ["public"] for library packages |
| Skip framework plugins | Next.js page files look orphaned (Knip doesn't know they're routes) | Enable plugin (Step 4) |
| Block PRs from day 1 in brownfield | Hundreds of pre-existing unused; team disables tool | Baseline first (Step 6 alt path) |
| Auto-fix mode on first run | --fix deletes legitimate unused public exports |
Manual review first; --fix after baseline clean |
Limitations
- Dynamic imports with computed paths (
import(\./${name}`)) cannot be statically tracked; Knip flags dependencies as unused even though they load at runtime. UseignoreDependencies` for these cases. - Side-effect imports (e.g.,
import "./polyfill") are tracked, but reflection-heavy code (DI containers that instantiate via string names) requires manualignoreentries.
References
- Knip docs - install, entry/project config, framework plugins
- Knip plugins page - full plugin list (Next.js, Remix, Astro, Storybook, Vite, etc.)
Files in this skill
2knip-dead-code skill questions
How do I install the knip-dead-code skill in Claude Code?
Run npx degit testland/qa/plugins/qa-code-quality/skills/knip-dead-code ~/.claude/skills/knip-dead-code. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the knip-dead-code skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
What can Knip detect in a project?
Knip identifies unused files, dependencies, exports, types, enum members, and class members.
How do I prevent Knip from flagging my Next.js routes as unused?
You should enable framework-aware plugins, such as the Next.js plugin, so Knip understands the project structure.
Can I use Knip in a CI/CD pipeline?
Yes, you can add it as a GitHub Action to fail builds if new dead code is introduced.