← 返回 Skills 市场
42
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install hallucination-detector
功能描述
幻觉检测器 - 原创技能。检测AI生成代码中的幻觉内容,包括不存在的API、错误的参数、虚假引用等。适用于代码审查、AI编程辅助、质量保证等场景。
使用说明 (SKILL.md)
⚠️ 发布规则
所有发布到ClawHub的技能必须严格测试,确定没有问题再发布
技能测试验证清单
- frontmatter格式正确
- 检测逻辑完整
- 幻觉类型覆盖全
- 验证流程明确
- 无语法错误
Hallucination Detector - 幻觉检测器
原创技能 | 激活词: 检测幻觉 / 验证代码 / 代码审查
核心问题
AI生成的代码可能出现"幻觉":
- 调用不存在的API
- 使用错误的参数
- 引用不存在的文档
- 混淆相似的库名称
- 虚构函数签名
幻觉类型分类
类型1: API幻觉
# ❌ 幻觉: 不存在的API
response = requests.get_json(url) # 应该是 response.json()
# ❌ 幻觉: 错误的方法
list.append_many([1,2,3]) # 应该是 extend()
# ❌ 幻觉: 不存在的参数
df.sort('column', ascending=True) # pandas 2.x 应该用 by= 参数
类型2: 版本幻觉
# ❌ 幻觉: 版本不兼容
# React 19 不需要 forwardRef 了
# ❌ 幻觉: 过时的API
requests.post(url, data={}) # 应该用 json={}
类型3: 引用幻觉
# ❌ 幻觉: 不存在的文档
# 参见: https://fake-docs-example.com (虚构链接)
# ❌ 幻觉: 不存在的库
import super_fake_library # 未发布的库
类型4: 类型幻觉
# ❌ 幻觉: 错误的类型假设
def func(x: str) -> str:
return x.append('a') # str没有append方法
# ❌ 幻觉: 类型不匹配
result = await promise.json() # promise是Promise对象���不是Response
类型5: 逻辑幻觉
# ❌ 幻觉: 不可能的逻辑
if user.is_admin and not user.is_admin: # 自相矛盾
return "impossible"
# ❌ 幻觉: 永远为真的条件
if x == x: # 总是True
pass
检测策略
1. 静态分析
def static_check(code: str) -> list[Hallucination]:
issues = []
# 检查不存在的API调用
for call in extract_api_calls(code):
if not api_exists(call):
issues.append(Hallucination(
type='api',
location=call.location,
message=f"API '{call.name}' 不存在"
))
# 检查类型错误
for type_check in extract_type_checks(code):
if not type_compatible(type_check):
issues.append(Hallucination(
type='type',
location=type_check.location,
message=f"类型不匹配: {type_check.expected}"
))
return issues
2. 引用验证
def verify_references(code: str) -> list[Hallucination]:
issues = []
for ref in extract_urls_and_docs(code):
if not url_exists(ref):
issues.append(Hallucination(
type='reference',
location=ref.location,
message=f"URL不存在或无法访问: {ref.url}"
))
for lib in extract_imports(code):
if not package_exists(lib):
issues.append(Hallucination(
type='package',
location=lib.location,
message=f"包 '{lib.name}' 不存在"
))
return issues
3. 逻辑验证
def logical_check(code: str) -> list[Hallucination]:
issues = []
for expr in extract_conditions(code):
if is_contradiction(expr):
issues.append(Hallucination(
type='logic',
location=expr.location,
message="逻辑矛盾或永真条件"
))
return issues
完整检测流程
1. 代码输入
↓
2. 静态分析 (API/类型检查)
↓
3. 引用验证 (URL/包检查)
↓
4. 逻辑验证 (矛盾/永���检查)
↓
5. 综合报告
↓
6. 修复建议
输出格式
## 幻觉检测报告
### 检测结果: 发现 3 处幻觉 ⚠️
### 幻觉 #1 [高危]
- **类型**: API幻觉
- **位置**: line 15
- **代码**: `response.get_json()`
- **问题**: 方法名错误
- **建议**: 改为 `response.json()`
### 幻觉 #2 [中危]
- **类型**: 版本兼容
- **位置**: line 23
- **代码**: `forwardRef(...)`
- **问题**: React 19 已废弃
- **建议**: 直接使用 ref 作为 prop
### 幻觉 #3 [低危]
- **类型**: 引用幻觉
- **位置**: line 45
- **代码**: `https://docs.example.com/fake`
- **问题**: URL可能不存在
- **建议**: 验证链接或移除
### 置信度评估
- 综合置信度: 0.92
- 误报率预估: \x3C5%
置信度计算
| 检测类型 | 基础置信度 | 调整因素 |
|---|---|---|
| API检查 | 0.85 | +0.1 静态可验证 |
| 版本检查 | 0.70 | +0.1 版本明确 |
| 引用检查 | 0.80 | +0.1 可实际验证 |
| 逻辑检查 | 0.75 | +0.1 模式明确 |
集成建议
配合其他技能使用:
| 配合技能 | 效果 |
|---|---|
| workflow-verifier | 执行前验证代码 |
| karpathy-principles | 确保代码简洁可验证 |
| entropy-manager | 控制验证流程熵 |
原创性声明
本技能为原创,融合了:
- 静态代码分析
- API签名验证
- 引用完整性检查
- 逻辑矛盾检测
作者: laosi 创建日期: 2026-04-28
安全使用建议
The skill appears coherent and appropriate for code-review use. Before enabling it: 1) confirm how url_exists() / package_exists() will be implemented — those checks typically perform network requests and could fetch remote content; avoid running them on sensitive code unless you trust the network behavior; 2) if you rely on private package registries or internal documentation, ask whether credentials will be required and how they are stored; 3) test the skill on non-sensitive sample code to verify it does not leak contents to external hosts; 4) request documentation from the author about network/timeouts/caching and whether any remote endpoints are logged or contacted. If those questions are answered satisfactorily, the skill is reasonable to use.
能力评估
Purpose & Capability
Name/description describe detecting hallucinations in generated code; the SKILL.md contains static-analysis, reference/package checks, and logic checks that are directly relevant to that goal. The skill does not request unrelated binaries, environment variables, or config paths.
Instruction Scope
Instructions outline static analysis, URL/document verification, package-existence checks, and logical contradiction detection — all in-scope. One operational detail is left unspecified: functions like url_exists() and package_exists() imply network access (checking web URLs and package registries). That is reasonable for reference verification but could involve fetching remote resources or querying external registries; the README does not describe how network queries are performed or whether fetched content is sent elsewhere.
Install Mechanism
No install specification and no code files — this is instruction-only, so nothing is written to disk or installed by the skill itself.
Credentials
The skill declares no required environment variables, credentials, or config paths. The checks described could optionally require access to the network or private registries (which would require credentials), but none are requested here — so permissions requested are proportionate.
Persistence & Privilege
always is false and the skill does not request persistent or elevated privileges. Autonomous invocation is allowed (platform default) and is reasonable for this tool.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install hallucination-detector - 安装完成后,直接呼叫该 Skill 的名称或使用
/hallucination-detector触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
原创技能 - 检测AI生成代码中的幻觉内容
元数据
常见问题
幻觉检测器 是什么?
幻觉检测器 - 原创技能。检测AI生成代码中的幻觉内容,包括不存在的API、错误的参数、虚假引用等。适用于代码审查、AI编程辅助、质量保证等场景。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 42 次。
如何安装 幻觉检测器?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install hallucination-detector」即可一键安装,无需额外配置。
幻觉检测器 是免费的吗?
是的,幻觉检测器 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
幻觉检测器 支持哪些平台?
幻觉检测器 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 幻觉检测器?
由 534422530(@534422530)开发并维护,当前版本 v1.0.0。
推荐 Skills