find-duplication

作成者: openshift

コードベース内のコード重複を検出します。現在のブランチの変更にスコープを限定するモードと、コードベース全体をスキャンするモードの2つをサポートしています。ユーザーが検出を依頼した場合に使用します…

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のその他のスキル

openshift-expert
openshift
OpenShiftプラットフォームとKubernetesのエキスパートであり、クラスターアーキテクチャ、オペレーター、ネットワーキング、ストレージ、トラブルシューティング、CI/CDパイプラインに関する深い知識を持つ。使用…
official
find-token
openshift
隠された認証トークンを見つけます。find-tokenスクリプトを実行して、ユニークなトークンを取得します。
official
code-review
openshift
プルリクエストのコード品質、正確性、プロジェクト規約をレビューします。ユーザーがPRのレビュー、コードレビュー、または変更の確認を依頼した場合に使用します。
official
css-review
openshift
CSSのコーディングスタイル、PatternFlyトークンの使用法、ベストプラクティスをレビューします。ユーザーがCSSのレビュー、スタイルの確認、CSSファイルの監査を依頼した場合に使用します。
official
review-readmes
openshift
リポジトリ内のすべてのREADME.mdファイルをレビューし、タイポ、エラー、古い情報をチェックします。ユーザーがREADMEのレビューやドキュメントの正確性の確認などを依頼したときに使用します。
official
review-skills
openshift
プロジェクトのAIスキルを重複、古い参照、誤り、構造上の問題についてレビューします。ユーザーがスキルのレビュー、監査、チェックを依頼した場合に使用します。
official
test
openshift
タグでフィルタリングされたエンドツーエンドテストを実行します。ユーザーがテストの実行、Playwrightの実行、または@coreや@attachのような特定の機能タグのテストを依頼した場合に使用します。
official
unused-exports
openshift
他のファイルから一度もインポートされていないエクスポートされたシンボルを検出します。ユーザーが「エクスポートを確認」「未使用のエクスポート」と言ったり、エクスポートの整理を依頼した場合に使用します。
official