Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add danhuaxiansheng/claude-code-cleanup-skills --skill unused-code-auditgit clone --depth 1 https://github.com/danhuaxiansheng/claude-code-cleanup-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/danhuaxiansheng/claude-code-cleanup-skills/unused-code-audit)<a href="https://agentmods.dev/skills/danhuaxiansheng/claude-code-cleanup-skills/unused-code-audit"><img src="https://agentmods.dev/badge/skills/danhuaxiansheng/claude-code-cleanup-skills/unused-code-audit/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/danhuaxiansheng/claude-code-cleanup-skills/unused-code-audit"><img src="https://agentmods.dev/badge/skills/danhuaxiansheng/claude-code-cleanup-skills/unused-code-audit.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00093 | $0.01943 |
| Opus 5 | $0.00046 | $0.00971 |
| Sonnet 5 | $0.00019 | $0.00389 |
| Haiku 4.5 | $0.00009 | $0.00194 |
Grade A, and why
unused-code-audit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 142 lines — stays where its author put it; the contents beside it link to each section on GitHub.
未使用代码审计
原则
把每个自动化结果都当作候选,而不是证明。只有在用法、入口、副作用和公共 API 风险都被排除后,才删除。
优先做小而有证据的删除。不要仅因为类型或导出名没有直接 import,就收缩公共 API;生成声明和推断出的消费者类型仍可能依赖它。
本技能回答“还有人在消费它吗?”。它不回答更广义的“它是否仍有必要?”。对于“被使用但不必要”的代码,切换到 necessary-code-audit。
不要在发现第一个未使用符号后停止。对于用户指定的目录或功能,必须审计作用域内所有文件、导出、本地 helper 和 re-export 路径后再报告完成。
不要把注释作为未使用代码删除或重写,除非相关代码被删除,或注释已经过期/误导。
本技能属于三个清理技能之一:
- 用
unused-code-audit证明代码是否仍有消费者。 - 代码被使用但可能不必要时,用
necessary-code-audit。 - 目标涉及页面状态、查询、变更、权限、错误或用户可见行为时,用
page-flow-cleanup-audit。
边界
本技能只回答“是否存在真实消费者,以及在零消费者时能否安全删除”。
适合本技能:
- 文件、导出、类型、常量、组件、hook、helper 是否无人 import 或引用。
- re-export、barrel export、type-only import、动态字符串 key、框架入口和副作用是否构成真实消费。
- 删除零消费者代码后,清理直接 export、孤立 import/type 和残留路径。
不适合本技能单独完成:
- 某个 helper 有调用方但只是薄 wrapper;改用
necessary-code-audit。 - 公共 API 仍被 import,但可能只是历史兼容面;改用
necessary-code-audit判断是否迁移调用方并收缩公共面。 - 防御分支、fallback、默认值、可选字段是否有领域意义;改用
necessary-code-audit。 - 页面状态、权限、query/mutation、source-of-truth 是否应清理;改用
page-flow-cleanup-audit。
协作规则:
- 搜索发现候选仍有真实消费者时,停止“未使用”结论;若它看起来仍不必要,移交
necessary-code-audit。 - 不要因为“调用方可以改写”就把已使用代码判定为 unused。那是必要性问题,不是 unused 问题。
- 本技能可以删除零消费者代码,但不负责迁移有消费者的调用方,除非迁移只是删除同一文件内新孤立的直接引用。
基线
- 先检查工作区状态:
git status --short --untracked-files=all。 - 检查目标作用域的 unstaged 和 staged 变更:
git diff --name-status -- <scope>、git diff --cached --name-status -- <scope>。 - 构建目标作用域文件清单,优先用
rg --files <scope>。 - 信任自动 unused 结果前,检查 import、export、manifest、框架入口、生成文件和直接消费者。
- 删除前建立影响面图:定义包 exports、同包消费者、下游 package/app import,以及可能 import 公共面的脚本/测试。
深度门槛
完成 unused-code audit 前必须:
- 列出请求作用域内每个文件和导出符号。
- 当本地 helper 只能通过导出聚合或公共函数触达时,也纳入检查。
- 搜索精确符号、import path、file stem、barrel export、type-only import、属性访问、字符串 key 和测试/脚本用法。
- 将结果明确分为“无消费者,可按删除标准继续”和“有消费者,退出 unused 判断并转 necessary-code-audit”。
- 只对无消费者候选继续检查公共入口、框架约定、副作用和动态引用。
- 编辑后再次搜索删除名称和旧路径,捕获孤立导出和陈旧 import。
- 公共面变更时,运行定义包验证和受影响下游 package/app 验证。
不要要求用户再次提示,才在同一请求作用域内从一个候选继续到下一个候选。
候选分类
删除前分类:
文件:模块、route、样式、setup、生成入口或副作用文件。运行时导出:函数、组件、hook、class、常量、store 或工厂。公共类型/API:导出的 interface/type/config,被声明文件或工厂返回类型使用。成员:属性、方法、action、enum member 或配置字段。本地 helper:单文件内非导出 helper。
What ships with it
2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 12d ago First seen · 142 lines · 93 tokens per session scan A 85d0fce2027b
unused-code-audit is a skill published in the GitHub repository danhuaxiansheng/claude-code-cleanup-skills (2 stars, last pushed 2mo ago), licensed MIT. It adds 93 tokens to every session and 1,943 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
concept-audit
A read-only audit skill for checking code against Daniel Jackson concept models, which describe independent parts of a system and how they work together.
dotnet-techne-refactor-pipeline
Use when the user asks for a phase-gated refactoring or redesign loop - session-blind workers map and trace the area, empirical probes precede the design, an approval gate guards implementation, and a conformance audit re-checks the branch after any design change. State persists in .episteme/DESIGN- .md. Requires the…
vet
Thorough codebase investigation that finds and fixes real problems. Maps architecture, scans every layer (structural, correctness, security, reliability, performance, hygiene), prioritized report with evidence, fix plan, executes collaboratively. A senior engineer doing a full review with authority to fix. Use when…
code-quality-loop
Iterative review-fix loop: reviews code, auto-fixes issues, repeats until clean or stuck. Finishes with reorganize (for large changes), simplify + test consolidation.
autofix
Review and repair current local changes until they converge, or run Qwen Code Autofix issue and review workflows from GitHub Actions.
audit
Project health audit and health check — architecture, performance, tests, dependencies, code quality. Use when assessing overall project health, before releases, or after refactors.