Wiring SlopScan into Claude Code — A Skill, a Hook, and a Bug I Almost Shipped An engineer has built SlopScan, an open-source API that detects 'slopsquatting'—malicious packages pre-registered under names hallucinated by LLMs—and integrated it into Claude Code via a skill and a PreToolUse hook. The hook automatically blocks installs of suspicious or nonexistent packages, addressing the ~20% hallucination rate in AI-generated code and the ~43% consistency of hallucinated names across model runs. The integration also surfaced a notable bug in the hook's command parsing logic. SlopScan https://github.com/c0ri/SlopScan is a small open-source API that checks whether an npm/PyPI package name is real before you install it. The problem it solves is specific and increasingly common: LLMs hallucinate package names — studies put it around 20% of AI-generated code referencing packages that don't exist — and attackers have started pre-registering those exact hallucinated names on the real registries with malicious payloads. It's called slopsquatting , and the nasty part is that ~43% of hallucinated names are consistent across runs of the same model, which makes them systematically guessable and worth squatting on. SlopScan itself is straightforward: point it at a package name, it scores trust based on registry age, download counts, GitHub signal, and a few other factors, and hands back SAFE / CAUTION / SUSPICIOUS / DANGEROUS . What this post is actually about is wiring it into Claude Code so it checks automatically , before any install runs — and a genuinely interesting bug I hit building the automatic part. I built this as a skill plus a hook , and they're not redundant — they solve different problems. A skill is documentation Claude reads and can act on. It's great for "here's how to do X when you need to" — but it only fires if the model remembers to reach for it. Ask yourself honestly: would you trust an assistant to always remember to check a package before installing it, across every session, forever, with no exceptions? I wouldn't, and I do this daily. A hook is different in kind: it's a real shell command the Claude Code harness runs deterministically at a named lifecycle event PreToolUse , PostToolUse , etc. , and it can return a decision that actually blocks the action. Not "the model decided to check" — the system runs your script, every time, no exceptions. For anything where "the model forgot, just this once" has a real cost, that distinction is the whole ballgame. So: skill for on-demand manual checks, hook for the safety net that doesn't depend on anyone remembering anything. Nothing fancy — a SKILL.md describing SlopScan's API contract and how to interpret results: --- name: slopscan-check description: "Check an npm or PyPI package name against SlopScan before installing it. Use before npm install/pip install/uv add, or adding any unfamiliar or LLM-suggested dependency." --- SlopScan runs locally or wherever you've deployed it on port 8765. Single package \ \ \ bash curl -s http://localhost:8765/check/npm/