跳到正文
Skillpedia
通用编程8.1k · #12568

dead-code-cleanup

它能做什么

这项技能帮助你的 AI 找出无用代码,并建议可以删除的内容。适合希望减少杂乱代码、代码包体积或技术债务的开发者。

适用场景

  • ✓当你要求删除未使用的代码,或缩减项目规模的时候。
  • ✓当你想找出无法到达的文件、未使用的导出或遗留的包的时候。
  • ✓当你在规划清理工作,需要一份按可信度排序的清单的时候。

技能链接

https://github.com/repowise-dev/repowise/blob/main/plugins/claude-code/skills/dead-code-cleanup/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/repowise-dev/repowise/blob/main/plugins/claude-code/skills/dead-code-cleanup/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请找出这个项目中可以安全删除的无用代码,并告诉我每一项为何看起来未被使用。”

每周 5 个新技能,1 分钟读完。

工作原理

技能向 Repowise 请求按可信度排序的无用代码结果。只有标记为安全的项目才建议删除,可信度较低的项目则列为需要排查的对象,并且在删除任何内容之前请你确认。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Dead Code Cleanup with Repowise

Repowise detects dead code through graph analysis — no LLM needed, works even with a template-rendered wiki.

When the user asks about dead/unused code

Call get_dead_code() to get findings sorted by confidence tier. Useful parameters:

  • safe_only=true — only findings confirmed safe to delete (confidence >= 0.7)
  • kind="unreachable_file" — files with no importers
  • kind="unused_export" — public symbols nobody uses
  • kind="zombie_package" — monorepo packages with no consumers
  • directory="src/old/" — limit to a specific directory
  • tier="high" — only high-confidence findings (>= 0.8)
  • min_confidence=0.7 — raise the floor (default is 0.5) for a release-ready cleanup
  • group_by="directory" or group_by="owner" — roll up to see where the dead code concentrates and who owns the most of it

How to present findings

  • Only suggest deletion for findings with safe_to_delete: true
  • For lower-confidence findings, present them as "candidates to investigate" not "things to delete"
  • Dynamically-loaded code (plugins, handlers, adapters) may appear as dead code but isn't — Repowise filters common patterns but edge cases exist

Before deleting anything

  1. Confirm with the user. Present the file/symbol name, confidence score, and why Repowise thinks it's dead.
  2. Call get_risk(targets=["path/to/file"]) to double-check dependents.
  3. Recently-modified "dead" code is more likely a false positive — flag this if the finding has recent git activity.

Safe deletion order

  1. Unreachable files first (whole file removal, cleanest)
  2. Unused internal symbols next
  3. Unused exports last (highest false-positive risk due to potential dynamic imports)
常见问题

它会自行删除代码吗?

不会。技能会先请你确认每一次删除。

它对插件或动态代码的判断可能有误吗?

可能。动态加载的代码看起来可能未被使用,因此技能会提醒存在这类特殊情况。

删除之前它会检查什么?

在建议移除之前,它会先用风险检查确认该文件的依赖关系。

详情

作者的原始描述

Use when the user asks about cleanup, removing unused code, refactoring, reducing bundle size, or identifying dead code in a Repowise-indexed codebase (.repowise/ directory exists). Also activates when discussing technical debt, code hygiene, or repository maintenance.

repo: repowise-dev/repowise

热度

GitHub 星标
8.1k
排名
#12568
许可证
AGPL-3.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能