knip
Find and remove unused files, dependencies, and exports in JavaScript/TypeScript projects with Knip. Use when someone asks to "find unused code", "clean up dependencies", "remove dead code", "find unused exports", "Knip", "reduce bundle size by removing unused files", or "audit npm dependencies". Covers unused files, dependencies, exports, types, and CI integration.
What this skill does
# Knip
## Overview
Knip finds unused files, dependencies, and exports in your TypeScript/JavaScript project. It understands your project structure — framework entry points, config files, scripts — and reports what's truly unused. Unlike ESLint's no-unused-vars (which only checks within files), Knip works across the entire project: unused exports, orphan files, unlisted dependencies, and packages in package.json that no code actually imports.
## When to Use
- Cleaning up a codebase that's accumulated dead code over time
- Auditing npm dependencies (unused, unlisted, or duplicate)
- Reducing bundle size by removing unused exports
- Pre-refactoring analysis to identify what can be safely deleted
- CI gate to prevent new unused code from being merged
## Instructions
### Setup
```bash
npx knip # Zero config — works out of the box
# Or install
npm install -D knip
```
### What Knip Detects
```bash
# Run a full analysis
npx knip
# Output:
# Unused files (2)
# src/utils/legacy-helper.ts
# src/components/OldBanner.tsx
#
# Unused dependencies (3)
# lodash
# moment
# chalk
#
# Unused exports (5)
# src/lib/api.ts: formatDate, parseResponse
# src/types/index.ts: LegacyUser, OldConfig
# src/utils/math.ts: calculateTax
#
# Unlisted dependencies (1)
# dotenv (used in src/config.ts but not in package.json)
```
### Configuration
```json
// knip.json — Customize detection
{
"entry": ["src/index.ts", "src/server.ts"],
"project": ["src/**/*.{ts,tsx}"],
"ignore": ["**/*.test.ts", "**/*.spec.ts"],
"ignoreDependencies": ["@types/node"],
"ignoreBinaries": ["docker"],
// Framework plugins (auto-detected)
"next": { "entry": ["pages/**/*.tsx", "app/**/*.tsx"] },
"vitest": { "entry": ["**/*.test.ts"] }
}
```
### CI Integration
```yaml
# .github/workflows/knip.yml — Fail CI on unused code
name: Unused Code Check
on: [pull_request]
jobs:
knip:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci
- run: npx knip
```
### Fix Mode
```bash
# Auto-remove unused exports (adds underscore prefix)
npx knip --fix
# Remove unused files
npx knip --fix --allow-remove-files
# Dry run — see what would change
npx knip --fix --dry-run
```
## Examples
### Example 1: Audit a legacy project
**User prompt:** "This project has 200+ files and we're not sure what's still used. Find all dead code."
The agent will run Knip to identify unused files, exports, and dependencies, then categorize results by confidence level and provide a cleanup plan.
### Example 2: Add to CI pipeline
**User prompt:** "Prevent new dead code from being merged. Add a CI check."
The agent will configure Knip with the project's entry points, add a GitHub Actions workflow, and set up framework plugins for accurate detection.
## Guidelines
- **Zero config works** — Knip auto-detects frameworks (Next.js, Remix, Vite, etc.)
- **Framework plugins are key** — they tell Knip about framework-specific entry points
- **Start with `npx knip`** — see what it finds before configuring
- **`--fix` is cautious** — it prefixes unused exports with `_`, doesn't delete
- **`--allow-remove-files` for cleanup** — actually removes orphan files
- **Ignore test files in `ignore`** — tests reference things that aren't "used" by app code
- **`ignoreDependencies` for false positives** — runtime-only deps that Knip can't trace
- **Run before major refactors** — know what's dead before restructuring
- **CI enforcement prevents regression** — new dead code fails the build
Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.