Hallucination
Also called AI hallucination or confabulation
When an AI model states something false with confidence, such as code that calls a function, package, or option that does not exist.
Before using any library function, check that it exists in the version installed in package.json and tell me where you confirmed it. If a package is not installed yet, confirm it is published on npm and widely used before adding it.
Paste into Layerwise or any AI coding tool.
What is Hallucination?
Models predict likely text, so they can produce answers that sound right and are wrong. In code, a hallucination is often a method borrowed from another language or library, like posts.last() on a JavaScript array, an import from a package that was never published, or a setting from an older version.
Many coding hallucinations fail loudly: the build breaks, the app crashes, or a test fails. An agent that runs the code and reads the error can often fix the mistake on its own. Quieter ones, like a wrong calculation or an invented fact in your copy, need a human check.
Point the AI at the real documentation or the installed version, ask it to confirm a package exists before installing it, and test the paths that matter. Be wary of unfamiliar package names: attackers publish packages under names that AI models tend to invent.
Related terms
All termsAI agent
An AI model that works toward a goal on its own by planning, using tools, checking the results, and repeating until the task is done.
Tool call
A request from an AI model to run a named action, such as reading a file, searching, or running a command, whose result goes back to the model.
Rules file
A file in your project, such as AGENTS.md or CLAUDE.md, with standing instructions that an AI coding agent reads at the start of every task.
Diff
A view of what changed in a file, with removed lines marked in red with a minus sign and added lines in green with a plus sign.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.