Plain Reckoner
English
← The blog

Hallucinations

AI Invented That Package. Check Before You Install.

Check invented packages, mismatched APIs, unsupported citations, and installation fixes before they spread.

By Plain Reckoner Team · Release date: 2026-10-29

Selected source checked:

How do you check an AI-suggested dependency? Verify the package name and publisher in the official registry, then check the version and API in the project documentation before installing.

A generated code sample imports a package with a sensible name, calls a method that sounds right, and includes a confident explanation. You copy the command and the install fails. Or the package exists, but it has nothing to do with the feature. Or the method belonged to another version. These are different failures, but they share a common workflow mistake: treating a plausible generated reference as a verified dependency.

This guide offers a practical way to check those references before they spread through a project. It covers package names, API methods, documentation links, and assumptions about installed versions. The examples are hypothetical and the recommendations are editorial guidance. The goal is to make uncertainty visible and reduce avoidable mistakes, not to promise that a model can be prompted into perfect factual accuracy. A reliable workflow needs evidence outside the model's own explanation.

In this guide
  1. Understand the boundary of the research
  2. Read the project before adding a package
  3. Verify identity, not only existence
  4. Match documentation to the installed version
  5. Separate syntax confidence from behavioral confidence
  6. Ask the model to expose uncertainty usefully
  7. Keep citations close to the claim
  8. Use a minimal experiment before a broad rewrite
  9. Do not let installation failures trigger random repairs
  10. Protect the distinction between examples and production code
  11. Make the corrected knowledge durable
  12. A checklist you can use in a real review

Understand the boundary of the research

The paper “We Have a Package for You!” studies package hallucinations in generated code across a defined set of models and programming tasks. It documents nonexistent package recommendations and evaluates mitigation strategies. The paper's latest listed revision is from March 2025. Its results establish a researched failure category, but they are not measurements of every model available in November 2026. Do not reuse its percentages as if they described your current assistant.

That distinction matters because a useful article should neither dismiss improvement nor imply that improvement eliminates the need to check. Your immediate task is narrower than ranking all models. You need to establish whether the specific package, version, and method proposed for your project are real and appropriate. That can often be checked directly against the installed environment and the original publisher's documentation.

A generated answer can still be a productive starting point. Treat unfamiliar references as candidates. The assistant may point you toward a useful concept even when the exact import is wrong. Preserve that conceptual value while verifying the concrete implementation separately.

Read the project before adding a package

Start with the dependency manifest and lockfile. The project may already contain a library that solves the problem. It may use a specific major version, a workspace wrapper, or an internal abstraction that generated examples do not know about. Adding a second library before reading those files can increase complexity without improving the feature.

Ask the assistant to identify the existing path for the behavior. If the application already has an HTTP client, validation layer, or date utility, inspect how it is used. A new dependency should have a clear reason. That reason might be a genuinely missing capability or a documented limitation of the existing tool. “The model suggested it” is not enough to justify an architectural change.

Keep the scope proportionate. A small formatting requirement does not always need a large package. On the other hand, replacing a mature parser with improvised code may introduce its own problems. The decision should depend on requirements, maintenance cost, and verified capabilities. It should not be driven solely by the shortest generated snippet or the most familiar name in the model's training data.

Verify identity, not only existence

Finding a name in a package registry is only the first check. Confirm that the package is the one described by the original project. Follow the publisher's official installation instructions and compare the repository, ownership, and documentation links. A familiar-looking name can refer to an unrelated project, and a package's existence does not establish that it implements the expected API.

Do not automatically install the nearest spelling when the proposed name fails. A failed lookup is a reason to investigate the reference, not an invitation to guess. Search from the official project's website or repository toward the package, rather than treating registry search results as interchangeable solutions. Record the verified package identifier so the next generated step does not revert to the invented one.

For internal packages, use the organization's approved registry and documentation. An assistant may not have access to those sources. In that case, it should say what it cannot verify instead of inventing a public replacement. A temporary interface sketch can still be useful, but label it as a sketch and keep it separate from instructions that someone might execute.

From plausible to checked
01
Package identity
02
Version match
03
API contract
04
Small working example

Match documentation to the installed version

A real method in current documentation may not exist in the version your project uses. Conversely, a familiar method may have changed or been removed in a newer release. Confirm the installed version before adapting an example. Then use documentation or release notes appropriate to that version. Avoid silently upgrading the project just to make a generated snippet compile.

Version mismatches can appear as misleading local errors. A missing export may be a typo, an incompatible version, or an incorrect import path. Inspect the package's actual exports and type definitions where available. These local artifacts often answer a more precise question than a generic web example. The goal is to understand the mismatch before changing several dependencies at once.

If an upgrade is necessary, treat it as a separate decision with its own compatibility checks. Identify affected callers, migration requirements, and the relevant test scope. Do not hide a major upgrade inside a small feature patch. Keeping the change explicit makes it easier to review and gives you a clearer rollback path if the new behavior differs from expectations.

Separate syntax confidence from behavioral confidence

A type checker can confirm that an import and call shape are acceptable while saying nothing about whether the call does what you intend. A method can exist and still use different units, return a lazy object, require initialization, or behave differently on an empty input. Verification needs to include meaning, not just spelling.

Read the contract around the method. Look for parameter units, default values, error conditions, and return types. Build a minimal example with an outcome you can inspect independently. If a time library accepts a number, confirm whether that number represents seconds or milliseconds. If a data client returns pages, confirm whether you received all records or only the first page. These are concrete questions that generated prose can gloss over.

Avoid treating a successful command as evidence of the entire workflow. An import check verifies that the module loads. A small execution verifies one path. An integration check may verify interaction with the surrounding application. Each adds useful evidence, but none should silently stand in for the others. State the level actually tested when reporting completion.

Source checked November 15, 2026: the package-hallucination study evaluates generated package names across specified models and datasets. Its results do not measure every current model. Package hallucination study ↗

Check the exact version before installing

Replace PACKAGE and VERSION with the identifier and version from the project’s official instructions. The first command queries registry metadata; the second lists the installed package in the current project. Neither command installs it. Compare the repository URL and runtime requirements with your project.

npm view PACKAGE@VERSION version repository.url engines --json
npm ls PACKAGE --depth=0

Then review provenance

Where a package supplies provenance, inspect the source commit and build workflow linked on its npm page. In an installed project, npm audit signatures checks supported registry signatures and provenance attestations. It needs an appropriate npm version and installed dependencies. A successful check links a published artifact to its origin; it does not establish that the code is safe.

Read npm’s provenance instructions ↗

Ask the model to expose uncertainty usefully

A prompt such as “do not hallucinate” expresses a preference but does not supply missing knowledge. Ask for a verifiable process instead. Request the source for unfamiliar APIs, the installed version assumed by the answer, and a clear distinction between verified references and proposed pseudocode. This gives you specific items to inspect rather than another statement of confidence.

For example: “Use dependencies already present in this repository where possible. Before introducing an unfamiliar package or API, verify its identity and version against the original publisher. If you cannot verify it, describe the required capability without inventing an import. Keep unexecuted examples labeled as proposals.” The wording does not guarantee compliance, but it defines a useful standard for reviewing the response.

Do not demand certainty where the available evidence is incomplete. An assistant that says a reference is unverified is giving you actionable information. You can provide the missing documentation, choose another approach, or defer the integration. Forcing a definitive answer can encourage a polished guess and makes it harder to see which part of the proposal requires investigation.

Keep citations close to the claim

A documentation link should support the specific statement beside it. Linking a library's homepage does not necessarily verify a particular method, configuration flag, or compatibility promise. Prefer a deep link to the relevant API documentation or release note. Check that the page actually contains the claimed behavior and belongs to the original publisher.

An assistant may provide a real URL whose contents do not support its explanation. Open the source and compare the claim. If the page describes a different version or a related feature, narrow the claim or find the correct reference. Do not treat the presence of a citation as an automatic quality signal. The relationship between the claim and the source is what matters.

For project documentation, record enough context that the reference remains useful later. Include the version and the reason the dependency was chosen. Avoid copying large sections of external documentation into the repository when a concise explanation and link will do. The objective is a maintainable decision record, not a second documentation site that can become stale independently.

Use a minimal experiment before a broad rewrite

Once the reference is verified, test the uncertain behavior in the smallest practical setting. A tiny script, a focused test, or an isolated component can reveal a mismatch before it spreads through the codebase. Choose an example that challenges the assumption, not only one that demonstrates the advertised happy path.

Suppose a generated integration assumes that a search API returns every match. Test pagination with a controlled dataset or inspect the documented response contract. Suppose it assumes that a parser rejects malformed input. Try a safe malformed example and observe the actual error. Suppose it assumes that a save operation is synchronous. Verify when the result becomes durable. These checks are more informative than asking the model to repeat its explanation.

Record the outcome and remove disposable experiments when they are no longer needed, preserving any meaningful regression coverage appropriate to the project. An experiment that fails is still progress if it eliminates a wrong assumption. Do not bury that result by rewriting the sample repeatedly until something happens to work without understanding which change mattered.

Do not let installation failures trigger random repairs

A missing package or failed install can send an agent into a long loop of speculative changes. It may alter lockfiles, switch package managers, remove constraints, or try unrelated versions. Stop the loop by classifying the error first. Was the package name wrong? Was access denied? Was the network unavailable? Was the version incompatible? These are distinct causes with different fixes.

Preserve the original error and inspect the environment. If authentication is required, use the approved secret mechanism rather than placing credentials in source or logs. If a registry is temporarily unavailable, changing the application code is unlikely to help. If the dependency graph conflicts, identify the incompatible requirement instead of deleting the lockfile as a first response.

A bounded recovery process is easier to review. State the hypothesis, make one relevant change, and run the smallest check that can confirm or reject it. If the result contradicts the hypothesis, update the explanation. The assistant should not describe each speculative attempt as the final fix. The final report should reflect the cause supported by the evidence.

Protect the distinction between examples and production code

Documentation samples often omit application-specific concerns. They may demonstrate a single call without covering authentication renewal, retries, cancellation, input validation, or error presentation. A generated adaptation can inherit those omissions. Before adopting the sample, identify which surrounding behaviors your application requires and which the sample deliberately leaves out.

Keep placeholders unmistakable. A fake hostname, example identifier, or illustrative response should not look like a verified production value. If the assistant creates a mock adapter while waiting for real documentation, name and describe it as a mock. Do not connect it to a user-facing success message that implies a live action occurred. The boundary should be visible in both code and reporting.

This matters beyond programming. A research assistant can invent a report title, a spreadsheet assistant can assume a column exists, and a writing assistant can cite a source it never opened. The same discipline applies: identify the external reference, verify it, and keep assumptions separate from observations. A plausible artifact is not the same as a checked one.

Make the corrected knowledge durable

After resolving a hallucinated or mismatched reference, update the local guidance that caused repeated confusion. A short note can identify the approved dependency, the supported version, and the preferred internal wrapper. Include a minimal example only when it is maintained with the code. Otherwise, point to the authoritative implementation or documentation.

Avoid accumulating a long blacklist of every mistake an assistant has ever made. Such lists can become difficult to follow and may preserve obsolete constraints. Focus on the current contract: which tools are available, where to find their definitions, and how to verify an unfamiliar capability. A small accurate guide is more useful than a large collection of historical warnings.

When the project upgrades, revisit the note. Durable context is only helpful while it remains correct. Mark superseded instructions clearly and remove contradictory examples from active guidance. This prevents the next agent from confidently following yesterday's fix into today's failure. The maintenance task belongs to the workflow, not to the model's memory alone.

A checklist you can use in a real review

Before accepting a new generated dependency, confirm the exact package identity, the installed or proposed version, and the original publisher's documentation. Inspect whether an existing project dependency already covers the requirement. Verify the specific API, not just the package name. Then run a small meaningful example and the relevant project checks. Record any unverified integration boundary explicitly.

Review the diff for changes outside the intended scope. Look for unexplained lockfile churn, configuration changes, placeholder values, or a new mock that bypasses the real integration. Ask why each is necessary. A working local example does not justify unrelated changes, and a large diff can hide the simple mismatch that started the problem.

The end state should be easy to explain: the reference is verified, the behavior is understood, the integration has appropriate evidence, and remaining limitations are visible. That is a stronger outcome than merely getting past an import error. It also gives the next person a clear path to maintain the feature without repeating the same search or trusting the same unsupported guess.