Logo: Hallucination Guard

Hallucination Guard

Organisatioun
Rune-kit
hallucination-guard

Verify AI-generated imports, API calls, and packages actually exist. Use when finishing AI-generated code that introduces new imports or external API calls — auto-fires after fix/cook to catch phantom functions, non-existent packages, and slopsquatting attacks.

Iwwersiicht

EditeurRune-kit
Repositoryrune
Skill-Nummhallucination-guard
Stären
88
Forks
26
Matgeliwwert Dateien
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Rune-kit huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Hallucination Guard an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/Rune-kit/rune/tree/master/skills/hallucination-guard
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Rune-kit/rune.git /tmp/rune
mkdir -p .claude/skills
cp -r /tmp/rune/skills/hallucination-guard .claude/skills/hallucination-guard
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Hallucination Guard an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Hallucination Guard automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Hallucination Guard net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

hallucination-guard

Purpose

Post-generation validation that verifies AI-generated code references actually exist. Catches the 42% of AI code that contains hallucinated imports, non-existent packages, phantom functions, and incorrect API signatures. Also defends against "slopsquatting" — where attackers register package names that AI commonly hallucinates.

Triggers

  • Called by cook after code generation, before commit
  • Called by fix after applying fixes
  • Called by preflight as import verification sub-check
  • Called by review during code review
  • Auto-trigger: when new import statements are added to codebase

Calls (outbound)

Exception: L3→L3 coordination

  • research (L3): verify package existence on npm/pypi

Called By (inbound)

  • cook (L1): after code generation, before commit
  • fix (L2): after applying fixes
  • preflight (L2): import verification sub-check
  • review (L2): during code review
  • db (L2): verify SQL syntax and ORM method calls are real
  • review-intake (L2): verify imports in code submitted for review
  • skill-forge (L2): verify imports in newly generated skill code
  • adversary (L2): verify APIs/packages in plan actually exist
  • logic-guardian (L2): verify referenced functions and imports after guarded logic edits

Execution

Step 1 — Extract imports

Use Grep to find all import/require/use statements in changed files:

Grep pattern: ^(import|require|use|from)\s
Files: changed files passed as input
Output mode: content

Collect every imported module name and file path. Separate into:

  • Internal imports (start with ./, ../, @/, ~/)
  • External packages (bare module names)

Step 2 — Verify internal imports

For each internal import path, use Glob to confirm the file exists in the codebase.

Glob pattern: <resolved import path>.*   (try .ts, .tsx, .js, .jsx, .py, .rs etc.)

If Glob returns no results → mark as BLOCK (file does not exist).

Also use Grep to verify that the specific exported name (function/class/const) exists in the resolved file:

Grep pattern: export (function|class|const|default) <name>
File: resolved file path

If export not found → mark as WARN (symbol may not be exported).

Step 3 — Verify external packages (Dependency Check Before Import)

Before importing ANY third-party library, check the dependency manifest.

Use Read on the project's dependency manifest to confirm each external package is listed:

  • JavaScript/TypeScript: package.json → check dependencies and devDependencies
  • Python: requirements.txt or pyproject.toml → [project.dependencies] and [project.optional-dependencies]
  • Rust: Cargo.toml → [dependencies] and [dev-dependencies]

Pre-import gate (BEFORE writing import statements, not just after):

  1. If the agent is ABOUT to import a package → check manifest FIRST
  2. If package is NOT in manifest → output install command before writing the import:
    ⚠ Package '<name>' not in dependencies. Install first:
      npm install <name>        # JS/TS
      pip install <name>        # Python
      cargo add <name>          # Rust
  3. If package IS in manifest → proceed with import

Post-import verification (after code is written):

  • If package is not listed in the manifest → mark as BLOCK (phantom dependency)
  • If package is listed but not installed (no lockfile entry) → mark as WARN (not yet installed)

Also check for typosquatting: if package name has edit distance ≤ 2 from a known popular package (axios/axois, lodash/lodahs, react/recat), mark as SUSPICIOUS.

Step 3.5 — Slopsquatting Registry Verification

For each NEW external package (present in manifest but absent from lockfile):

3.5a. Registry existence check:

JavaScript: Bash: npm view <package-name> version 2>/dev/null
Python:     Bash: pip index versions <package-name> 2>/dev/null
Rust:       Bash: cargo search <package-name> --limit 1 2>/dev/null

If command returns empty/error → BLOCK (package does not exist on registry — likely hallucinated name).

3.5b. Popularity check (slopsquatting defense):

JavaScript: Bash: npm view <package-name> 'dist-tags.latest' 'time.modified' 2>/dev/null
→ If last modified > 2 years ago AND weekly downloads < 100: SUSPICIOUS
Python:     Use rune:research to check PyPI page for download stats

Low-popularity packages with names similar to popular ones = SUSPICIOUS (potential slopsquatting attack).

3.5c. Known slopsquatting patterns:

Popular Package → Common AI Hallucination
axios           → axois, axio, axioss
lodash          → lodahs, loadash, lo-dash
express         → expresss, express-js
react-router    → react-routes, react-routing
python-dotenv   → dotenv (wrong package in Python context)

Flag any match with edit distance ≤ 2 from these known pairs.

Step 4 — Verify API calls

For any API endpoint or SDK method call found in the diff, use rune:docs-seeker (Context7) to confirm:

  • The method/function exists in the library's documented API
  • The parameter signature matches usage in code

Mark unverifiable API calls as WARN (cannot confirm without docs).

Step 5 — Report

Emit the report in the Output Format below. If any BLOCK items exist, return status BLOCK to the calling skill to halt commit/deploy.

Check Types

INTERNAL    — file exists, function/class exists, signature matches
EXTERNAL    — package exists on registry, version is valid
API         — endpoint pattern valid, method correct
TYPE        — assertion matches actual type
SUSPICIOUS  — package name similar to popular package (slopsquatting)

Output Format

## Hallucination Guard Report
- **Status**: PASS | WARN | BLOCK
- **References Checked**: [count]
- **Verified**: [count] | **Unverified**: [count] | **Suspicious**: [count]

### BLOCK (hallucination detected)
- `import { formatDate } from 'date-utils'` — Package 'date-utils' not found on npm. Did you mean 'date-fns'?
- `import { useAuth } from '@/hooks/useAuth'` — File '@/hooks/useAuth' does not exist

### WARN (verify manually)
- `import { newFunction } from 'popular-lib'` — Function 'newFunction' not found in popular-lib@3.2.0 exports

### SUSPICIOUS (potential slopsquatting)
- `import axios from 'axois'` — Typo? Similar to popular package 'axios'

### Verified
- 12/15 references verified successfully

Constraints

  1. MUST verify every import against actual installed packages — not just check if name looks reasonable
  2. MUST verify API signatures against docs — not assume from function name
  3. MUST report BLOCK verdict with specific evidence — never "looks suspicious"
  4. MUST NOT say "no hallucinations found" without listing what was checked

Sharp Edges

Known failure modes for this skill. Check these before declaring done.

Failure ModeSeverityMitigation
Declaring "no hallucinations found" without listing what was checkedCRITICALConstraint 4 blocks this — always list verified count vs total
Marking phantom package (not in manifest) as WARN instead of BLOCKHIGHUnlisted package in manifest = BLOCK — not installed = won't run
Missing typosquatting check on external packagesMEDIUMEdit distance ≤2 check is mandatory — check every external package name
Only checking package name, not the specific exported symbolMEDIUMStep 2: verify the specific function/class is exported, not just the file exists
Skipping registry verification for new packagesCRITICALStep 3.5 HARD-GATE: new packages MUST be verified against actual registry
AI-hallucinated package name passes because it "sounds right"HIGHSlopsquatting defense: check registry existence, not name plausibility
Low-popularity package with similar name to popular one not flaggedHIGHPopularity check catches slopsquatting attacks on newly registered packages

Done When

  • All imports extracted from changed files (internal + external separated)
  • Internal imports: file existence AND symbol export verified
  • External packages: manifest presence checked for every package
  • Suspicious package names flagged (edit distance ≤2 from popular packages)
  • API signatures checked via docs-seeker for new SDK/library calls
  • Hallucination Guard Report emitted with PASS/WARN/BLOCK and verified count

Cost Profile

~500-1500 tokens input, ~200-500 tokens output. Haiku for speed — this runs frequently as a sub-check.

Heefeg gestallte Froen

Wat mécht de KI-Skill Hallucination Guard?

Verify AI-generated imports, API calls, and packages actually exist. Use when finishing AI-generated code that introduces new imports or external API calls — auto-fires after fix/cook to catch phantom functions, non-existent packages, and slopsquatting attacks.

Firwat Hallucination Guard op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Hallucination Guard besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Hallucination Guard an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/Rune-kit/rune/tree/master/skills/hallucination-guard an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Hallucination Guard benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Hallucination Guard benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Hallucination Guard domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Hallucination Guard gratis?

Jo. Rune-kit huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇