rune-kit/rune/hallucination-guard
Claude Code and agent skill by rune-kit/rune
- community
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install rune-kit/rune/hallucination-guardSKILL.md
The same SKILL.md was published earlier as rune-kit/rune/hallucination-guard.
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
cookafter code generation, before commit - Called by
fixafter applying fixes - Called by
preflightas import verification sub-check - Called by
reviewduring 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 commitfix(L2): after applying fixespreflight(L2): import verification sub-checkreview(L2): during code reviewdb(L2): verify SQL syntax and ORM method calls are realreview-intake(L2): verify imports in code submitted for reviewskill-forge(L2): verify imports in newly generated skill codeadversary(L2): verify APIs/packages in plan actually existlogic-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:
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.
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:
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→ checkdependenciesanddevDependencies - Python:
requirements.txtorpyproject.toml→[project.dependencies]and[project.optional-dependencies] - Rust:
Cargo.toml→[dependencies]and[dev-dependencies]
Pre-import gate (BEFORE writing import statements, not just after):
- If the agent is ABOUT to import a package → check manifest FIRST
- 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 ``
- 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
<HARD-GATE> Any NEW package added to the manifest (not previously in the lockfile) MUST be verified against the actual registry. AI agents hallucinate package names at high rates. A package that doesn't exist on npm/PyPI/crates.io = supply chain risk. </HARD-GATE>
For each NEW external package (present in manifest but absent from lockfile):
3.5a. Registry existence check:
If command returns empty/error → BLOCK (package does not exist on registry — likely hallucinated name).
3.5b. Popularity check (slopsquatting defense):
Low-popularity packages with names similar to popular ones = SUSPICIOUS (potential slopsquatting attack).
3.5c. Known slopsquatting patterns:
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
Output Format
Constraints
- MUST verify every import against actual installed packages — not just check if name looks reasonable
- MUST verify API signatures against docs — not assume from function name
- MUST report BLOCK verdict with specific evidence — never "looks suspicious"
- 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 Mode | Severity | Mitigation | |
|---|---|---|---|
| Declaring "no hallucinations found" without listing what was checked | CRITICAL | Constraint 4 blocks this — always list verified count vs total | |
| Marking phantom package (not in manifest) as WARN instead of BLOCK | HIGH | Unlisted package in manifest = BLOCK — not installed = won't run | |
| Missing typosquatting check on external packages | MEDIUM | Edit distance ≤2 check is mandatory — check every external package name | |
| Only checking package name, not the specific exported symbol | MEDIUM | Step 2: verify the specific function/class is exported, not just the file exists | |
| Skipping registry verification for new packages | CRITICAL | Step 3.5 HARD-GATE: new packages MUST be verified against actual registry | |
| AI-hallucinated package name passes because it "sounds right" | HIGH | Slopsquatting defense: check registry existence, not name plausibility | |
| Low-popularity package with similar name to popular one not flagged | HIGH | Popularity 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.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/hallucination-guard/SKILL.md
Popularity
- Repository stars
- 77
- Repository forks
- 21
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/rune-kit/rune/hallucination-guard)