ExactGround logo

Stop AI coding agents from installing packages that don't exist

To stop an AI coding agent from installing packages that don't exist, put a check in front of its install commands. ExactGround is a free, open-source hook for Claude Code, Codex, Gemini CLI and Cursor that does exactly that. It checks the npm/pnpm/yarn/bun/npx and pip/uv/poetry install commands it can parse, and new dependencies written into a manifest, against the public npm registry and PyPI before the command runs. It blocks hallucinated package names (the root of slopsquatting), versions that were never published, young look-alikes of popular packages and npm security placeholders.

Threat model: ExactGround stops an agent that hallucinates or mistypes a package name in a normal install command. It is a cooperative guardrail, not a sandbox: an agent deliberately evading it can get around it, so use OS or container sandboxing to contain an agent you do not trust.

Out of scope, on purpose: an agent running as your user that deliberately obfuscates its commands (program names or file paths built at run time, its own scripts, encoded commands) can defeat any hook-based guard, including this one. ExactGround denies the obfuscation patterns it knows but does not chase this class further. For an adversarial agent, use an OS sandbox or container, or a separate OS user. SECURITY.md

Limits, up front: installs hidden in node -e/python -c, $(...) or eval cannot be checked, so they are denied; every tool call is inspected (any tool with a command is treated as a shell, and file paths are checked); if the registry or the checker fails, the hook denies. Hooks are guardrails, not a sandbox.

GitHub (MIT)Hosted MCP API

$ npx -y github:alidaram99/exactground#v0.1.5 check pypi:requests pypi:reqeusts react@99.0.0
OK      pypi:requests
BLOCK   pypi:reqeusts — "reqeusts" does not exist on PyPI; did you mean "requests"? (it is 1 edit away)
BLOCK   react@99.0.0 — version 99.0.0 of "react" was never published (latest is 19.3.0)

Why

A USENIX Security 2025 study (Spracklen et al.) had 16 models write 576,000 code samples. Of the 2.23 million package recommendations in them, 440,445 (19.7%) named packages that do not exist, 205,474 unique names. In a separate test, the authors re-ran 500 prompts that had produced a hallucination 10 times each, and 43% of those hallucinated names came back in all 10 runs (paper). Attackers register those names (slopsquatting). Coding agents run installs without a human reading the name, and a rule in CLAUDE.md is text the model may ignore. A hook runs every time.

Install in your agent

AgentHowHook
Claude Codeclaude plugin marketplace add alidaram99/exactground
claude plugin install exactground@exactground-marketplace
PreToolUse on Bash, Write, Edit, MultiEdit
Codexcodex plugin marketplace add alidaram99/exactground --ref v0.1.5 then trust it in /hooksPreToolUse on Bash and apply_patch
Gemini CLIgemini extensions install https://github.com/alidaram99/exactground --ref v0.1.5BeforeTool
Cursorexactground init cursor --writebeforeShellExecution

Version-exact API checks (MCP)

Status: live on the Apify Store since 2026-10-03. Calls need your Apify API token.

Real packages are also used wrongly: useActionState in a React 18 project, numpy.asfarray after NumPy 2.0 removed it. The hosted ExactGround API reads the published package (npm .d.ts via the TypeScript compiler, Python wheels parsed statically, never executed) and answers per symbol. check_symbols $0.002/symbol · check_packages $0.0005/package · check_diff $0.01/diff.

claude mcp add --transport http exactground https://dropin-apis--exactground-api.apify.actor/mcp \
  --header "Authorization: Bearer $APIFY_TOKEN"

FAQ

How do I stop Claude Code from installing hallucinated npm or PyPI packages?

Install the free ExactGround Claude Code plugin: run claude plugin marketplace add alidaram99/exactground and claude plugin install exactground@exactground-marketplace. Its PreToolUse hook checks every install command and every package.json, requirements.txt or pyproject.toml edit against the npm registry and PyPI, and denies the tool call when a package name does not exist.

What is slopsquatting?

Slopsquatting is registering a package name that AI models hallucinate, so that agents or developers who trust the suggestion install the attacker's code. A USENIX Security 2025 study (Spracklen et al.) had 16 models write 576,000 code samples; of the 2.23 million package recommendations in them, 440,445 (19.7%) named packages that do not exist (205,474 unique names). In a separate rerun of 500 prompts that had produced a hallucination, 10 times each, 43% of those hallucinated names came back in all 10 runs.

Does ExactGround work with Codex, Gemini CLI and Cursor?

Yes. Codex uses a PreToolUse hook on Bash and apply_patch, Gemini CLI a BeforeTool hook, and Cursor a beforeShellExecution hook. Run exactground init <agent> --write in your project.

How do I check that a function exists in the exact version of a package?

Use the hosted ExactGround API, an MCP server at https://dropin-apis--exactground-api.apify.actor/mcp. Its check_symbols tool reads npm type declarations with the TypeScript compiler and Python wheels statically, and answers exists true, false or null for a symbol in a specific version. It costs $0.002 per symbol.

How do I install ExactGround as a Gemini CLI extension?

Run gemini extensions install https://github.com/alidaram99/exactground --ref v0.1.5. The extension adds a BeforeTool hook for run_shell_command, write_file and replace.

Is ExactGround free?

The local guard (CLI and agent hooks) is free and MIT-licensed. Only the hosted version-exact API is paid per check through Apify.

Is an agent hook a security boundary?

No. Hooks are guardrails: vendors document that they can time out or be bypassed, and installs inside inline scripts cannot be parsed (ExactGround denies those). ExactGround's hooks deny when the registry or the checker fails. Keep lockfiles, CI checks and an install-time scanner as well.