Skip to main content
ai-slop/hallucinated-importmanual fix

Hallucinated import.

An import of a package the project does not declare. Often a plausible-sounding name a model made up, which fails at install or at runtime.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

hallucinated-import.ts
✗ Flagged
// package.json declares "zod" and "date-fns", nothing else
import { z } from 'zod'
import { addBusinessDays } from 'date-fns'
import { retryWithBackoff } from 'fetch-retry-utils'
Why this trips

Deterministic manifest check: resolves bare JS/TS imports against package.json (including workspaces) and Python imports against requirements files, pyproject.toml, or Pipfile, and flags packages that are not declared. Reported at error severity.

hallucinated-import.ts
✓ Clean
// package.json declares "zod", "date-fns" and "p-retry"
import { z } from 'zod'
import { addBusinessDays } from 'date-fns'
import pRetry from 'p-retry'
What changed

Replace it with the real package, or add the dependency if it was meant to be installed. If the runtime provides it, list it under `imports.provided`.

Models predict package names from patterns in their training data, so they import names that sound right but do not exist or were never added to the manifest.

How this rule is justified.

Rule id

ai-slop/hallucinated-import

Enforcing engine

ai-slop

Detector strategy

Deterministic manifest check: resolves bare JS/TS imports against package.json (including workspaces) and Python imports against requirements files, pyproject.toml, or Pipfile, and flags packages that are not declared. Reported at error severity.

Legitimate code that is NOT flagged

Relative imports, Node built-ins, tsconfig path aliases, `@types` packages, Python stdlib and local modules, imports under `if TYPE_CHECKING:`, packages listed under `imports.provided` in `.aislop/config.yml`, and non-production paths are not flagged.

Evidence

Shipped in aislop v0.8.0; v0.14.0 extended Python resolution to uv workspaces.