本文へ移動
cccskills
無料GitHub で公開日本語紹介

duplicate-and-dead-code

コードの意味的な重複や未使用コードの候補を調べ、計画段階の担当箇所確認やレビュー時の重複チェック、削除判断を支援します。

原文原文の説明を見る

Find semantic copies and dead code before a plan or a review.

JetBrains/intellij-communityスター 20,685(GitHub 20,685 + cccskills 0)

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • 実装前に既存の担当箇所を調べたいとき
  • 変更箇所の重複候補をレビューしたいとき
  • 未使用コードや画像の候補を確認したいとき

日本語での紹介

できること

変更計画の前に、追加しようとしている処理をすでに担うコードがないか調べます。動作や役割を手がかりに既存コードを探し、呼び出し元や参照先をたどって担当箇所を確認します。レビュー時には、構文や意味が似た関数を検出するコピー lint を実行し、変更したファイルに関係する候補を確認します。また、宣言や画像などの未使用候補を一覧にし、削除する場合の確認手順を示します。

こんなときに便利

同じ責務を別の場所に実装してしまうのを避けたいときや、変更箇所のレビューで重複を見つけたいときに役立ちます。未使用候補の調査にも使えます。検出結果は確定ではなく候補なので、コードを読んで判断する必要があります。

使い方の例

  • 「この変更で追加する処理を担当している既存コードがないか調べてください」
  • 「変更したディレクトリの意味的な重複候補を確認してください」
  • 「この範囲の未使用コード候補を調べてください」

注意点

accio と jscpd を使います。accio が PATH にない場合は ./community/tools/accio.cmd、jscpd は指定のラッパー経由で実行します。初回の意味的解析には548 MBのモデルが必要です。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

資料チェック

SKILL.md の記述から、注意が要る操作と導入の前提を AI が確認しました。点数は実際に動かした結果(実行検証)だけで付けています。

安全面送信・削除・コマンド実行などの扱いが明示されているか
A良好削除前に範囲なしで再確認し、候補を読んで判断する手順を明記。
導入のしやすさ必要なツールや API キーが少ないか、書かれているか
B一部不足`accio`・`jscpd`と指定ラッパー、初回548 MBモデルが必要と記載。

点数には入れていません。 2026年10月29日 時点で AI(OpenAI Codex)が判定しました。目安なので、入れる前に原文も確認してください。

評価が違うと思ったら、見直しを依頼する

どの項目が、なぜ違うと思うかを書いてください。ログインは不要です。内容を SKILL.md と照らし合わせて評価を作り直し、この欄に反映します。

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

含まれるファイル(1)

  • SKILL.md6.0 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

<!-- Generated by community/.ai/render-guides.mjs; edit community/.agents/skills/duplicate-and-dead-code/SKILL.md -->

Duplicate and dead code

The exact copy-paste gate finds a copied text only. This skill finds one responsibility in two pieces of different code, and dead code. Each tool gives candidates, not a proof. Read each candidate before you act on it.

The tools

ToolWhat it findsUse
jscpd exact, --exit-code 1a copied text (Type-1)the gate of an area
jscpd --ignore-identifiers --kind renameda copy with renamed names (Type-2)burn-down
jscpd --similarity 0.9 --kind asttwo functions with one syntax tree (Type-3)the copy lint
jscpd --semantic --kind semantictwo functions that do one thing (Type-4)the copy lint
jscpd --compare <a>/ <b>/the functions of <a> with no counterpart in <b>a port or two implementations
accio locate '<question>' --mode semantic, accio context '<task>'the code of a behaviour or a taskthe owner check
accio trace <Name> --direction callers, accio references <Name>the callers and every use of a namethe owner check, dead code
accio unused --scope <dir>/declarations, bundle keys and image variants used nowheredead code

Without accio on the PATH, run ./community/tools/accio.cmd. Run jscpd only through ./community/tools/jscpd.cmd -c <config>. <config> is the .jscpd.json of the area, for example plugins/air/.jscpd.json. An area without a .jscpd.json runs the commands without -c and has no exact gate. Write each JSON report to a temporary directory of your session. The jscpd_test target of the area runs the gate too, for example //plugins/air:air-duplicate-code_test.

Before a plan: the owner check

Do this for each responsibility that the plan adds: a mapping, a policy, a parser, a cache, a lifecycle step.

  1. accio locate '<a full question about the behaviour>' --mode semantic --scope <area>/. On a miss, ask again in other words.
  2. accio context '<the task in words>' --scope <area>/. Name the task by the nouns of the domain, not by a role word such as "mapper".
  3. accio references <ResultType> --scope <area>/ --no-tests --files. A private function that builds the type is an owner too.
  4. For a V1 or V2 change, find the other version: accio files '<Prefix>V1*', accio files '<Prefix>V2*'.
  5. accio trace <Name> --direction callers for each candidate, then read it. A call site marked ? (:57?) fits more than one overload: read it.

The plan then has an Existing owners line. It names each owner and the decision: extend it, move it, or write new code with the reason why the owner does not fit. When the check finds nothing, the line names the queries.

Before a review: the copy lint

The copy lint is a report, not a gate. Run it after the exact gate of the area passes, when the area has one. Give the touched directories and the directories of their owners: the scan compares only the files under the paths it gets.

./community/tools/jscpd.cmd -c <config> --similarity 0.9 --kind ast --absolute \
  --reporters json --output <temp-dir>/ast <touched-dir>...
./community/tools/jscpd.cmd -c <config> --semantic --semantic-scope same --kind semantic \
  --semantic-same-threshold 0.9 --ignore '**/testSrc/**,**/test/**,**/tests/**,**/testFramework/**' \
  --absolute --reporters json --output <temp-dir>/semantic <touched-dir>...

Then keep the pairs that touch a file of the change. Run this from the repository root:

{ git diff --name-only <base>; git ls-files --others --exclude-standard; } | sed "s|^|$PWD/|" \
  | jq -R . | jq -s . > <temp-dir>/changed.json
jq -r --slurpfile c <temp-dir>/changed.json '.duplicates[]
  | select(.firstFile.name as $a | .secondFile.name as $b | $c[0] | index($a) or index($b))
  | "\(.similarity) \(.firstFile.name):\(.firstFile.start)-\(.firstFile.end) ~ \(.secondFile.name):\(.secondFile.start)-\(.secondFile.end)"' \
  <temp-dir>/ast/jscpd-report.json <temp-dir>/semantic/jscpd-report.json

Filter the report by file, not by kind. An --kind ast pair has "kind": "similar".

  • Do not use --changed or --baseline-from-ref. Each makes a git worktree of the base revision with 1.4 million files.
  • The first --semantic run on a machine needs --semantic-download (a model of 548 MB). The first run on a directory takes minutes. A later run takes below 1 s.
  • Read each pair at 0.90 or more. Below 0.80, most pairs are two functions of one shape.
  • A pair in one file whose two parts are one line apart is a table, not a copy.
  • A pair that the change did not touch is a lead. Report it and do not fix it.
  • A pair that you keep needs a reason in the review: two sides that no shared module can hold, or a wire DTO and its model.

Dead code

accio unused --scope <dir>/ --limit 1000 gives the candidates. Each candidate is a lead. The note of the answer explains each mark, and accio unused --help says what the scan leaves out and cannot see.

  • A (generated) icon field: delete its SVG and generate the icon class again with the icon-resources skill. First search the SVG file name over the whole repository. A SKILL.md can name it as an icon, and then the fix is an icon-robots.txt skip.
  • A (published) candidate is a published API. Keep it unless its owner decides otherwise.
  • An area can keep a guide of the candidates that stay, for example plugins/air/docs/guides/dead-code-guide.md. Read it before the triage, and add each candidate that you keep.

To delete a candidate, prove it with accio locate '<name>' without --scope. Then delete it, the tests that test only it, the imports that only it needed, and the KDoc links to it. Delete a dead key from the English bundle only. The translations under localization/ belong to the localization team. Run the tests of the area, and run accio unused again.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

actions

無料概要あり

IntelliJプラグインのAnActionと登録設定を実装・変更し、表示文言やアイコンの定義、非同期処理の起動方法を整えます。

  • IDEに新しいアクションを追加したいとき
  • アクションの登録やアイコンを変更したいとき
  • 表示名と説明文の定義を整理したいとき
JetBrains/intellij-community2.1万2026年10月29日 更新

bazel-test-migration

無料概要あり

IntelliJのJPSテストモジュールをBazelへ移行し、Bazelだけで起きる失敗を依存関係や実行環境から切り分ける手順を案内します。

  • JPSテストをBazelへ移行したいとき
  • Bazelだけで起きるテスト失敗を調べたいとき
  • テストの依存関係やデータ設定を確認したいとき
JetBrains/intellij-community2.1万2026年10月29日 更新

code-style

無料概要あり

IntelliJのKotlin・Javaコードを新規作成やレビューする際に、言語の選び方、書式、型の扱い、例外処理などのプロジェクト規約に沿って整えるスキルです。

  • IntelliJ規約に沿ってKotlinを書きたいとき
  • Javaコードをレビューしたいとき
  • 例外処理やsealed型の分岐を確認したいとき
JetBrains/intellij-community2.1万2026年10月29日 更新

commits

無料概要あり

IntelliJ向けの変更を適切な単位に分け、チケットの有無に応じた形式で、理由や判断も伝わるコミットメッセージを作成・修正するスキルです。

  • チケット付き変更のメッセージを作りたいとき
  • テストやドキュメントのコミットを整理したいとき
  • 既存のコミットメッセージを修正したいとき
JetBrains/intellij-community2.1万2026年10月29日 更新

compare-python-typecheckers

無料概要あり

Pythonコードの型推論や型エラーを複数の型チェッカーで比較し、各ツールの判定と診断内容をまとめたレポートを作成します。

  • 型推論の違いを比較したいとき
  • 型エラーになるか確かめたいとき
  • 複数チェッカーの診断を見比べたいとき
JetBrains/intellij-community2.1万2026年10月29日 更新

compose-ui-architecture

無料概要あり

Compose Desktopの画面で状態や副作用をどこに持たせるか整理し、表示と判断の境界、再利用部品やリストの設計を整えます。

  • 画面とプレゼンターの責務を分けたいとき
  • UI状態の置き場所を整理したいとき
  • Effectやコルーチンの使い方を見直したいとき
JetBrains/intellij-community2.1万2026年10月29日 更新

JetBrains のスキルをすべて見る

このスキルの問題を報告する