review-duplication

Investigate codebases for duplicated logic and missed reuse opportunities during code reviews.

107k|14.5k|Updated Apr 17, 2025
One-click install
npx skills add https://github.com/google-gemini/gemini-cli --skill review-duplication
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: review-duplication
Source: https://github.com/google-gemini/gemini-cli/tree/main/.gemini/skills/review-duplication
Command: npx skills add https://github.com/google-gemini/gemini-cli --skill review-duplication

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Code reviews often miss cases where new code duplicates existing utilities, reinvents wheels, or ignores established project patterns, leading to inconsistent and harder-to-maintain codebases.

Core Features & Use Cases

  • Structured Duplication Investigation: Follows a five-step workflow to extract core logic, hypothesize existing locations, delegate codebase searches, evaluate best practices, and formulate feedback.
  • Sub-Agent Delegation Strategy: Formulates specific investigative objectives for codebase_investigator and generalist sub-agents covering structural similarity, naming conventions, architectural fit, and refactoring guidance.
  • Constructive Review Feedback: Generates review comments that identify the source file path, provide implementation guidance with code snippets, and explain the value of reusing existing code.
  • Use Case: A reviewer encounters a new formatDate utility in a pull request and uses this skill to verify whether an existing helper in packages/core/src/utils/ already handles the same logic before flagging the duplication.

Quick Start

Review the current pull request for duplicated functionality and report any missed opportunities to reuse existing project utilities or shared patterns.

Frequently Asked Questions about review-duplication

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

FAQPage Schema
How do I detect duplicated code during a pull request review?

Extract the core algorithms and utility functions from the new code, then delegate searches to a codebase investigator sub-agent. Ask about structural similarity, naming conventions, and architectural fit to locate existing implementations that could be reused.

What is the best way to check for reinvented utilities in a codebase?

Hypothesize where the utility would live if it already existed, such as packages/core/src/utils/ or packages/cli/src/utils/. Trace third-party imports and check package.json for installed libraries like lodash or uuid that may already provide the functionality.

Can sub-agents perform deep codebase searches during code review?

Yes, the codebase_investigator and generalist sub-agents are optimized for deep searches and semantic mapping. Formulate specific objectives including search vectors like structural similarity, naming patterns, and architectural fit to get comprehensive results.

Why does new code duplicate existing project utilities?

Developers often miss existing helpers when working in unfamiliar parts of a monorepo. Lack of centralized documentation and inconsistent naming conventions across packages/core and packages/cli contribute to accidental duplication.

When should I not flag code duplication in a review?

Avoid flagging duplication when the new implementation has different requirements, performance constraints, or dependencies that justify a separate utility. Also skip cases where the existing code is deprecated or scheduled for removal.