Skip to content
cccskills
FreePublished on GitHubEnglish overview

duplicate-and-dead-code

Finds code that performs the same responsibility in different forms, along with declarations and assets that appear unused. It helps check existing owners before planning changes and review duplication candidates, while leaving final decisions to a person.

OriginalShow the original description

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

JetBrains/intellij-community20,684 stars(GitHub 20,684 + cccskills 0)

Run score Not tested

See how to install

Good for

  • Check whether a planned behavior already has an owner
  • Look for similar functions in changed directories
  • Review candidates for unused declarations or assets

Overview

What it does

Before planning a change, this skill searches for existing code that may already perform the work you intend to add. It uses behavior and task context to find likely owners, then follows callers and references to check where that work is handled. During review, it runs copy lint to find functions with similar syntax or meaning and narrows the report to candidates related to changed files. It can also list potentially unused declarations and images and provide steps for checking them before removal.

When it helps

Use it to check whether a responsibility already has an owner before implementing it elsewhere, to review a change for duplication candidates, or to investigate potentially unused code and images. Results are leads, not proof; read the relevant code before deciding what to do.

Example requests

  • “Check whether existing code already handles the behavior I plan to add.”
  • “Review the changed directory for semantic duplication candidates.”
  • “Find potentially unused code in this scope.”

Notes

This skill uses accio and jscpd. If accio is not on PATH, use ./community/tools/accio.cmd; run jscpd through its specified wrapper. The first semantic analysis requires a 548 MB model.

This overview was written by AI (OpenAI Codex) from the public SKILL.md. Check the original below for the exact behavior.

Document check

AI checked the SKILL.md for operations that need care and for setup requirements. The score comes only from actually running the skill (hands-on test).

SafetyAre sending data, deleting files, and running commands disclosed?
AGoodIt requires reviewing candidates and proving them with an unscoped search before deletion.
Easy setupDoes it need few tools or API keys, and are they documented?
BPartly lackingIt names `accio`, `jscpd`, wrappers, and a 548 MB model, but not installation steps.

Not counted in the score. Rated by AI (OpenAI Codex) as of Oct 29, 2026. Treat it as a guide and read the original before installing.

Disagree? Request a re-evaluation

Tell us which point is wrong and why. No login needed. We will check it against the SKILL.md, redo the evaluation, and show the result here.

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

Files included (1)

  • SKILL.md6.0 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

<!-- 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.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

actions

FreeSummary

Implement or update IntelliJ `AnAction` classes and their `plugin.xml` registrations. Keep labels and descriptions in message bundles, configure optional icons, and launch suspending work through the event coroutine scope so synchronous action handling does not freeze the IDE.

  • Adding a new IntelliJ action
  • Updating an action's registration or icon
  • Moving action labels into a message bundle
JetBrains/intellij-community20.7KUpdated Oct 29, 2026

Move IntelliJ JPS test modules to Bazel and diagnose failures that occur only under Bazel. The guide helps trace missing dependencies, plugins, test data, and runfiles, then verify the generated target and migrated tests.

  • Migrating a JPS test module to Bazel
  • Diagnosing a test failure that occurs only in Bazel
  • Checking Bazel dependencies and test data wiring
JetBrains/intellij-community20.7KUpdated Oct 29, 2026

code-style

FreeSummary

Write or review Kotlin and Java code in line with IntelliJ project conventions. The guidance covers language choice, formatting, sealed types, threading annotations, and safe handling of control flow exceptions so changes fit the surrounding codebase.

  • Writing a new Kotlin file that follows IntelliJ conventions
  • Reviewing Java code and checking its style guidance
  • Checking formatting, sealed-type handling, or exception handling
JetBrains/intellij-community20.7KUpdated Oct 29, 2026

commits

FreeSummary

Create, amend, or rename IntelliJ commits with messages that follow the project’s ticket and label formats. Keep each commit focused, explain the reason and decision in the body when needed, and pass the message safely through the shell or PowerShell.

  • Writing a message for a change linked to a YouTrack ticket
  • Preparing a commit message for tests, cleanup, or documentation
  • Amending or renaming an existing IntelliJ commit
JetBrains/intellij-community20.7KUpdated Oct 29, 2026

Compare how Python type checkers interpret a code snippet or file. The script runs selected tools, including ty, pyrefly, basedpyright, mypy, and zuban, then produces a Markdown report with verdicts, timings, and each checker's diagnostic output.

  • Comparing type inference for a Python snippet
  • Checking whether a Python expression should be a type error
  • Reviewing differences among Python type checkers
JetBrains/intellij-community20.7KUpdated Oct 29, 2026

Shape Compose Desktop UI code by keeping composables focused on rendering and placing application decisions in presenters or coordinators. Get guidance on state ownership, effects, reusable component APIs, lazy-list keys, animation, and performance for individual UI changes.

  • Separating screen rendering from application decisions
  • Choosing which UI state belongs in composition
  • Structuring effects and coroutine work
JetBrains/intellij-community20.7KUpdated Oct 29, 2026

See all skills by JetBrains

Report a problem with this skill