帮助你审计代码库,找出语义重复但命名或实现不同的函数
复制安装指令,让 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 虚拟机。
帮助你通过 tmux 控制需实时交互的命令行会话,安全运行编辑器、REPL 和交互式 Git 操作。
按需通过 mcp CLI 调用 MCP 服务,发现工具与资源而不预加载上下文
在对话开始时建立技能发现与调用规则,确保先用技能再作答。
在创意与实现前梳理用户意图、需求与方案方向,降低返工风险。
系统化定位 bug、测试失败与异常行为,并在修复前梳理原因与排查步骤。
快速识别并合并重复记录,零配置完成高精度实体去重匹配。
用自然语言在代码库中进行语义搜索,快速定位相关文件与实现逻辑。
检测多语言代码库中的复制粘贴与重复片段,辅助重构和代码质量治理
调用多模型交叉审查代码变更、PR与高风险修改,辅助发现缺陷与争议点
用于语义化检索代码片段,并以更少 token 返回最相关结果。
将漏斗、无障碍与大模型可见性审计生成为可靠Markdown报告