# Find Duplicated Code

Checks a change for reinvented utilities and duplicated functionality in the codebase.

- Repository: https://github.com/google-gemini/gemini-cli (108651 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add google-gemini/gemini-cli --skill review-duplication -g -a claude-code -y`
Codex: `npx skills add google-gemini/gemini-cli --skill review-duplication -g -a codex -y`
Cursor: `npx skills add google-gemini/gemini-cli --skill review-duplication -g -a cursor -y`
Gemini CLI: `npx skills add google-gemini/gemini-cli --skill review-duplication -g -a gemini-cli -y`

## Description

Use this skill during code reviews to proactively investigate the codebase for duplicated functionality, reinvented wheels, or failure to reuse existing project best practices and shared utilities.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Review Duplication

## Overview

This skill provides a structured workflow for investigating a codebase during a code review to identify duplicated logic, reinvented utilities, and missed opportunities to reuse established patterns. By executing this workflow, you ensure that new code integrates seamlessly with the existing project architecture.

## Workflow: Investigating for Duplication

When reviewing code, perform the following steps before finalizing your review:

### 1. Extract Core Logic
Analyze the new code to identify the core algorithms, utility functions, generic data structures, or UI components being introduced. Look beyond the specific business logic to see the underlying mechanics.

### 2. Hypothesize Existing Locations & Trace Dependencies
Think about where this type of code *would* live if it already existed in the project. Provide absolute paths from the repo root to disambiguate.
- **Utilities:** `packages/core/src/utils/`, `packages/cli/src/utils/`
- **UI Components:** `packages/cli/src/ui/components/`, `packages/cli/src/ui/`
- **Services:** `packages/core/src/services/`, `packages/cli/src/services/`
- **Configuration:** `packages/core/src/config/`, `packages/cli/src/config/`
- **Core Logic:** Call out `packages/core/` if functionality does not appear React UI specific.

**Trace Third-Party Dependencies:** If the PR introduces a new import for a utility library (e.g., `lodash.merge`, `date-fns`), trace how and where the project currently uses that library. There is likely an existing wrapper or shared utility.

**Check Package Files:** Before flagging a custom implementation of a complex algorithm, check `package.json` to see if a standard library (like `lodash` or `uuid`) is already installed that provides this functionality.

The rest: https://github.com/google-gemini/gemini-cli/blob/HEAD/.gemini/skills/review-duplication/SKILL.md
