帮助你审计代码库,找出语义重复但命名或实现不同的函数
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "finding-duplicate-functions" 技能: 1. 下载 https://raw.githubusercontent.com/obra/superpowers-lab/main/skills/finding-duplicate-functions/SKILL.md 2. 保存为 ~/.claude/skills/finding-duplicate-functions/SKILL.md 3. 装好后重载技能,告诉我可以用了
请审计这个代码库中的所有函数,找出语义上执行相同任务、但名称或实现不同的函数。按相似度分组,说明每组的共同职责、关键差异,并建议保留哪一个函数作为标准实现。
一份重复函数分组报告,包含相似原因、差异说明和合并建议。
这是一个由大模型辅助生成的项目,请重点检查是否存在“新写了一个函数而不是复用已有函数”的情况。列出疑似重复函数,指出哪些调用点可以改为复用现有实现,并给出重构建议。
面向重构的审计结果,指出可复用函数、替换调用点和代码清理方案。
请检查这个 utils 目录,找出功能重叠的辅助函数,例如多个格式化、解析、校验或转换函数。输出合并方案,并给出统一命名和迁移步骤建议。
一份工具函数合并清单,包含重复项、统一命名建议和迁移路径。
LLM-generated codebases accumulate semantic duplicates: functions that serve the same purpose but were implemented independently. Classical copy-paste detectors (jscpd) find syntactic duplicates but miss "same intent, different implementation."
This skill uses a two-phase approach: classical extraction followed by LLM-powered intent clustering.
| Phase | Tool | Model | Output |
|---|---|---|---|
| 1. Extract | scripts/extract-functions.sh | - | catalog.json |
| 2. Categorize |
scripts/categorize-prompt.md| haiku |
categorized.json |
| 3. Split | scripts/prepare-category-analysis.sh | - | categories/*.json |
| 4. Detect | scripts/find-duplicates-prompt.md | opus | duplicates/*.json |
| 5. Report | scripts/generate-report.sh | - | report.md |
digraph duplicate_detection {
rankdir=TB;
node [shape=box];
extract [label="1. Extract function catalog\n./scripts/extract-functions.sh"];
categorize [label="2. Categorize by domain\n(haiku subagent)"];
split [label="3. Split into categories\n./scripts/prepare-category-analysis.sh"];
detect [label="4. Find duplicates per category\n(opus subagent per category)"];
report [label="5. Generate report\n./scripts/generate-report.sh"];
review [label="6. Human review & consolidate"];
extract -> categorize -> split -> detect -> report -> review;
}
./scripts/extract-functions.sh src/ -o catalog.json
Options:
-o FILE: Output file (default: stdout)-c N: Lines of context to capture (default: 15)-t GLOB: File types (default: *.ts,*.tsx,*.js,*.jsx)--include-tests: Include test files (excluded by default)Test files (*.test.*, *.spec.*, __tests__/**) are excluded by default since test utilities are less likely to be consolidation candidates.
Dispatch a haiku subagent using the prompt in scripts/categorize-prompt.md.
Insert the contents of catalog.json where indicated in the prompt template. Save output as categorized.json.
./scripts/prepare-category-analysis.sh categorized.json ./categories
Creates one JSON file per category. Only categories with 3+ functions are worth analyzing.
For each category file in ./categories/, dispatch an opus subagent using the prompt in scripts/find-duplicates-prompt.md.
Save each output as ./duplicates/{category}.json.
./scripts/generate-report.sh ./duplicates ./duplicates-report.md
Produces a prioritized markdown report grouped by confidence level.
Review the report. For HIGH confidence duplicates:
Focus extraction on these areas first - they accumulate duplicates fastest:
| Zone | Common Duplicates |
|---|---|
utils/, helpers/, lib/ | General utilities reimplemented |
| Validation code | Same checks written multiple ways |
| Error formatting | Error-to-string conversions |
| Path manipulation | Joining, resolving, normalizing paths |
| String formatting | Case conversion, truncation, escaping |
| Date formatting | Same formats implemented repeatedly |
| API response shaping | Similar transformations for different endpoints |
…
帮助用户在 Docker 中创建、管理并通过 SSH 连接无头 Windows 11 虚拟机。
帮助开发者审查代码中的内存泄漏与资源释放问题,定位常见生命周期隐患。