---
author: 'Tatyana Ardyntceva'
description:
  'Review a branch or merge-request diff for newly introduced, meaningful code
  duplication. Use when a user asks about repeated logic or copy-paste code in a
  diff.'
extras:
  'Add a script for obtaining the merge-base diff and an eval with intentional
  repeated test fixture code.'
focus: 'Find duplication newly introduced by a branch or merge-request diff.'
id: 'duplicate-code-check'
improve:
  - '“Ask before suggesting removal” is unnecessarily restrictive: suggestions
    are useful; ask before modifying code instead.'
  - 'Define the diff base/default when branch details are missing.'
  - 'Use a report with location pairs, similarity evidence, confidence, and a
    “do not merge” threshold.'
name: 'duplicate-code-check'
path: '../submitted-skills/Tatyana%20Ardyntceva/skills/duplicate-code-check/SKILL.md'
status: 'Needs report contract'
title: 'Duplicate code check'
wins:
  - 'Appropriately non-mutating by default.'
  - 'Targets the diff rather than all code.'
---

# duplicate-code-check

## Inputs

Source branch or MR and target branch; use the repository default base only
after reporting it.

## Workflow

1. Obtain the merge-base diff and list files examined.
2. Compare changed blocks with nearby and existing code; distinguish deliberate
   repetition, generated code, and test fixtures.
3. Report evidenced candidates with both locations, similarity, maintenance
   risk, and a proportionate suggestion.

## Rules

- Do not modify or remove code without explicit approval.
- Do not label repeated literals alone as duplication without a maintenance
  consequence.
- Report scope limits and skipped generated files.

## Output

Return a Markdown table: candidate, locations, evidence, confidence, risk,
suggested next step.
