hallucination-guard
Skill88 starsChanged 7 months agoMITView on GitHub
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.
- Installs packages
2 other projects use a version of this.
Adopted by
Most recently taken up by
- not-yet-autonomous/CLAIREtheir own version, first seen Aug 17, 2026
- Momo2323-ui/claude-orchestratheir own version, first seen Jun 15, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- Momo2323-ui/claude-orchestra★ 9same name
- not-yet-autonomous/CLAIRE★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository67 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- adversarySkill
- asset-creatorSkill
- auditSkill
- autopsySkill
- baSkill
- brainstormSkill
- browser-pilotSkill
- completion-gateSkill
- constraint-checkSkill
- context-engineSkill
- context-packSkill
- convergeSkill
- cookSkill
- councilSkill
- dbSkill
- debugSkill
- dependency-doctorSkill
- deploySkill
- designSkill
- diagramSkill
- doc-processorSkill
- docs-seekerSkill
- docsSkill
- fixSkill
- gitSkill
- graftSkill
- improve-architectureSkill
- incidentSkill
- integrity-checkSkill
- journalSkill
- launchSkill
- logic-guardianSkill
- marketingSkill
- mcp-builderSkill
- neural-memorySkill
- onboardSkill
- perfSkill
- planSkill
- preflightSkill
- problem-solverSkill
- quarantineSkill
- rescueSkill
- researchSkill
- retroSkill
- review-intakeSkill
- reviewSkill
- safeguardSkill
- sastSkill
- scaffoldSkill
- scope-guardSkill
- scoutSkill
- sentinel-envSkill
- sentinelSkill
- sequential-thinkingSkill
- session-bridgeSkill
- skill-forgeSkill
- skill-routerSkill
- slidesSkill
- surgeonSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 13 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 48
Use Grep to find all import/require/use statements in changed files:
- Very specific: line 68
If Glob returns no results → mark as BLOCK (file does not exist).
- Distinctive: line 77
If export not found → mark as WARN (symbol may not be exported).
- Distinctive: line 81
Before importing ANY third-party library, check the dependency manifest.
- Very specific: line 83
Use Read on the project's dependency manifest to confirm each external package is listed:
- Distinctive: line 90
If the agent is ABOUT to import a package → check manifest FIRST
- Distinctive: line 91
If package is NOT in manifest → output install command before writing the import:
- Distinctive: line 98
If package IS in manifest → proceed with import
- Distinctive: line 101
If package is not listed in the manifest → mark as BLOCK (phantom dependency)
- Distinctive: line 102
If package is listed but not installed (no lockfile entry) → mark as WARN (not yet installed)
- Distinctive: line 122
If command returns empty/error → BLOCK (package does not exist on registry — likely hallucinated name).
- Distinctive: line 191
MUST verify every import against actual installed packages — not just check if name looks reasonable
- Distinctive: line 192
MUST verify API signatures against docs — not assume from function name
- Distinctive: line 193
MUST report BLOCK verdict with specific evidence — never "looks suspicious"
- Distinctive: line 194
MUST NOT say "no hallucinations found" without listing what was checked
- Distinctive: line 212
All imports extracted from changed files (internal + external separated)
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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:
Grep pattern: ^(import|require|use|from)\s
Files: changed files passed as input
Output mode: contentCollect 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 pathIf 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:
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/nullIf 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 statsLow-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 successfullyConstraints
- 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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

