duplication-audit

Detect and classify must-agree code copies that can silently diverge across a codebase.

Updated Feb 17, 2026
One-click install
npx skills add https://github.com/semantic-praxis/barwise --skill duplication-audit-semantic-praxis
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: duplication-audit
Source: https://github.com/semantic-praxis/barwise/tree/main/.claude/skills/duplication-audit
Command: npx skills add https://github.com/semantic-praxis/barwise --skill duplication-audit-semantic-praxis

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Codebases that deliberately favor parallel copies over shared abstractions accumulate duplicated decisions—re-listed unions, copied helpers, prose restating code facts—that can drift apart silently. This Skill provides the classification rubric, authoring rules, and five-pass audit method to find, classify, and prevent such drift before it becomes a live bug. ## Core Features & Use Cases - Classification rubric: Assigns every duplicated pair a verdict—guarded, benign parallel, drift-prone, or diverged—based on whether copies must agree and what mechanically checks them. - Authoring rules: Six prevention rules covering deriving from authorities, registering or testing intentional copies, completeness checks for union membership, exhaustive vs. partial switches, and prose that restates code. - Five-pass audit method: A structured sweep covering cross-surface wiring, literals and unions, prose parity claims, derived artifacts, and structural clones, seeded by the deterministic npm run audit:duplication detector. - Use Case: When reviewing a diff that adds a second copy of a decision (e.g., a z.enum restating a core union in both CLI and MCP surfaces), apply the rubric to decide whether it needs a drift test, a parity manifest entry, or derivation from a shared authority. ## Quick Start Audit this repository for duplicated decisions that must agree but have no mechanical check, and classify each finding using the drift rubric.

Frequently Asked Questions about duplication-audit

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

FAQPage Schema
How do I audit a codebase for duplicated logic that can drift?▼

Run the deterministic detector (npm run audit:duplication) to emit candidates, then apply the five-pass sweep: cross-surface wiring comparison, literal and union tracing, prose parity claims, derived artifact guard checks, and structural clone hunts with jscpd. Classify each finding with the rubric before filing.

How do I decide whether duplicated code is a defect?▼

Ask whether the copies must agree for the system to be correct and what notices when they stop. Copies with a mechanical check are guarded; copies serving different concerns are benign parallel; must-agree copies with no check are drift-prone; drift-prone copies that already disagree are diverged.

When is duplicating code acceptable instead of sharing an abstraction?▼

Cross-package parallelism is acceptable when a shared abstraction would couple packages that should stay orthogonal. The copy must then be registered in a parity manifest or covered by a drift test in the same commit—a 'must match' comment is not a check.

Why is a Set or array of union members not a completeness check?▼

A Set<Union> or readonly Union[] proves every listed entry is valid, not that every member is listed—a new union member stays silently absent. Derive from a Record<Union, true> via Object.keys, or make the switch exhaustive with assertNever, to get a compile-time completeness guarantee.

What are the limitations of automated duplication detection?▼

Token-level detectors like jscpd find byte-similar clones but miss semantic clones—same decision with different literals, such as resolve-or-default shapes or type-mapping tables. Those require manual judgment passes, and every finding must be re-verified against the current tree since concurrent merges can move or fix it.