帮助你审计代码库,找出语义重复但命名或实现不同的函数
复制安装指令,让 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 |
…
按需通过 mcp CLI 调用 MCP 服务,发现工具与资源而不预加载上下文
帮助你通过 tmux 控制需实时交互的命令行会话,安全运行编辑器、REPL 和交互式 Git 操作。
帮助用户在 Docker 中创建、管理并通过 SSH 连接无头 Windows 11 虚拟机。
帮助你撰写不过时的代码注释,聚焦做什么与为什么而非时序背景。
先用伪代码梳理方案与迭代思路,再高效转成可执行代码。
帮助开发者用早返回或表驱动方式简化嵌套条件分支,提升代码可读性。
调用多模型交叉审查代码变更、PR与高风险修改,辅助发现缺陷与争议点
全面审计网站 SEO 健康度,发现关键词机会、内容缺口与优化优先级。
帮助开发者审查代码中的内存泄漏与资源释放问题,定位常见生命周期隐患。
全面审计网站 SEO、性能、安全与可访问性问题并给出改进方向
帮助用户在代码仓库中识别可远程利用、具备漏洞赏金价值的安全问题。
审查 Convex 读写与订阅性能瓶颈,定位慢功能与并发冲突问题。