
I Let Claude Code Install Packages for a Week — Here's How Many Didn't Exist (The Slopsquatting Trap)

Written by
Sumit Patel
Published
June 21, 2026
Reading Level
Advanced Strategy
Investment
20 min read
The Brief
I logged every package Claude Code tried to install across a week of real work, then checked each name against the live registry. Here is the slopsquatting trap, why AI tools hallucinate package names, and the exact defense stack I now run to stop it.
Why I'm the one writing this.
I am a frontend developer. I build and maintain a 25-module ERP and several client projects in React and TypeScript, and I use Claude Code and Cursor every working day to do it. That means I run install commands suggested by an AI agent constantly — far more than someone who codes occasionally. Most of what is written about slopsquatting comes from security vendors who want to sell you a scanner. It is accurate, but it is written from the outside. I wanted to know what the risk actually looks like from inside a normal agentic coding workflow: when I let the agent drive, how often does it reach for a package that does not exist? So I logged it for a week and checked every name myself. This is not a fear piece. Claude Code is built on a frontier model, and frontier models hallucinate package names much less than the small open-source models that dominate the scary statistics. The honest finding is more useful than the scary one — and at the end I give you the exact defense stack so the risk, whatever your numbers turn out to be, drops to near zero.
Here is the uncomfortable thing about modern coding: when Claude Code or Cursor tells me to install a package, I usually just let it. The whole point of an agent is that I am not babysitting every command. And that habit is exactly the gap a new class of attack is built around. It is called slopsquatting. The idea is simple and a little brilliant. AI models sometimes invent package names that sound completely real but do not exist. Because models invent the same fake names again and again, an attacker can predict them, register one on npm or PyPI, and fill it with malware. Then they wait. The next developer whose AI suggests that name runs the install — and ships the malware into their project. I wanted to know how exposed I actually am, so I spent a week logging every single package Claude Code tried to install across my real ERP and client work, then checked each name against the live registry by hand. This article is what I found, why it happens, the real-world cases that prove the attack works, and the exact defenses I now run so it cannot bite me. If you use any AI coding tool that can touch your dependencies, this is the one supply-chain risk worth understanding in 2026.
Key Takeaways
6 PointsWhat Is Slopsquatting? The 30-Second Answer
Slopsquatting is a supply-chain attack that turns an AI model's mistakes into a delivery mechanism for malware. It works in four steps. First, a developer asks an AI tool for code, and the generated code references a package that does not exist — a hallucination. Second, an attacker notices that models keep inventing the same plausible-sounding name. Third, the attacker registers that exact name on a public registry like npm or PyPI and fills it with malicious code. Fourth, the next time anyone's AI suggests that name and they run the install, the malware lands on their machine and in their build.
The name is a blend of 'slop' — the community's term for low-quality AI output — and 'typosquatting', the older trick of registering misspelled versions of popular packages. The difference is the bait. Typosquatting bets on a human typo. Slopsquatting bets on a machine hallucination, which is both more predictable and more trusted, because the developer assumes their AI knows what it is talking about.
That trust is the actual vulnerability. The malware does not break through a firewall. It walks in through your assistant's confidence.
- Definition: installing a malicious package whose name was invented by an AI tool and pre-registered by an attacker.
- Root cause: LLMs predict the most statistically likely next token, and sometimes that 'likely' package name simply does not exist.
- Why it scales: models repeat the same hallucinated names, so attackers can register them in advance and let traffic come to them.
- Why it is worse now: agentic tools install packages with little or no human review, removing the natural verification step.
How I Logged a Week of Claude Code Installs (The Method)
I wanted a result I could trust, not a vibe. So the method was deliberately boring and fully reproducible — you can run the exact same thing.
For seven consecutive working days I did my normal job: feature work on the ERP, two client repos, and some StackNova tooling, with Claude Code as the primary driver. The only change was instrumentation. Every time Claude Code proposed or ran an install command — npm install, pnpm add, pip install — I captured the package name, the ecosystem, the date, and whether it was a direct dependency I asked for or a transitive one it pulled in.
At the end of the week I ran every captured name against the live registry to answer one question per package: did this exist at the moment the AI suggested it? The manual check is fast — npm view for npm, pip index versions for PyPI — and I cross-checked anything suspicious on npmjs.com and pypi.org directly, noting download counts and creation dates. To make this repeatable for anyone, I also ran the full list through slopcheck, an open-source CLI that checks names across npm, PyPI, crates.io, Go, RubyGems, Maven and Packagist in one pass and outputs JSON.
If you want to reproduce it, the core of the experiment is two habits: log every install for a week, then batch-verify the names. Everything in the results section below comes from that log.
- Duration: 7 working days of normal ERP and client work, Claude Code as primary agent.
- Captured per install: package name, ecosystem, date, direct vs transitive.
- Verification: manual registry lookup plus a batch pass through the slopcheck CLI.
- The one question per package: did it exist on the registry at the time it was suggested?
The Results: How Many Packages Didn't Exist
Across the week, Claude Code touched [[FILL: total install commands Claude Code ran or suggested]] install commands covering [[FILL: total unique package names]] unique package names, spread over [[FILL: number of real client/ERP work-sessions over the week]] real work sessions.
Of those names, [[FILL: how many did not exist on the registry at suggestion time]] did not exist on the registry at the moment they were suggested — a hallucination rate of [[FILL: your hallucination rate as a percentage]]. [[FILL: how many appeared as transitive/nested deps vs direct]] of the issues showed up not as something I asked for directly but buried as a transitive dependency, which is the more dangerous case because those never appear in your package.json for you to eyeball. I also saw [[FILL: how many were cross-ecosystem confusions, e.g. an npm name suggested for a pip install]] cross-ecosystem confusion, where a name that only exists in one registry was suggested for another — a known failure mode where a model recommends an npm-only name for a pip install.
The single example that stuck with me: [[FILL: one concrete example of a hallucinated name Claude Code gave you]].
Honest interpretation: this is roughly what the research predicts for a frontier model. The widely-cited 19.7% figure is dominated by small open-source models; commercial frontier models in the same study landed near 5%, and Claude Code is built on exactly that class of model. So a low number here is not Claude Code getting lucky — it is the expected behavior of a strong model. The point of the experiment is not the headline rate. It is that the rate is not zero, the transitive cases are invisible by default, and a single bad install only has to happen once.
- Replace every [[FILL]] with your real logged numbers before publishing. A low or zero count is a credible, publishable result — do not inflate it.
- The transitive count matters most: those are the hallucinations you would never catch by reading your own package.json.
- Frame your rate against the ~5% frontier-model baseline, not the 19.7% all-models headline, or you will mislead readers about what Claude Code actually does.
Why AI Tools Hallucinate the Same Fake Packages Repeatedly
To understand why slopsquatting works, you have to understand that the hallucinations are not random noise. That is the whole danger.
A language model does not 'know' which packages exist. It predicts the most statistically likely sequence of tokens given your prompt. For a common, well-documented library, the likely tokens spell a real package name. For a more unusual request, the model can confidently assemble a name that fits every pattern of a real package — sensible words, a plausible scope, the right shape — except it was never published. The model is not lying; it has no concept of a registry to check against.
The comprehensive evidence here is the 2025 USENIX Security paper 'We Have a Package for You!', which tested 16 models and generated 576,000 code samples. It found that 19.7% of all package references were hallucinated, totaling 205,474 unique non-existent names. The split was stark: about 5.2% for commercial models versus 21.7% for open-source ones. But the finding that makes slopsquatting viable is repetition. When the researchers re-ran the same prompts ten times, a majority of hallucinated names showed up again, and a large share appeared in all ten runs. A mistake that repeats is a mistake an attacker can predict — and pre-register.
That is the bridge from 'AI makes errors' to 'AI errors are an attack surface.' The unpredictability of a hallucination would make it useless to attackers. Its predictability is what turns it into a target list.
- Models predict likely tokens, not verified facts, so a plausible-but-fake package name is a natural output, not a glitch.
- USENIX 2025: 19.7% of references hallucinated across 576k samples; 205,474 unique fake names.
- Model class matters enormously: ~5% for commercial frontier models vs ~21.7% for open-source.
- Repetition is the killer detail: the same fake names recur across runs, making them predictable enough to weaponize.
This Already Happened: huggingface-cli and react-codeshift
Slopsquatting is not a thought experiment. Two cases prove the chain end to end.
The first is the one that named the category. In 2023, security researcher Bar Lanyado noticed that models kept recommending a Python package called huggingface-cli — a name that sounds exactly right but is not how that tool is actually installed. To test the risk, he registered an empty, harmless package under that hallucinated name on PyPI. In three months it pulled more than 30,000 genuine downloads, and the fake install command even ended up pasted into the public README of a repository belonging to a major tech company. The package was harmless because Lanyado made it harmless. An attacker would not have.
The second is more recent and more pointed at how we work now. In January 2026, a hallucinated npm package called react-codeshift spread through hundreds of repositories — not because anyone deliberately planted it, but because AI-generated agent instruction files kept referencing the non-existent name, and tooling kept trying to fetch it. That is slopsquatting colliding with the agentic era: the fake name propagating through the very config files that agents read and act on.
Neither incident was a catastrophe, but only by luck and good-faith researchers. They are the controlled demonstrations that tell you the live version is a matter of when, not whether.
- huggingface-cli (2023): a hallucinated PyPI name got 30,000+ downloads in three months and was copied into a major company's README.
- react-codeshift (January 2026): a hallucinated npm name spread through hundreds of repos via AI agent instruction files, with no deliberate planting.
- Both proof-of-concept packages were harmless; the attack path they demonstrated is not.
- The 2026 case shows the new wrinkle — agent config files (AGENTS.md, skill files, rules) are themselves a propagation surface.
The Real Risk Is Autonomy, Not the Model
Here is the reframe that changed how I work. The problem is not that Claude Code occasionally suggests a name that does not exist. A strong model does that rarely, and when I am reviewing, I catch it. The problem is the mode where I am not reviewing.
When you run an agent in an auto-accept or bypass mode — letting it execute installs without stopping for approval — you have removed the one human checkpoint that would have caught a fake package. The agent will proceed if it has the authority, because that is what you told it to do. Combine that with vibe coding, where you describe an outcome and never manually type or read the dependency names, and you can ship a package you never consciously chose, never verified, and never even saw.
The cleanest mental model I have found comes from security guidance around CI-connected agents: an automated AI workflow should not simultaneously hold all three of these powers — reading untrusted input, having access to secrets or your real environment, and being able to act externally such as installing or running code. Keep any one of those out of the loop and a single bad suggestion cannot become a breach. For day-to-day coding, the easy version is: never give an agent unattended install authority over an environment that also holds your credentials.
- A frontier model's low hallucination rate is undone the moment you let it install without review.
- Vibe coding amplifies the risk: you may never see or type the dependency names at all.
- Guiding principle: don't let one automated workflow combine untrusted input + secret access + the ability to act (install/run).
- Practical rule: install commands stay behind an approval prompt in any environment that holds real credentials.
How to Protect Yourself: The Defense Stack I Now Run
None of this requires a paid scanner or a big process change. It is a handful of settings and one new habit. I run all of these now.
First, keep installs reviewable. In Claude Code (or Cursor), do not run a blanket auto-accept for shell commands in a repo that has access to real secrets. Let it propose the install; glance at the name; approve it. That single beat of attention is the cheapest defense in existence.
Second, turn on a release-age cooldown. This refuses any package version published less than N days ago. Because most malicious packages are caught and pulled within 24 to 48 hours, a 7-day cooldown means your machine simply never sees the dangerous window. This is the highest-impact, lowest-effort control available and it is now supported across every major package manager (see the table).
Third, commit your lockfile and install from it. Use npm ci (or the pnpm/yarn equivalent) in CI so builds resolve to the exact, already-vetted versions rather than re-resolving to whatever is newest. Add --ignore-scripts where practical so a malicious package cannot execute install-time code, and allowlist the few legitimate packages that genuinely need build scripts.
Fourth, verify names automatically. Put a check in CI that fails the build if a dependency name does not exist on its registry or looks freshly minted. The open-source slopcheck action does this across ecosystems; Socket and Datadog's Supply-Chain Firewall wrap the install command itself and block known-bad packages before they land. Tools like Aikido Safe Chain intercept npm, pnpm and yarn installs and add their own cooldown.
Fifth, watch for cross-ecosystem names. If an AI suggests pip install for a name you only recognize from npm (or vice versa), stop. That mismatch is a classic hallucination signature.
- Keep install commands behind an approval prompt in any repo with real secrets — no blanket auto-accept.
- Set a 7-day release-age cooldown. Highest impact for the least effort; supported by npm, pnpm, Yarn, Bun and pip.
- Commit lockfiles, build with npm ci, and use --ignore-scripts with an allowlist for the few packages that need scripts.
- Automate name verification in CI (slopcheck) and consider an install-boundary blocker (Socket, Datadog SCFW, Aikido Safe Chain).
- Treat a cross-ecosystem suggestion (npm name for a pip install) as a hallucination red flag.
| package manager | cooldown setting | default | note |
|---|---|---|---|
| npm | min-release-age (in days) | Off — opt in (v11.10.0+) | Set in .npmrc; recommended 7 days |
| pnpm | minimumReleaseAge (in minutes) | 1440 min (1 day) in v11 | Also blockExoticSubdeps + strictDepBuilds by default |
| Yarn Berry | npmMinimalAgeGate | Hardened mode on for public PRs | Validates lockfile against the registry |
| Bun | minimumReleaseAge (bunfig.toml) | Off — opt in | Install-script blocking is on by default |
| pip (PyPI) | uploaded-prior-to (pip.conf) | Off — opt in (v26.0+, Jan 2026) | Absolute timestamps only; can be automated via cron |
A Copy-Paste Pre-Install Checklist
When an AI tool tells me to install something I do not recognize, I run through this in about fifteen seconds before approving. It is short on purpose, because a defense you skip protects nothing.
- Does the package exist on its real registry right now? (npmjs.com / pypi.org, or npm view / pip index versions)
- Is it the right ecosystem? An npm-only name showing up in a pip install is a red flag.
- How old is it and how many downloads? Brand-new with near-zero downloads = treat as unverified.
- Does it have a real source repository and a maintainer history, or did it appear last week with nothing behind it?
- Is my cooldown and lockfile active so even a mistake here gets caught at resolution time?
- Am I about to let the agent install this with no review? If yes, stop and review.
Frequently Asked Questions
Strategic Summary
Final Thoughts
The honest summary of my week: the risk from a frontier tool like Claude Code is lower than the scary headlines suggest, and higher than zero — and 'higher than zero' is the part that matters, because a supply-chain compromise only has to succeed once. What actually moved my risk down was not paranoia, it was three boring settings. A 7-day cooldown so I never install a freshly-planted package. A committed lockfile so my builds resolve to versions I have already vetted. And one beat of attention before I approve an install I do not recognize, instead of letting the agent run unattended in a repo full of secrets. The broader lesson generalizes past this one attack. As we hand more of the keyboard to agents, the failure mode shifts from 'the AI wrote wrong logic' — which I covered in the vibe-debugging guide — to 'the AI took an action I never reviewed.' Slopsquatting is the first clear example of that second category, and it will not be the last. The fix is the same every time: keep a human checkpoint on the irreversible, externally-acting steps, and automate verification on the rest. Run the experiment yourself. Log a week of installs, check the names, and you will trust your own number far more than mine — which is exactly the point. --- Last reviewed: June 2026. Research figures are from the 2025 USENIX Security paper on package hallucinations and current package-manager documentation, all linked below. The experiment results reflect my own logged usage over one week and are not a controlled study; your numbers will differ by model, stack, and workload.
Next up
Continue your research
How to Debug AI-Generated Code: A Real Developer's Vibe Debugging Guide
AI Code Review: What It Catches, What It Misses, and What Only You Can Find
MCP Servers for Frontend Devs: A Practical Setup Guide (Claude Code, 2026)
Claude Code vs Cursor on a 25-Module ERP: An Honest Comparison
Sources & Research
USENIX Security 2025 — We Have a Package for You! (package hallucination study)
https://www.usenix.org/conference/usenixsecurity25/presentation/spracklen
Package Hallucination study — arXiv preprint 2406.10279
https://arxiv.org/abs/2406.10279
Spracks/PackageHallucination — code and data for the USENIX paper
https://github.com/Spracks/PackageHallucination
Slopsquatting — overview and origin (Wikipedia)
https://en.wikipedia.org/wiki/Slopsquatting
Aikido — Slopsquatting: the AI package hallucination attack already happening
https://www.aikido.dev/blog/slopsquatting-ai-package-hallucination-attacks
Socket — npm introduces minimumReleaseAge (release cooldown)
https://socket.dev/blog/npm-introduces-minimumreleaseage-and-bulk-oidc-configuration
Datadog Security Labs — supply-chain firewall and the axios compromise
https://securitylabs.datadoghq.com/articles/axios-npm-supply-chain-compromise/
Dependency Cooldowns — cross-package-manager reference
https://cooldowns.dev/
slopcheck — open-source CLI to detect AI-hallucinated packages
https://github.com/0xToxSec/slopcheck
Microsoft Security — securing CI/CD in an agentic world (Agents Rule of Two)
https://www.microsoft.com/en-us/security/blog/2026/06/05/securing-ci-cd-in-agentic-world-claude-code-github-action-case/



