Import Sentinel
aharwelik/import-sentinel
Bloqueia imports inexistentes e typosquatting antes de rodar código
Ver no GitHubFerramenta de segurança que detecta imports falsas (hallucinations) e typosquatting em código Python e JavaScript/TypeScript antes da execução. Funciona offline como hook pre-commit ou skill Claude Code, verificando imports contra stdlib, manifesto do projeto e módulos locais.
Instalação
npx convez-ai aharwelik/import-sentinel1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
Casos de uso
- Validar código gerado por LLMs
- Prevenir supply chain attacks via typosquatting
- Gate de segurança pre-commit em CI/CD
- Detectar hallucinations de imports em código gerado
Veredito

Solução prática e de zero-dependências que resolve um problema real: LLMs geram imports inexistentes e typosquatting explora isso. Merece atenção de quem usa Claude Code ou mantém projetos com risco supply chain.
README
A tradução para o português deste README ainda está na fila.
import-sentinel
Catch hallucinated and typosquatted imports before they run. Offline, deterministic, Python and JavaScript, as a pre-commit gate or a Claude Code skill.
Keywords: slopsquatting, typosquatting, AI code security, LLM hallucination, dependency confusion, supply chain security, package validation, pre-commit hook, Claude Code, Codex, Python imports, npm, DevSecOps.
The problem
LLMs invent imports. About a third of erroneous LLM-generated code comes from
incorrect API usage, including importing packages that do not exist. Attackers
exploit this with slopsquatting: they register the exact package names models
tend to hallucinate, so a single bad pip install or npm install pulls in
malicious code. Retrieval-augmented approaches help generate better code but do
not, by themselves, verify that a generated package actually exists.
import-sentinel verifies. It resolves every imported name against what genuinely exists in your project and flags anything that does not, with extra scrutiny for names that are one edit away from a popular package.
What it catches
- Typosquats (critical): an import one character off from a popular package
(
requetsforrequests,expresforexpress). - Unresolved imports (high): a name that is not in the standard library, the manifest, or the project. Likely a hallucination.
- Undeclared dependencies (medium): a real, popular package used but not pinned in a manifest. Pinning is a slopsquatting defense.
How it decides
A name is trusted only if it resolves to:
- the standard library (Python's
sys.stdlib_module_namesis the oracle), - a declared dependency (
requirements.txt,pyproject.toml, orpackage.json), or - a local module in the project.
Distribution aliases are handled (import yaml resolves when pyyaml is
declared; bs4/beautifulsoup4, sklearn/scikit-learn, PIL/pillow, and
more). Everything else fails closed.
Install
No dependencies. Python 3.10+.
git clone https://github.com/aharwelik/import-sentinel
cd import-sentinel
Use it
python -m importsentinel scan examples/project
Output:
import-sentinel: scanned 1 file(s), 2 finding(s)
[CRITICAL] python 'requets' (did you mean 'requests'?)
possible typosquat of 'requests' (slopsquatting risk)
[HIGH] python 'totally_made_up_helper'
unresolved import: not in stdlib, manifest, or project (possible hallucination)
The real requests import and the yaml import resolve, so they are not
flagged. Exit code is 1 when any high or critical finding is present.
As a pre-commit gate on the diff:
git diff | python -m importsentinel scan --diff
Emit a proof-carrying-ops receipt for the import change:
python -m importsentinel scan src --receipt | python -m pco verify -
Use it as a Claude Code skill
mkdir -p ~/.claude/skills/import-sentinel
cp skill/SKILL.md ~/.claude/skills/import-sentinel/SKILL.md
Then ask Claude to "check the imports in this file before running it."
Theory
This is the Identity Normalization invariant from proof-carrying-ops applied to dependencies: a package name is an identity that must be normalized and resolved to something real before it is trusted. An unresolved name is treated as no identity and fails closed, which is exactly the property that defeats both hallucinated imports and slopsquatting.
Honesty boundary
The popular-package list and the edit-distance threshold are heuristics; a CRITICAL finding is a strong hint, not proof. The authoritative existence check is your package index. This is the fast offline gate that runs before you get there.
Design
Standard library only, tested on Python 3.10 through 3.13, no-emoji guard in CI.
Author
Anthony Harwelik -- aharwelik@gmail.com -- https://github.com/aharwelik
License
MIT. See LICENSE.