Skip to content
Automation
Skill

/knip-cleanup

Add knip to a TypeScript project and use it to remove dead exports, collapse pass-through barrels, and narrow every export to what another file actually imports. Trigger on "add knip", "set up knip", "find dead code", "remove unused exports", "clean up barrel files", "get rid of

From plugin
jobpilot
10432 skills4 agents2 MCP

Claude Code

$ npx -y skills add suxrobGM/jobpilot --skill knip-cleanup --agent claude-code

SKILL.md

knip-cleanup.SKILL.md
name: knip-cleanup
description: Add knip to a TypeScript project and use it to remove dead exports, collapse pass-through barrels, and narrow every export to what another file actually imports. Trigger on "add knip", "set up knip", "find dead code", "remove unused exports", "clean up barrel files", "get rid of export *", "why is this exported".
metadata:
  version: "1.0"

Knip Integration and Barrel Cleanup

Four phases, each one committed and verified on its own. Later phases depend on earlier ones: every deletion exposes another layer of dead code, so knip is re-run between them rather than once at the start.

Do not start at phase 3. A knip baseline full of false positives will delete something real.

Phase 0: measure before believing the complaint

If the user also reports line-ending churn on every format, check before changing anything:

git ls-files --eol | awk '{print $1, $2}' | sort | uniq -c | sort -rn | head
<formatter> --check .    # biome check . / prettier --check .

`i/lf w/lf` across the board with a clean formatter run means the tracked tree is already normalized and the churn is in **newly created** files. The fix is prevention, not renormalizing: `.editorconfig` with `end_of_line = lf`, the editor's own EOL setting (`"files.eol": "\n"` for VS Code), and `git config core.autocrlf false` locally. Renormalizing a tree that is already LF produces a huge no-op diff and fixes nothing.

Phase 1: a baseline that is actually true

Install knip at the **repo root**, one config, one script. In a monorepo never give each package its own config: a per-workspace run cannot see that another workspace imports the symbol, so every shared export reads as dead.

{
  "$schema": "https://unpkg.com/knip@<major>/schema.json",
  "tags": ["-knipignore"],
  "workspaces": {
    "packages/lib": {
      "entry": ["src/index.ts", "src/**/*.test.ts"],
      "project": ["src/**/*.ts"],
      "includeEntryExports": true,
      "ignoreExportsUsedInFile": true
    }
  }
}

Then iterate until the report contains **only real findings**. Expect these, in this order:

  • **Every compiled entrypoint must be listed.** Grep the Dockerfiles, CI, and build scripts for

`--outfile`, `--entry`, `bun build`, `esbuild`. A second binary built from `src/worker.ts` is invisible to knip and its whole dependency tree reports as unused.

  • **Config files that read env at load time** (`prisma.config.ts` and friends) crash knip's plugin

loader. Disable that plugin (`"prisma": false`) rather than faking the variable.

  • **`includeEntryExports: true` wherever `package.json` `exports` uses wildcards.** A map like

`"./utils/*": "./src/utils/*.ts"` makes *every file* an entry, and knip then reports nothing at all for that package. Verify by adding a deliberately unused export and confirming knip sees it — silence is the failure mode here, so it will not announce itself.

  • **Framework-indirect dependencies** (`@prisma/client`, `pg`, a JWT lib reached through a plugin)

go in `ignoreDependencies`. Check each one is genuinely reached before ignoring it.

  • **Type-level assertions are not dead code.** A `type XInSync = [Assert<A, B>, Assert<B, A>]`

drift guard has no runtime caller by design. Tag it `@knipignore` (with `"tags": ["-knipignore"]` in the config) and say in a comment what it guards. Deleting it silently removes a check.

Commit the config and the script separately from any deletion.

Phase 2: dead exports, before touching barrels

Pure subtraction, no import churn, so it lands cleanly and reviews easily.

Cross-check every finding against a repo-wide grep before deleting. `files=1 refs=1` (the declaration is the only occurrence) is safe. More than that needs a look, and the reasons split into four:

| What grep shows | What it means | What to do | | --- | --- | --- | | Only the declaration | Truly dead | Delete | | A same-named declaration in another workspace | Duplicate, this copy is dead | Delete this one | | Hits only in a barrel's re-export line | The forwarding line is dead, not the symbol | Handle in phase 3 | | Hits in a comment | Not a reference | Delete |

Then delete, and **re-run knip after deleting**: removing a function usually orphans the data tables and helper types it used, which were invisible while it existed.

Two traps when automating the deletion:

  • Deleting a declaration by brace balance breaks on chained expressions

(`export const x = new Builder().use(a).derive(b)`) — the balance returns to zero mid-chain. Verify with a lint run and hand-edit the mangled file rather than tuning the heuristic.

  • Deletions strand imports and module-level state. Run the formatter's unsafe autofix

(`biome check --write --unsafe`, `eslint --fix`) on the touched files, then read what it could not fix.

Phase 3: barrels, by whether they earn their keep

State the rule before writing any code, because it decides the size of the diff. A barrel stays only when **it aggregates more than one file and has more than one importer outside its own directory**. Everything else is indirection: `export *`, single-file forwarders, and barrels with one caller.

Classify first and show the counts — the split is usually lopsided and tells you where the real work is. In one monorepo it was 168 barrels: 74 `export *`, 75 named, 18 with real code; after the rule, all 45 survivors were frontend component aggregators and the backend kept none.

Two barrels must never be deleted:

  • Anything `package.json` `exports` points at. Deleting `src/utils/index.ts` when the map says

`"./utils": "./src/utils/index.ts"` breaks every consumer, and **typecheck inside that package still passes** — the break only shows up in the packages that import it. `export *` is defensible in exactly this position, since the subpath is the unit of API.

  • A barrel that a *surviving* barrel re-exports from. Repoint the parent's `export ... from` lines

at the concrete files first, then drop the c

Read more
@suxrobgm
Ships withjobpilot

An AI agent that applies to jobs for you, using the Claude or Codex subscription you already have. Open JobPilot → · Docs · How it works · Changelog Watch it full size → Applying for jobs takes hours.

10432 skills4 agents2 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
104
Star history of suxrobGM/jobpilot on GitHub, a chart by star-history.com

Other skills on jobpilot.

add-api-route

add-api-route

Add a new JobPilot API route or module the standard way - contracts schema, controller, service, response schema, optional web…

@suxrobgm@suxrobgmInstall Skill
commit

commit

Write a git commit with a one-sentence Conventional Commits subject and no narrative body. Use whenever the user asks to commit,…

@suxrobgm@suxrobgmInstall Skill
db-migrate

db-migrate

Create and apply a Prisma migration safely against the remote (tunneled) PostgreSQL. Use for schema changes - "create a…

@suxrobgm@suxrobgmInstall Skill
pr-review

pr-review

Review a JobPilot pull request on its own branch, resolve merge conflicts with main, remove over-engineering, redundancy,…

@suxrobgm@suxrobgmInstall Skill
release

release

Bump the unified JobPilot version (host + plugin), update the changelog, commit, and tag a new release

@suxrobgm@suxrobgmInstall Skill
restart-terminal

restart-terminal

Rebuild the .NET terminal host, restart it, and wait for /healthz. Use after any C# change under apps/terminal, or when asked to…

@suxrobgm@suxrobgmInstall Skill

More skills from other plugins.

agent-builder

agent-builder

Load immediately after an Agent intent, before the first agent_builder_* call. Governs how you create, configure, test, and…

n8n11d209k
@n8n-io@n8n-ioInstall Skill
browser-use

browser-use

Direct browser control via CDP for web interaction: automation, scraping, testing, screenshots, and site/app work. Also covers…

@browser-use@browser-useInstall Skill
agent-browser

agent-browser

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling…

@vercel-labs-2@vercel-labs-2Install Skill
add-anydoc

add-anydoc

Add local office-document-to-Markdown conversion to NanoClaw agent containers with the pinned Firecrawl AnyDoc CLI. Use when…

@nanocoai@nanocoaiInstall Skill

Questions about knip-cleanup.

Which coding agents can use knip-cleanup?
knip-cleanup installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.