ai-debt-detector
它能做什么
这个 AI“技术债”检测工具会检查 AI 生成的代码,找出人类开发者通常会避免的常见问题。它会查找错误处理缺失、资源未释放、依赖项不存在,以及偏离项目规范等情况。
适用场景
- ✓在 AI 生成代码之后。
- ✓在采纳 AI 的建议或合并 AI 生成的代码之前。
- ✓当代码能运行,但你觉得它不够稳定或不够完整时。
技能链接
https://github.com/wshobson/agents/blob/main/plugins/skill-forge-essentials/skills/ai-debt-detector/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“扫描这段 AI 生成的代码,查找失败处理缺失、孤立资源和不存在的依赖项。”
每周 5 个新技能,1 分钟读完。
工作原理
它会分析代码中 AI 常见的错误模式,比如缺少错误处理、资源没有被释放,以及引用了不存在的软件包。目标是确保代码足够健壮和安全。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
AI Debt Detector
Overview
AI agents generate code that passes the happy path but hides debt: missing error handling, orphaned resources, ignored failure modes, hallucinated packages, silent architectural drift. This skill forces a targeted audit for the exact patterns AI agents get wrong.
When to Use
- After any AI code generation session (20+ lines produced)
- Before merging AI-generated PRs
- When code works but something feels off
- After vibe-coding sprints where debt accumulates fastest
- When the agent claims done without showing verification
Process
After code generation, scan for these AI-specific debt patterns:
FAILURE MODES - What happens when this fails?
- Network timeout? Disk full? Permission denied? Null input?
- Is there a try/catch? Does it catch SPECIFIC errors or swallow everything?
- Are resources cleaned up on failure? (streams closed, connections returned, temp files deleted)
ORPHANS - What gets created but never cleaned up?
- Temp files, event listeners, intervals, subscriptions, connections
- Are there corresponding cleanup/dispose/close calls for every open/create?
- In React: does every addEventListener have a removeEventListener in cleanup?
EDGE CASES - What inputs break this?
- Empty array/string? null/undefined? Multi-MB input? Unicode? Concurrent calls?
- Does the code assume the happy path? (AI almost always does)
HALLUCINATED DEPS - Do all imports actually exist?
- Is every package in package.json/requirements.txt?
- Are API methods real? (AI invents plausible-sounding methods that don't exist)
- Does this library's latest version still export this function?
ARCHITECTURAL DRIFT - Does this match the project's patterns?
- Same error handling style as existing code?
- Uses the project's established utilities (not reinventing)?
- Follows the file structure convention?
Red Flags (stop and fix immediately)
catch (e) {}orcatch (e) { console.log(e) }- swallowed error- No
finallyblock when resources were opened // TODO: handle error- AI's way of punting- Import from a path that doesn't exist in the project
- Timeout set but no abort/cleanup on timeout
- Database connection opened but never released back to pool
Common Mistakes
- Trusting that compilation means correctness (compilation checks syntax, not logic)
- Reviewing only the diff without checking what the AI did NOT generate (missing error paths)
- Assuming the AI used the right library version (it often uses deprecated APIs)
- Skipping the orphan check because garbage collection handles it (it doesn't for connections, listeners, timers)
Why This Exists
AI agents systematically optimize for "looks correct" and "passes the happy path." They miss failure modes, orphan resources, and hallucinate dependencies at rates significantly higher than manual code. This skill forces an audit for those specific blind spots.
常见问题
为什么要检查 AI 生成的代码?
AI 擅长写出在理想条件下能运行的代码,但它可能忘记处理错误、释放资源,或使用正确的软件包,这些遗漏会形成“技术债”,日后可能引发问题。
什么是“孤立资源”(orphaned resources)?
指代码创建了却没有在使用后关闭或删除的东西,比如网络连接或临时文件,它们会持续占用系统资源。
什么是“失败模式”(failure modes)?
指代码可能出错的情况(比如网络故障或输入无效),以及代码对这些情况的应对方式。好的代码会预先考虑如何处理这些情况。
详情
作者的原始描述
Use after generating code, after accepting AI suggestions, or when reviewing AI-written modules. Also use when code works but feels brittle, when error handling seems thin, when orphaned resources or missing cleanup are suspected, or when the agent claims done but hidden debt may exist. Catches the specific failure patterns AI agents produce that humans would not.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6788
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …