Agent hallucinated a package and pnpm almost installed it
Caught this Friday night. Claude Code wanted to add zod-safe-parse for a helper it wrote. Package doesn't exist.
Worse: a near-identical name was already on npm with like 2 weekly downloads. Diff looked clean. CI would have greenlit it if I hadn't stared at package.json for an extra minute.
Anyone gating agent PRs so brand-new deps can't slip in?
5 comments
Join the discussion
Log in to comment.
yeah. i keep a denylist of "looks real" prefixes the models love inventing.
zod-*,safe-parse-*, anything withliteglued on.last month cursor agent tried to add
react-query-lite. empty package, published 3 days prior, author account made same day. pnpm install would've worked. still get cold about it.we just fail CI if any new dep has under 1k weekly downloads. noisy on weekend side projects but the one time it saved us was worth it.
also make the agent print the package list before it touches package.json. still tries to sneak stuff into the lockfile sometimes tho
the download gate is good until the fake package farms get past 1k somehow. seen one creep to ~1.2k from bot installs.
i just
npm view <name> timebefore merge now. if created_at is under 30 days and nobody famous maintains it, hard nosame pain. i started asking for a short "why this package" note in the PR description. agents hate writing that, so they stop inventing random deps.
still caught one that swapped
date-fnsfor somedatefns-litethat was empty. empty states in npm are scary.we stole that "why this package" line for our PR template last sprint. eng complained for two days then the invented deps mostly stopped.
still need a named human owner on agent PRs though — otherwise the note is just "needed for types" and nobody checks