@readmodelmag
MODEL

Tools

Builder tip: run Knip after your coding agent is done

SummaryWe planted the leftovers coding agents tend to leave in a small TypeScript repo and ran Knip 6.44.2. It found the dead file, two unused packages, two unused exports and one import missing from package.json. Its auto-fix only does part of the cleanup.

· MODEL Editors · 2 min read

Some links may be affiliate links. Disclosure

MODEL builder tip card on a cream background. Small red kicker: BUILDER TIP. Large red words: 5 leftovers. Black headline: Knip found what the agent left behind. Bottom left: MODEL. Bottom right: Sources: MODEL test, Knip 6.44.2.
MODEL hands-on test of Knip 6.44.2 on a small TypeScript repo, Nov 8, 2026. Illustration by MODEL. Original. Image source.

The problem. Ask a coding agent to try a few approaches and you often get the winner plus everything it tried along the way: an old version of a file nobody imports, packages it added and stopped using, helper functions exported "just in case". The reverse happens too. The agent imports a package that never made it into package.json, and it works on the agent's machine until it doesn't.

What we ran. Knip (open source, ISC license, by Lars Kappert) looks for unused files, dependencies and exports in JavaScript and TypeScript projects. On Nov 8 we installed knip@6.44.2 with TypeScript 5.9.3 on Node 24.22.1 and pointed it at a small TypeScript repo where we had planted these leftovers ourselves:

  • src/utils-old.ts, an earlier attempt that nothing imports
  • lodash and axios in dependencies, never imported
  • dayjs imported in src/index.ts but missing from package.json
  • formatPriceV2 and TAX_RATE exported from src/utils.ts, never used

No config file, no AI model, no API key.

What Knip found. One plain npx knip run caught all six, with file and line numbers, and exited with code 1:

  • Unused files (1): src/utils-old.ts
  • Unused dependencies (2): axios, lodash
  • Unlisted dependencies (1): dayjs
  • Unused exports (2): formatPriceV2, TAX_RATE

That exit code is the useful part. It means you can drop npx knip into CI or into an agent's "before you say done" checklist and it fails loudly.

The catch: --fix is a partial cleanup. We ran npx knip --fix on a copy of the repo:

  • It removed axios and lodash from package.json. But axios was still in node_modules (npm listed it as extraneous) until we ran npm install again.
  • It removed the export keyword from formatPriceV2 and TAX_RATE and left the code in place. Knip stopped flagging them, but tsc --noEmit --noUnusedLocals then reported both as declared but never read.
  • It did not delete src/utils-old.ts. That needs --fix --allow-remove-files, which did remove it.
  • It did not add dayjs. Knip's docs say auto-fix does not add unlisted dependencies, because it can't know whether they belong in dependencies or devDependencies. TypeScript also failed on the missing module.

All of this matches Knip's own auto-fix docs, which tell you to review changes in Git, use ESLint or Biome for unused variables afterward, and reinstall dependencies.

Our verdict. Worth adding to any repo where an agent writes code. It is fast, local and catches the cleanup an agent skips. Treat the report as a to-do list, not --fix as the cleanup.

The tip.

  1. Run npx knip and read the report.
  2. Run npx knip --fix, then add --allow-remove-files only after you've checked the file list.
  3. Run your linter or tsc --noUnusedLocals to catch code the export removal left behind.
  4. Install any unlisted dependency yourself, run npm install, and review the diff.

Limits of our test. This was one small repo with leftovers we planted, not a large codebase or a real agent session. Big monorepos and framework projects usually need a Knip config or plugins to avoid false positives. We did not test those.

Disclosure: Tested by MODEL on Nov 8, 2026. Not sponsored. No affiliate links.

MODEL Editors

Sources

  1. Auto-fix

    Knip docs

  2. Knip

    Knip

  3. webpro-nl/knip

    GitHub

  4. knip 6.44.2

    npm

FREE · EVERY WEEK

The top AI tools this week, tested.

Every week MODEL's editors pick the AI tools worth your time, try them hands-on, and tell you what's good, what's not, and who it's for. Free, in your inbox.

Free. Unsubscribe anytime. Our picks are editorial and can't be bought.