Use this skill during code reviews to proactively investigate the codebase for duplicated functionality, reinvented wheels, or failure to reuse existing project
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-review-duplication-89c53174a9ee ,按照其中的说明把「review-duplication」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
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.
When reviewing code, perform the following steps before finalizing your review:
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.
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.
packages/core/src/utils/, packages/cli/src/utils/packages/cli/src/ui/components/, packages/cli/src/ui/packages/core/src/services/, packages/cli/src/services/packages/core/src/config/, packages/cli/src/config/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.
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 as your primary researcher. When delegating, formulate an objective that asks specific, investigative questions about the codebase, explicitly including these search vectors:
Intl.DateTimeFormat or setTimeout for similar purposes?").*Format* or *Debounce*?").generalist for detailed, turn-intensive comparisons. For example: "Review the implementation of MyNewComponent in the PR and compare it semantically against all components in packages/ui/src. Are there any existing components that could be extended or used instead?"package.json include lodash?"), perform a direct search to save time. Default to delegation for any open-ended "investigations."Check if the new code aligns with the project's established conventions.
If you discover that the PR duplicates existing functionality or ignores a best practice:
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."