finding-duplicate-functions

Detects semantically duplicate functions across a codebase using extraction and LLM-based intent clustering.

Updated Jun 20, 2026
One-click install
npx skills add https://github.com/dchavez3395/Puchica-hydrogen --skill finding-duplicate-functions-dchavez3395
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: finding-duplicate-functions
Source: https://github.com/dchavez3395/Puchica-hydrogen/tree/main/docs/superpowers/skills/openclaw-ports/finding-duplicate-functions
Command: npx skills add https://github.com/dchavez3395/Puchica-hydrogen --skill finding-duplicate-functions-dchavez3395

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ripgrep, jq, and includes scripts (resource) components.

What problem does it solve? LLM-generated and organically grown codebases accumulate semantic duplicates: functions that do the same thing under different names or implementations. Classical copy-paste detectors like jscpd only find syntactic duplicates and miss same-intent code, leading to bloated utilities and inconsistent behavior. ## Core Features & Use Cases - Two-Phase Detection Pipeline: Extracts a function catalog with ripgrep and jq, then uses LLM subagents to categorize functions by domain and detect duplicates within each category. - Model-Tiered Analysis: Uses a lightweight model (haiku-class) for cheap categorization and a stronger model (opus-class) for subtle semantic duplicate detection, with confidence-ranked reporting. - Prioritized Markdown Report: Aggregates per-category findings into a report grouped by confidence level so reviewers know which consolidations to act on first. - Use Case: Before a major refactor of an LLM-generated TypeScript app, run the pipeline over app/components/ and app/lib/ to find reimplemented validation, formatting, and path utilities, then consolidate them safely behind tests. ## Quick Start Ask the assistant to audit the src directory for semantically duplicate functions and produce a prioritized consolidation report.

Frequently Asked Questions about finding-duplicate-functions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find duplicate functions in a codebase?▼

Run the extraction script over your source directory to build a JSON function catalog, categorize functions by domain with a lightweight LLM, then run a stronger model per category to detect semantic duplicates. The final script generates a prioritized markdown report.

What is the difference between jscpd and semantic duplicate detection?▼

jscpd finds syntactic copy-paste duplicates by comparing token sequences. Semantic duplicate detection uses LLM analysis to find functions with the same intent but different names or implementations, which copy-paste detectors miss.

Which tools are required to run the duplicate detection scripts?▼

The pipeline requires ripgrep, jq, and bash, all of which work in standard environments including Git Bash on Windows. The categorization and detection phases additionally need access to LLM subagents.

Why use different models for categorization and duplicate detection?▼

Categorization is a simple grouping task that a cheap haiku-class model handles adequately. Duplicate detection requires spotting subtle semantic equivalence, so it needs a stronger opus-class model to avoid missing non-obvious duplicates.

When should I not consolidate duplicate functions?▼

Do not consolidate when the surviving function lacks tests covering all use cases of the deleted duplicates. Verify test coverage first, update callers to the survivor, delete the duplicates, and rerun the test suite.