# Find Similar Functions > Usa truffler para encontrar símbolos JS/TS parecidos o ya existentes antes de implementar código nuevo, sobre todo helpers, utilidades, parsers, formatters, scanners y fuzzy matchers, para no duplicar código existente. Fuente: https://skillsagentes.com/skills/millionco/react-doctor/find-similar-functions Markdown: https://skillsagentes.com/skills/millionco/react-doctor/find-similar-functions.md Repositorio: https://github.com/millionco/react-doctor Autor: millionco Licencia: NOASSERTION Actualizado: hace 3 meses Coste de contexto: 106 tok instalada, 1.2k tok al activarse, 1.2k tok con todos los archivos del bundle Bundle: 1 archivo, 5 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add millionco/react-doctor --skill find-similar-functions --agent claude-code # Cursor npx -y skills add millionco/react-doctor --skill find-similar-functions --agent cursor # Codex npx -y skills add millionco/react-doctor --skill find-similar-functions --agent codex # Gemini CLI npx -y skills add millionco/react-doctor --skill find-similar-functions --agent gemini # Windsurf npx -y skills add millionco/react-doctor --skill find-similar-functions --agent windsurf # Cline npx -y skills add millionco/react-doctor --skill find-similar-functions --agent cline ``` ## Qué hace - Usa `truffler`, una búsqueda difusa de símbolos, para encontrar funciones, métodos, constantes, tipos e interfaces JS/TS que ya existen antes de escribir código nuevo. - Deriva de 3 a 6 consultas del comportamiento previsto: el nombre propuesto, sustantivos de dominio, verbos y abreviaturas o sinónimos. - Ejecuta la búsqueda contra la raíz más estrecha útil primero y luego amplía; inspecciona los mejores resultados con las herramientas normales de lectura antes de editar. - Trata `truffler` como capa de descubrimiento: un nombre parecido no prueba duplicación, hay que comparar forma de entrada, efectos, comportamiento de error y forma de retorno. - En la respuesta final menciona qué encontró y si reutilizó algo o añadió una implementación nueva a propósito. ## Cuándo usarla - Antes de escribir código JS/TS nuevo que podría solapar con helpers existentes: utilidades, parsers, formatters, scanners, fuzzy matchers. - Al añadir o refactorizar funcionalidad en un repo JS/TS y querer evitar duplicar código. ## Qué la activa - "¿Ya existe un helper que normalice rutas en este repo?" - "Busca funciones parecidas antes de que escriba este formateador" - "Comprueba si hay un parser de config reutilizable" ## Antes de instalar - Necesita `truffler` instalado en el proyecto, ejecutable con `bunx @rayhanadev/truffler`, o `bun src/cli.ts` dentro del propio repo de truffler. - Necesita en el PATH: bun ## Archivos - SKILL.md — 5 KB ## SKILL.md Reproducido tal cual desde millionco/react-doctor bajo NOASSERTION. Esta sección es el documento original y está en inglés. # Similar Function Finder 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. ## Workflow 1. State the behavior you are about to implement in a few words. 2. Derive 3-6 search queries from the intended behavior: - the proposed function or class name - domain nouns, such as `symbol`, `path`, `file`, `route`, `token`, or `config` - verbs, such as `parse`, `normalize`, `discover`, `scan`, `format`, `rank`, `score`, `resolve`, or `validate` - common abbreviations and synonyms, such as `btn` for `button` or `cfg` for `config` 3. Run `truffler` against the narrowest useful root first, then broaden if needed. 4. Inspect the top matches with normal code-reading tools before editing. 5. Prefer reusing, extending, or moving existing code when the behavior substantially matches. Create new code only after the search shows there is not a suitable existing symbol. 6. In your final response, briefly mention what you found and whether you reused something or intentionally added a new implementation. ## Command Recipes When `truffler` is installed in the target project: ```bash 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: ```bash 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: ```bash 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. ## Search Strategy Start with symbols most likely to represent reusable behavior: ```bash truffler "" --kind function,method,constant,type,interface --limit 20 ``` Use JSON output when you need structured fields for ranking, locations, signatures, or automation: ```bash truffler "" --format json --limit 20 ``` Broaden deliberately: - If a precise function name has no match, search the domain noun and verb separately. - If a utility may live outside `src/`, try known library, package, app, or test roots. - If there are many matches, restrict `--kind` and reduce the root rather than skimming unrelated output. - If top matches look close, read the implementation and nearby tests or call sites before deciding. ## Reuse Decision Guide 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. ## Reporting Template Use a short note like this when the search affects your implementation: ```markdown 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: ```markdown 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. ``` ## Dónde encaja - Categoría: [Herramientas para desarrolladores](https://skillsagentes.com/categorias/herramientas-desarrollo.md) — Skills que cambian cómo tu agente escribe, revisa y despliega código. - Creador: [millionco](https://skillsagentes.com/creators/millionco.md) — 16 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [React Doctor](https://skillsagentes.com/skills/millionco/react-doctor/react-doctor.md): Escanea bases de código React en busca de problemas de seguridad, rendimiento, corrección y arquitectura, y da una puntuación de salud de 0 a 100. Incluye chequeo de regresión y un flujo completo de triage local con `/doctor`. - [Run Parity](https://skillsagentes.com/skills/millionco/react-doctor/run-parity.md): Compara los diagnósticos de React Doctor de un pull request contra su base con Daytona. Se usa para correr parity, comprobar regresiones de diagnósticos en un PR o reportar diagnósticos añadidos y quitados. - [Improve Threejs](https://skillsagentes.com/skills/millionco/react-doctor/improve-threejs.md): Audita y arregla apps de Three.js y React Three Fiber: rendimiento del frame-loop, fugas de memoria de GPU, corrección del grafo de escena y defectos visuales como z-fighting, shadow acne, espacio de color erróneo y resize roto. - [Fuzz](https://skillsagentes.com/skills/millionco/react-doctor/fuzz.md): Somete a fuzzing las reglas de React Doctor con `@react-doctor/fuzz` para hallar crashes, lentitud, falsos positivos y diagnósticos sensibles a mutaciones. Se usa tras pasar los tests de la regla o al confirmarse un falso positivo nuevo. - [Performance](https://skillsagentes.com/skills/millionco/react-doctor/performance.md): Diagnostica el rendimiento de React en tiempo de ejecución con trazas de React Doctor, marcado de renders en vivo, Long Animation Frames y evidencia de renders por componente. Se invoca como `/performance`. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)