find-dead-code

作成者: openshift

未使用の関数、クラス、インポート、および到達不能なコードパスを検出します。ユーザーがデッドコード、未使用コード、クリーンアップ候補の特定を求めた場合、または…したい場合に使用します。

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

Find Dead Code

Detect unused code that can be safely removed.

Rules

  • Report findings, do not delete. Removal is a separate task.
  • Focus on production code (ols/). Skip tests unless explicitly asked.
  • Vulture has false positives — classify each finding before recommending removal.
  • Code used only via dynamic dispatch (e.g. Pydantic validators, FastAPI dependencies) is not dead.

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$'

Step 2: Run Vulture

uvx vulture <target> --min-confidence 80

--min-confidence 80 reduces noise. Lower confidence findings are more likely false positives.

Step 3: Run Pylint Unused Checks

uv run pylint --disable=all --enable=unused-import,unused-variable,unused-argument,unreachable <target>

Cross-reference with vulture findings to increase confidence.

Step 4: Filter False Positives

Common false positives in this codebase:

PatternWhy it's not dead
Pydantic model_validator, field_validatorCalled by Pydantic, not directly
FastAPI dependency functionsInjected via Depends()
__eq__, __hash__, __str__Called implicitly by Python
Constants used in config YAMLReferenced by config loader
Abstract method implementationsCalled via base class interface
Imports re-exported from __init__.pyUsed by external consumers

Step 5: Classify Findings

For each finding, classify:

CategoryCriteriaAction
RemoveClearly unused, no dynamic referencesSafe to delete
VerifyPossibly used dynamically or externallySearch for string references before removing
False positivePydantic/FastAPI/magic methodSkip

For "Verify" findings, search for string-based references:

rg "<function_or_class_name>" ols/ tests/

Step 6: Report

For each finding:

  1. File and line number
  2. What is unused (function, class, import, variable)
  3. Confidence level (vulture %)
  4. Classification (remove / verify / false positive)

Summary: total findings, how many safe to remove, 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