/ever-better:ever-better-dryfrom ever-better
Turns jscpd-found duplication into shared functions and knip-found dead code into deletions. Judges which clones are knowledge worth extracting vs coincidence to leave alone.
Ships in ever-better. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Lint sees inside a file. This is for what it cannot see: the same logic written twice in different files, and code nobody calls at all.
This is the sweep, not the first pass. The drain already deletes a copy at the cheapest possible
moment — while the second one is being written (ever-better-drain, step 6d). What should reach
this phase is the duplication no single rule fix could see: clones across modules, and the shared
layer they imply. If a drain has run and jscpd still reports a great deal, that is worth saying out
loud rather than quietly extracting — it usually means the copies predate any of this work.
Both scans in a bootstrapped repo are report-only, and that is a rule rather than a stage:
A check that fails on something the author did not write is what teaches a team to reach for ignore comments. So the scans inform this skill, and the ratchet stays with ESLint, which can point precisely at new code.
The per-PR view comes from SARIF into GitHub Code Scanning, which does diff against the base —
that is what the generated duplication-scan workflow uploads.
npx --yes jscpd@4 . --format "typescript,javascript" \
--ignore "**/node_modules/**,**/dist/**,**/*.d.ts" \
--reporters console,html --output report --blame
--blame attributes each clone, html gives a browsable report. No --threshold — you are
reading, not gating.
Read the breakdown per language. An overall 3% can hide 22% in one format, and averaging them tells you nothing about either.
This is the judgment the tool cannot make. One question settles most of it:
If the requirement changed, would I have to edit both copies?
push are the same
shape, not the same knowledge. Extracting them couples things that have no reason to change
together, and the abstraction that results is harder to read than the repetition was.Structurally-similar adapters — one per external service, one per platform — are usually the second kind. Forcing them into a shared abstraction raises complexity while the duplication metric falls, which is the metric winning over the code.
Take the parameters that actually vary. If the extracted function needs a flag argument to pick between two behaviours, you extracted the wrong thing — that flag is the difference the two callers exist to express.
Give the extracted function a name that says what it decides, not where it came from. formatCell,
not sharedHelper2.
The extraction gets a test, and it is cheap to write because you just made it pure. That is usually the real payoff: the duplicated code was untested in both places.
<pm> lint && <pm> typecheck && <pm> test
npx ever-better check
One extraction per commit, naming both call sites. A reviewer needs to see that the two really were the same.
An extraction with nowhere to go ends up beside one of its two callers, which is how the third caller misses it. A repository that is going to stay DRY needs a standard module, and it has rules:
text, time, money, paths. A file
called utils.ts, helpers.ts or common.ts is a drawer: nobody can predict what is in it, so
nobody looks, so the function gets written again — and the drawer is the one file every module
imports, which makes it the hardest thing in the repo to change.Reach for the platform before writing one at all. node:util, node:path, Intl, structuredClone
and Array.prototype.at have all quietly replaced a package someone still depends on — and a
built-in cannot go unmaintained.
Removing duplication is the second-best outcome. The best is the helper being found before the second one is written:
npx ever-better catalog
It writes docs/shared-helpers.md — every exported function, grouped by directory, with the first
sentence of its doc comment. Point the repository's CLAUDE.md at it, or it will not be read
before the next helper is written, and generating it will have achieved nothing.
This is the gap between the two scans. A linter sees inside one file. Duplication detection only notices copies once they are textually similar — and two independent implementations of the same idea rarely are. Nothing else reports the same function under a sixth name.
Regenerate it after a refactor rather than editing it; it is derived, and a stale catalogue is worse than none because it sends the reader looking for something that moved.
<pm> knip
Three kinds, and they are not equally trustworthy:
entry in knip.json rather than deleting it.An export used only inside its own module is not dead — stop exporting it. That is the fix, not deletion, and it shrinks the public surface at the same time.
Keep the inventory at zero once you get there. An empty inventory is what makes the next report readable: with nothing in it, "everything knip lists" and "what this PR orphaned" are the same list.
Open one rather than guessing when:
Say which clones, what you would extract, where you would put it, and what it would cost. Then move on to the next one instead of waiting.
npx ever-better log --kind deferred "3 clones between server/ and web/; extracting crosses the package boundary — #47"
A clone you decided to leave needs the entry more than one you extracted. The extraction is in the diff; the judgement that two similar blocks are coincidence rather than one idea is visible nowhere else, and the next run will otherwise re-open the same question and reach a different answer.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub isamu/ever-better --plugin ever-better8 skills in this plugin
/ever-betterEntry point for making a repository's quality only go up. Diagnoses what tooling is missing, explains what each gap costs, and routes to the skill that closes it. Use when the user says "この repo の品質を上げたい", "lint を入れたい", "リファクタリングを始めたい", "technical debt", "where do I start with this codebase", or asks what ever-better would do here./ever-better-bootstrapever-better bootstrapInstall the quality tooling a repository is missing and review the generated config before anything is enforced. Use after `ever-better diagnose` reports gaps in the bootstrap phase, or when the user says "lint を入れて", "eslint 設定して", "set up linting and tests here", "TypeScript にしたい". Ends at the point where the baseline can be frozen — it never freezes./ever-better-drainever-better drainWork a frozen backlog down one rule at a time — fix the violations, extract the pure function that makes a fix testable, write the test, prune the ceiling, commit. Automates everything it can and opens a GitHub issue only for a refactor that genuinely needs the owner's judgment. Use after `ever-better freeze`, or when the user says "warn を減らして", "backlog を潰して", "リファクタリングして", "drain the baseline", "テストを増やして"./ever-better-freezeever-better freezePin a repository's current lint violations as a ceiling that can only fall, and wire CI to enforce it. Use after `ever-better-bootstrap`, or when the user says "ベースラインを固定して", "freeze the baseline", "既存のエラーは許して新しいのだけ止めたい", "grandfather the existing violations". Also covers reclaiming the ceiling with prune after a fix./ever-better-migrateever-better migrateMove a JavaScript repository to TypeScript in one pass — rename everything, get it compiling, and let the lint fallout land in the ratchet instead of blocking the migration. Use when `diagnose` reports "No TypeScript", or the user says "TypeScript にしたい", "型を入れたい", "migrate this to TypeScript", "ts化して". Not for adding types to a repo that is already TypeScript — that is the drain skill's type tier./ever-better-prepareever-better prepareCheck that the agent instructions this process depends on actually exist before running it — the user's global CLAUDE.md and the repository's own. Adds only the conventions ever-better assumes, and reports which were already there. Use before `ever-better-run` on a repo for the first time, or when the user says "CLAUDE.md を整えて", "規約を追加して", "set up the conventions", or when a run produced inconsistent work across sessions.Other plugins' skills for the same job