routine-dup-unifier

Detects and merges duplicated code implementations within a single monorepo package.

275|32|Updated Oct 2, 2020
One-click install
npx skills add https://github.com/bex-co/beancount-io --skill routine-dup-unifier-bex-co
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: routine-dup-unifier
Source: https://github.com/bex-co/beancount-io/tree/main/.agents/skills/routine-dup-unifier
Command: npx skills add https://github.com/bex-co/beancount-io --skill routine-dup-unifier-bex-co

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jscpd.

What problem does it solve? Monorepos accumulate parallel copies of the same logic as teams build features in isolation, and manually finding, comparing, and consolidating these duplicates is slow and error-prone. This Skill automates the entire deduplication workflow from discovery through shipping. ## Core Features & Use Cases - Duplicate Discovery: Searches a package for repeated names, similar signatures, and shared distinctive string literals, with optional acceleration via jscpd. - Semantic Verification: Reads every copy end to end to prove implementations are semantically identical before merging, and writes missing tests for the surviving implementation. - Safe Consolidation: Keeps the best-tested copy, repoints all callers, deletes the losers, re-runs dead-code detection, and ships each unification via /ship. - Use Case: A developer notices two helper files in the same package both format currency amounts. Invoke the routine to prove they are equivalent, merge them into one tested implementation, update all imports, and ship the change. ## Quick Start Ask the agent to run /routine-dup-unifier on a specific package to find and merge duplicated implementations into a single copy.

Frequently Asked Questions about routine-dup-unifier

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

FAQPage Schema
How do I find and remove duplicated code in a monorepo package?

Run the routine with a package path to search for repeated names, similar signatures, and shared string literals. It proves copies are semantically identical, keeps the best-tested one, repoints all callers, and deletes the rest.

What tools detect duplicate code in a codebase?

This routine uses agent-driven grep searches for repeated names and distinctive literals, with jscpd as an optional accelerator via npx. jscpd runs with a minimum token threshold and writes output to the package's gitignored tmp directory.

Can this merge duplicated code across different packages?

No, cross-package duplication is never merged because the repo forbids new cross-package imports. Such findings are only reported in the summary, while merging happens strictly within one package.

When should I skip merging two similar code implementations?

Skip when unification requires an abstraction more complex than either original, such as config objects or strategy callbacks. Also skip dead code with no callers and deliberate clean-room reimplementations listed in DO_NOT_DO.md.

How does the routine verify two code copies are truly equivalent?

It reads every copy end to end, since name similarity is not proof. Semantics must be identical or differ only in ways covered by a simple parameter, and the survivor must have tests covering all behavior callers rely on.