
review-duplication
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.
- Installs
- 342
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/google-gemini/gemini-cli --skill review-duplication- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads review-duplication automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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.
3. Investigate the Codebase (Sub-Agent Delegation)
Delegate the heavy lifting of codebase investigation to specialized sub-agents. They are optimized to perform deep searches and semantic mapping without bloating your session history.
To ensure a comprehensive review, you MUST formulate highly specific objectives for the sub-agents, providing them with the "scents" you discovered in Step 1.
- Codebase Investigator: Use the
codebase_investigatoras your primary researcher. When delegating, formulate an objective that asks specific, investigative questions about the codebase, explicitly including these search vectors:- Structural Similarity: Ask if existing code uses the same underlying APIs (e.g., "Does any existing code use
Intl.DateTimeFormatorsetTimeoutfor similar purposes?"). - Naming Conventions: Ask if there are existing symbols with similar naming patterns (e.g., "Are there existing symbols with naming patterns like
*Format*or*Debounce*?"). - Comments & Documentation: Ask if keywords from the PR's comments or JSDoc exist in describing similar behavior elsewhere.
- Architectural Fit: Ask where this type of logic is currently centralized (e.g., "Where is centralized date formatting logic located?").
- Refactoring Guidance: Crucially, ask the sub-agent to explain how the new code could be refactored to use any existing logic it finds.
- Structural Similarity: Ask if existing code uses the same underlying APIs (e.g., "Does any existing code use
- Generalist Agent: Use the
generalistfor detailed, turn-intensive comparisons. For example: "Review the implementation ofMyNewComponentin the PR and compare it semantically against all components inpackages/ui/src. Are there any existing components that could be extended or used instead?" - Retain Fast Path for Simple Searches: For extremely simple, unambiguous checks (e.g., "Does
package.jsonincludelodash?"), perform a direct search to save time. Default to delegation for any open-ended "investigations."
4. Evaluate Best Practices
Check if the new code aligns with the project's established conventions.
- Error Handling: Does it use the project's standard error classes or logging mechanisms?
- State Management: Does it bypass established stores or contexts?
- Styling: Does it hardcode colors or spacing instead of using theme variables? If the PR introduces a new pattern, compare it against the documented standards and explicitly confirm if an existing project pattern should have been used instead.
5. Formulate Constructive Feedback
If you discover that the PR duplicates existing functionality or ignores a best practice:
- Provide a clear review comment.
- Identify the Source: Explicitly mention the absolute or project-relative file path and the specific symbol (function, component, class) that should be reused.
- Implementation Guidance: Provide a brief code snippet or a clear explanation showing how to integrate the existing code to fulfill the task's requirements.
- Explain the Value: Briefly explain why reusing the existing code is beneficial (e.g., maintainability, consistency, built-in edge case handling).
Example comment:
"It looks like this PR introduces a new
formatDateutility. We already have a robust, testedformatDatefunction insrc/utils/dateHelpers.ts.You can replace your implementation by importing it like this:
import { formatDate } from '../utils/dateHelpers'; // Then use it here: const displayDate = formatDate(userDate, 'MMM Do, YYYY');Reusing this ensures that the date formatting remains consistent with the rest of the application and handles timezone conversions correctly."
FAQ
What does the review-duplication skill do?
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.
How do I install review-duplication?
Run npx skills add https://github.com/google-gemini/gemini-cli --skill review-duplication in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/review-duplication/ (personal) or .claude/skills/review-duplication/ (project).
Which AI agents can use review-duplication?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is review-duplication safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains review-duplication?
It is published by google-gemini in google-gemini/gemini-cli, and it is an official skill from the maker of the technology it covers. It has 342 recorded installs.
More from google-gemini/gemini-cli
code-reviewer
google-gemini/gemini-cli
Use this skill to review code. It supports both local changes (staged or working tree) and remote Pull Requests (by ID or URL). It focuses on correctness, maintainability, and adherence to project standards.
docs-writer
google-gemini/gemini-cli
Always use this skill when the task involves writing, reviewing, or editing files in the /docs directory or any .md files in the repository.
pr-creator
google-gemini/gemini-cli
Use this skill when asked to create a pull request (PR). It ensures all PRs follow the repository's established templates and standards.
docs-changelog
google-gemini/gemini-cli
Generates and formats changelog files for a new release based on provided version and raw changelog data.
pr-address-comments
google-gemini/gemini-cli
Use this skill if the user asks you to help them address GitHub PR comments for their current branch of the Gemini CLI. Requires gh CLI tool.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.