obra avatar

Finding Duplicate Functions

LLM-generated codebases have a nasty habit of reimplementing the same utility function six different ways instead of reusing what exists. This skill catches those semantic duplicates that traditional copy-paste detectors miss. It extracts your functions, uses Haiku to group them by domain, then unleashes Opus on each category to find functions that do the same thing despite different implementations. The two-tier model approach is smart: cheap categorization, expensive analysis only where it matters. Focus on your utils folders and validation code first, those accumulate duplicates fastest. Just make sure the survivor function has tests before you consolidate, because the LLM can miss edge cases that only one implementation handled.

skills.sh installs
647
GitHub stars
438
last updated
Aug 21, 2026

Install

$ npx -y skills add obra/superpowers-lab --skill finding-duplicate-functions --agent claude-code

Installs into .claude/skills of the current project.

Files

Finding Duplicate-Intent Functions

Overview

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.

When to Use

  • Codebase has grown organically with multiple contributors (human or LLM)
  • You suspect utility functions have been reimplemented multiple times
  • Before major refactoring to identify consolidation opportunities
  • After jscpd has been run and syntactic duplicates are already handled

Quick Reference

PhaseToolModelOutput
1. Extractscripts/extract-functions.sh-catalog.json
2. Categorizescripts/categorize-prompt.mdhaikucategorized.json
3. Splitscripts/prepare-category-analysis.sh-categories/*.json
4. Detectscripts/find-duplicates-prompt.mdopusduplicates/*.json
5. Reportscripts/generate-report.sh-report.md

Process

Sponsors

Details

Repository
github.com/obra/superpowers-lab
Category
AI & Agent Building
First seen
Jun 3, 2026

More from obra/superpowers-lab

All 4
1product-on-purpose avatarutility-pm-skill-auditorproduct-on-purpose/pm-skillsRun a repo-wide cross-cutting governance audit via the pm-skill-auditor sub-agent. Aggregates the enforcing validator suite, re-derives aggregate counters, and 645skills.sh installs
2basicmachines-co avatarmemory-defragbasicmachines-co/basic-memory-skillsDefragment and reorganize agent memory files: split bloated files, merge duplicates, remove stale information, and restructure the memory hierarchy. Use when me643skills.sh installs
3product-on-purpose avatarutility-pm-changelog-curatorproduct-on-purpose/pm-skillsDraft CHANGELOG entries from git log via the pm-changelog-curator sub-agent, applying the repo hygiene rules (describe what changed, public paths only, no attri641skills.sh installs
4product-on-purpose avatarutility-pm-release-conductorproduct-on-purpose/pm-skillsWalk the guided 6-gate release runbook (G0 readiness, G1 adversarial review, G2 version bump and CHANGELOG, G2.5 commit and re-verify, G3 tag and push, G4 post-639skills.sh installs
5crafter-station avatarintent-layercrafter-station/skillsSet up hierarchical Intent Layer (AGENTS.md files) for codebases. Use when initializing a new project, adding context infrastructure to an existing repo, user a638skills.sh installs
6mvanhorn avatarpp-linearmvanhorn/printing-press-libraryOffline-capable, agent-native Linear CLI with SQLite-backed sync, FTS5 search, cross-cycle comparison, project... Trigger phrases: `what's on my Linear plate to635skills.sh installs