Package Hallucination
What Is Package Hallucination?
Package hallucination is an AI coding error where a tool invents a software package and presents it as a real dependency. For example, it may suggest npm install data-cleaner-pro even though that name is absent from npm, PyPI, or crates.io.
Why AI Coding Tools Invent Package Names
AI models predict likely text from learned patterns. They do not necessarily check a live package registry. Familiar naming styles, old training data, and vague requests can therefore produce convincing but nonexistent dependencies.
Package Hallucination vs. Typosquatting vs. Slopsquatting
These issues can lead to an unsafe install, but their starting points differ.
| Issue | Source of name | Main risk |
|---|---|---|
| Package hallucination | AI invents a name | Broken build or unsafe future install |
| Typosquatting | A misspelling of a real package | Developer installs an attacker-controlled lookalike |
| Slopsquatting | An attacker registers an AI-invented name | Malicious code is installed when AI output is copied |
How to Verify an AI-Suggested Package
Check every new dependency before installing it.
- Search the official registry for the exact name.
- Confirm the publisher, source repository, and documentation.
- Review release activity and reported issues.
- Pin an approved version and commit the lockfile.
- Scan and review the dependency before merging.
Security and Delivery Risks
A missing package is not always harmless. Treat dependency verification as software supply chain hygiene.
- Build failures and lost debugging time.
- Malicious install scripts that access environment credentials.
- Unreviewed transitive dependencies added downstream.
- False confidence when generated code appears complete.
Package Hallucination in AI-Assisted Development
AI-assisted development works best when generated dependencies receive the same review as human-written code. Learn more about AI hallucinations, package hallucination, and an AI package supply chain breach. Build with AI safely by verifying every dependency.
Frequently Asked Questions
Your Questions, Answered
Don't change this element unless you know what you are doing
What is a package hallucination in AI coding?
It is when an AI coding tool recommends a package name that does not exist in the relevant software registry.
Why do AI coding assistants invent software packages?
They predict plausible names from patterns in their training data and prompt context, rather than always checking a live registry.
What is the difference between package hallucination and slopsquatting?
A package hallucination is the AI error. Slopsquatting is an attack in which someone registers the invented name to catch future installs.
How can developers verify an AI-suggested package?
Search the official registry, check the maintainer and source repository, review activity, pin the version, and scan it before use.
Can a nonexistent package name become a security risk?
Yes. An attacker can register the name later, turning copied AI-generated install commands into a potential malicious dependency installation.
on Emergent today


