Use truffler to find similar or pre-existing JavaScript/TypeScript symbols before implementing new code, especially helpers, utilities, parsers, formatters, sca
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-find-similar-functions-ad1a6c429014 ,按照其中的说明把「find-similar-functions」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Use this skill before writing new JavaScript or TypeScript code that might overlap with existing helpers. The goal is to discover nearby functions, methods, constants, types, and interfaces early enough to reuse or extend them instead of creating duplicate behavior.
truffler is a fuzzy symbol search tool. Treat it as a discovery layer: it points you to likely symbols, but you still need to inspect the code before deciding whether something is reusable.
symbol, path, file, route, token, or configparse, normalize, discover, scan, format, rank, score, resolve, or validatebtn for button or cfg for configtruffler against the narrowest useful root first, then broaden if needed.When truffler is installed in the target project:
truffler "normalize path" src --kind function,method,constant,type --limit 20
truffler "score" src --kind function,method --format json --limit 15
When working inside this truffler repository:
bun src/cli.ts "discover file" src --kind function,method,constant,type --limit 20
bun src/cli.ts "format result" src --kind function,method --format json --limit 15
When the project has no installed binary and you should not add dependencies, use bunx if network/package execution is acceptable for the environment:
bunx @rayhanadev/truffler "parse config" src --kind function,method,type --limit 20
If truffler cannot be run, say so and fall back to the repository's available search tools. Still follow the same deduplication intent: search before implementing.
Start with symbols most likely to represent reusable behavior:
truffler "<query>" <root> --kind function,method,constant,type,interface --limit 20
Use JSON output when you need structured fields for ranking, locations, signatures, or automation:
truffler "<query>" <root> --format json --limit 20
Broaden deliberately:
src/, try known library, package, app, or test roots.--kind and reduce the root rather than skimming unrelated output.Consider an existing symbol reusable when it already handles the same input shape, side effects, error behavior, and return shape, or when a small extension would preserve its current contract.
Avoid reusing a symbol just because its name is close. Fuzzy matches can surface unrelated code. Inspect signatures, implementation, callers, and tests before changing anything.
When no suitable symbol exists, keep the new implementation near the closest related module and align with that module's naming, error handling, and test style.
Use a short note like this when the search affects your implementation:
I checked for existing symbols with `truffler` using queries like `normalize`, `path`, and `resolve`. The closest match was `normalizePath` in `src/files.ts`, so I reused that behavior instead of adding a separate helper.
If nothing relevant exists:
I searched with `truffler` for `parse`, `config`, and `loadConfig` across `src/`; the matches were unrelated, so I added a new helper in the nearest module.