🐈 TheCoreMan/cat-knip

This is a short 🩳; a note that doesn’t merit a full post. See all shorts here.

I published my first npm package! It’s called cat-knip. It detects unused exports in NestJS applications by parsing the dependency graph. To use it:

import {
  expectNoUnusedExports,
  getModuleRefWithSnapshot,
} from 'cat-knip/testing';
import { AppModule } from '../src/app.module';

it('has no unused module exports', async () => {
  await using moduleRef = await getModuleRefWithSnapshot({
    imports: [AppModule],
  });

  expectNoUnusedExports(moduleRef);
});

Should be simple to add - please use it, ⭐ it, open issues, etc.

Where did this come from

While commenting on a PR, I noticed that one of my teammates left an unused export in our NestJS app. We were both surprised that Knip, or NestJS itself, etc. didn’t catch it. So I vibe-coded this library that you can drop into your NestJS tests.

“Vibe coded” in this case meant that I put it on a /goal, then tried to use the library locally (using pnpm pack). Then I gave it feedback as a user until it was nice to use. For example, the original API didn’t include both the await using syntax nor the custom expect.

Only after I was happy with the external behavior, did I read the code itself, and even did some fixes manually. I’m still on “read the code” mode, especially for open source projects. It’s respectful.

Stuff I’ve learned

  • prek seems to work well. Might be my new default instead of pre-commit.
  • How to publish to npm. I now have an NPM profile. With all the supply-chain attacks recently, I’ve set it up with 2FA, hope that’s enough.
  • Using /goal in Codex for a side-tangent. I wouldn’t have done this project without the ability to sic an agent on it, but as expected, actually getting it good took more of my time than I had, so I was almost late to a movie while trying to finalize it.

Why “cat-knip”

NestJS’s logo is a cat, and there’s a unused code detection tool called knip. The #dad-joke was right there, I couldn’t help myself.


Shay Nehmad

nestjsshort

327 Words

2026-07-24 15:10 -0700