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.

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.

Common errors

Module not found: Can't resolve
The bundler followed an import to a file or package that doesn’t exist under that name, so it couldn’t build the page.
Cannot find module
Node tried to load a package or file that isn’t where the code says it is, usually because it was never installed or the path is wrong.
X is not a function
The code called something that isn’t a function, most often .map on API data that came back as an object or a string instead of an array.
All terms

AI 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.