DEV Community

Cover image for Step 3: A dead-code finder in the loop
Remy Loubradou
Remy Loubradou

Posted on Originally published at lesecretairedefernand.co

Step 3: A dead-code finder in the loop

I don't read the code my agents write. Step 3 of what makes that hold:

An agent rewrites a function and leaves the old one behind: nobody calls it, nothing flags it, and the next session may build on it. Put a dead-code finder in the agent's loop, as an error, and it deletes its leftovers before you ever see them. In TypeScript, knip.

In Birgitta Böckeler's grid of guides and sensors, knip is a computational sensor: it looks at the whole project after the agent acts, and answers the same every time. The series' map: https://lesecretairedefernand.co/en/tech/mapping-your-attention-to-free-it/

Why a tool of its own: the linter sees an unused variable inside a file. knip sees what no single file can: an export nobody imports, a file nobody reaches, a dependency nobody uses.

Make it fail the check, not warn. A warning is one more thing for you to notice; an error is the agent's to fix before the commit.

If you want an example, here is my knip config: https://github.com/lbdremy/phax/blob/7ecfaa56b64fa9b1f472c3b96361277d9e0c09fa/knip.json

One step a day of the harness I put around my agents, in the order I added them.

Top comments (0)