find-duplication

द्वारा openshift

Find code duplication in the codebase. Supports two modes - scoped to current branch changes or a full codebase sweep. Use when the user asks to find…

npx skills add https://github.com/openshift/lightspeed-service --skill find-duplication

Find Code Duplication

Detect duplicated or near-duplicate code and suggest consolidation candidates.

Rules

  • Report findings, do not refactor. Refactoring is a separate task.
  • Focus on production code (ols/). Skip test duplication unless explicitly asked.
  • Group findings by severity: exact duplicates first, then near-duplicates.
  • For each finding, state whether extraction is worth it or acceptable duplication.

Step 1: Determine Scope

Ask the user:

  • Branch mode: only files changed in the current branch vs main.
  • Full mode: scan the entire ols/ directory.

For branch mode:

git diff --name-only origin/main -- 'ols/' | grep '\.py$'

For full mode, the target is ols/.

Step 2: Run Pylint Duplicate Detection

uv run pylint --disable=all --enable=duplicate-code --min-similarity-lines=6 <target files or directory>

Review output. Filter out false positives:

  • Import blocks (common imports are not duplication)
  • Pydantic model boilerplate (Field declarations)
  • Single-line patterns (logging, raises)

Step 3: Semantic Duplication Search

Pylint only catches textual similarity. Also look for:

  1. Similar function signatures — functions with near-identical parameter lists doing similar work.
  2. Repeated error handling — same try/except/log/return pattern across multiple files.
  3. Copy-pasted blocks — search for distinctive string literals or variable names that appear in multiple files.
rg "<distinctive pattern>" ols/ --type py -l

Step 4: Classify Findings

For each duplicate found, classify:

CategoryAction
Extract — identical logic in 3+ placesRecommend a shared helper
Parameterize — same structure, different valuesRecommend a common function with parameters
Acceptable — similar but serving different domainsNote it, no action needed
Test-only — repeated test setup/fixturesRecommend shared fixture (only if user asked)

Step 5: Report

For each finding:

  1. Files and line ranges involved
  2. What is duplicated (brief description)
  3. Classification (extract / parameterize / acceptable)
  4. Suggested location for shared code (if applicable)

Summary: total findings, how many actionable, estimated lines saved.

openshift की और Skills

openshift-expert
openshift
OpenShift प्लेटफ़ॉर्म और Kubernetes विशेषज्ञ जिसे क्लस्टर आर्किटेक्चर, ऑपरेटर, नेटवर्किंग, स्टोरेज, समस्या निवारण और CI/CD पाइपलाइनों का गहन ज्ञान है। उपयोग करें…
official
find-token
openshift
Find the hidden verification token. Run the find-token script to retrieve a unique token.
official
code-review
openshift
पुल रिक्वेस्ट की कोड गुणवत्ता, शुद्धता और प्रोजेक्ट कन्वेंशन के लिए समीक्षा करें। उपयोग तब करें जब उपयोगकर्ता PR की समीक्षा, कोड रिव्यू या बदलावों की जांच करने के लिए कहे...
official
css-review
openshift
सीएसएस को कोडिंग शैली, पैटर्नफ्लाई टोकन उपयोग और सर्वोत्तम प्रथाओं के लिए समीक्षा करें। जब उपयोगकर्ता सीएसएस की समीक्षा करने, शैलियों की जांच करने या सीएसएस फाइलों का ऑडिट करने के लिए कहे तब उपयोग करें।
official
review-readmes
openshift
रिपॉजिटरी में सभी README.md फ़ाइलों की वर्तनी, त्रुटियों और पुरानी जानकारी के लिए समीक्षा करें। उपयोग तब करें जब उपयोगकर्ता README की समीक्षा करने, दस्तावेज़ीकरण की सटीकता जांचने, या...
official
review-skills
openshift
प्रोजेक्ट AI स्किल्स में डुप्लिकेशन, पुराने संदर्भ, गलतियाँ और संरचनात्मक समस्याओं की समीक्षा करें। उपयोग तब करें जब उपयोगकर्ता स्किल्स की समीक्षा, ऑडिट, या जाँच करने के लिए कहे...
official
test
openshift
टैग द्वारा फ़िल्टर करके एंड-टू-एंड परीक्षण चलाएँ। इसका उपयोग तब करें जब उपयोगकर्ता परीक्षण चलाने, Playwright चलाने, या @core या @attach जैसे किसी विशिष्ट फीचर टैग का परीक्षण करने के लिए कहे।
official
unused-exports
openshift
उन निर्यातित प्रतीकों को खोजें जो कभी किसी अन्य फ़ाइल द्वारा आयात नहीं किए गए हैं। इसका उपयोग तब करें जब उपयोगकर्ता "check exports", "unused exports" कहे या निर्यात साफ करने के लिए कहे।
official