Why dry-lint · First-run tutorial · How CI runs it · Documentation · Related tools
Coding agents rarely copy and paste. They write new code for a job the codebase already does: a second
truncate, another pagination loop, a fresh Mongo query helper, each slightly different. Copy-paste detectors
(pylint's duplicate-code, jscpd) look for repeated lines, so they miss this. Every rewrite is also a chance to
drift: one version rounds, the other truncates, and callers get different answers to the same question.
Set it up with your coding agent. Give Claude Code, Codex, Cursor or any coding agent in your repository this one prompt:
Set up dry-lint in this repository. Fetch https://dry-lint.readthedocs.io/en/latest/agent-setup.md and follow it.
The agent reads how your repository works (default branch, action pinning, pull request template, existing
secrets), writes the settings, accepts today's duplicates in a baseline, adds the workflows and hooks, proves the
check catches a copied function, and opens a pull request. Repository settings and secrets stay with you: it stops
and asks you to add a TypeSafe API key secret if there is none, to make the dry-lint check required, and to add a
token for the weekly cleanup pull request. To do it by hand, follow the first-run tutorial;
how CI runs dry-lint explains the moving parts.
dry-lint finds functions in a pull request that look like they re-implement something that already exists. A judge decides whether each pair really is one concept, and the result goes back as PR annotations and one comment (see one):
src/widgets/caption.py:1: preview_caption_text looks like src/text.py::shorten_text (drifted)
judge 0.91; the two already behave differently; call the existing function;
similarity 0.71; if they are different concepts, add
`# dry-lint: distinct-from src/text.py::shorten_text`;
if they are one concept copied on purpose, add a [[patterns]] entry with a reason
You bring your own keys. dry-lint never provides API keys, models or judge execution: judges run on the credentials your repository passes in, at your cost, and without any it only lists look-alikes (design).
Quick start
Python, TypeScript and TSX work out of the box. TypeScript repositories need no Python project, bun install,
Node or build step: dry-lint installs its own tools and parses source without executing your code
(TypeScript and Bun covers monorepos).
Try it locally, without an API key
Install uv, open a terminal in your Git repository, and run:
uvx --no-config --python 3.13 dry-lint scan --judge none --limit 30
uv downloads Python and runs dry-lint in its own environment, so nothing is added to your project. This lists
look-alikes without calling a model or failing on findings. To inspect just your branch, replace
scan --judge none --limit 30 with check --judge none --base origin/main (use your default branch's name).
For a permanent dry-lint command, then open a new terminal:
uv tool install --no-config --python 3.13 dry-lint
uv tool update-shell
Add it to GitHub Actions
Save this as .github/workflows/dry-lint.yml. It works without a secret. For judged findings, store your
TypeSafe API key as a repository or organization secret and pass it to typesafe-api-key:. The secret can have any
name; this example calls it TYPESAFE_AI_API_KEY (check gh secret list and your organization's secrets first).
name: dry-lint
on: [pull_request]
permissions:
contents: read
pull-requests: write
concurrency:
group: dry-lint-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
dry-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 1
- uses: gigaverse-app/dry-lint@v1
with:
typesafe-api-key: ${{ secrets.TYPESAFE_AI_API_KEY }}
The action installs its own Python and dependencies; your project's Python version, uv configuration and
virtual environment do not change, and no setup-python, pip install or build step is needed. It annotates
the changed functions, keeps one sticky PR comment up to date and caches verdicts between runs. The comment
links both functions at the analyzed commit, shows the review workload, and folds evidence and pair-specific
suppression instructions under each summary. A clean pull request gets a green sticky with what was checked
(comment-on-clean: "false" to opt out), and every sticky keeps a running account of what each push cost and
each duplicate kept out (the ledger).
A reported duplicate fails the check at the preset's threshold (98% of them are real duplicates with
jev+opus); fail-at raises or lowers it, and the dry-lint: override label lets one through. That precision
is for people. A coding agent can check findings itself, so for agents a cheap judge at a lower threshold catches
more for less (who reads the findings). Pull
requests from forks get no secrets, so the default mode: auto runs dry-lint as two jobs for them: detect on the pull
request, and judge in a workflow_run job that keeps the key away from pull
request code (design). For default-branch runs, rechecks when override
labels change, and a fork job named dry-lint detect so it can never satisfy a required dry-lint check, use
the extended workflow; the action guide
lists every option.
pre-commit
default_install_hook_types: [pre-commit, prepare-commit-msg]
repos:
- repo: https://github.com/gigaverse-app/dry-lint
rev: v1
hooks:
- id: dry-lint
- id: dry-lint-trailers # optional: the pull request's comment counts what the hook kept out
The hook checks the staged Python, JavaScript and TypeScript for the coding agent making the commit. An agent checks
each finding itself, then reuses the existing function or records why the two differ, so the hook judges for
recall: preset agent, Jev on every pair, blocking from 0.6. That keeps 92% to 100% recall on four gold sets, with
about one finding in two real, for about $0.0002 a commit. Set TYPESAFE_AI_API_KEY in the environment or in an
untracked .env; nothing else is needed. The key is needed only when the staged change has a pair to judge, so
pre-commit run --all-files in tox, a CI lint job or pre-commit.ci, where nothing is staged, passes without one. args: [--preset, agent+haiku] adds Claude Haiku on Jev's uncertain
scores, for higher precision and some lost recall on TypeScript; args: [--preset, auto] gives a person committing
by hand the same precision-first judging as CI
(who reads the findings).
Once the repository has a baseline, the hook must judge with the baseline's preset, because a baseline refuses any
other: args: [--preset, jev, --baseline, .dry-lint/baseline.json], naming the preset in .dry-lint.toml
(one preset everywhere).
rev: v1 follows dry-lint's 1.x releases, but pre-commit caches the first install and warns that v1 is a mutable
reference. To pick up a newer release, run pre-commit clean && pre-commit install --install-hooks.
A blocked commit names the pair. Fix it by reusing the existing function, or record an intentional difference with
# dry-lint: distinct-from path::name or dry-lint feedback dismiss PAIR --reason .... For wider exploration with a
persistent campaign budget, see balanced.
A duplicate the hook blocks and the agent fixes never reaches a push, so CI alone would never count it. The hook
remembers what it blocked; dry-lint-trailers writes what was then fixed or dismissed into the commit message,
Dry-Lint-Kept-Out: ab7719f1ec3f9b70 repository_counter_name ≈ counter_key (3 lines), and the pull request's
sticky, the repository's ledger and the global counter count it
(the ledger). Run pre-commit install once more after adding it.
Commands
| Command | Does |
|---|---|
check [--base REF | --staged] |
detect, judge and report the functions a change touched (base: origin/HEAD) |
scan [--limit N] [--refresh] [--repo OWNER/NAME=PATH ...] |
the repository's backlog, or cross-repository pairs from a combined workspace |
sweep [--init | --update] |
audit the configured repository; explicitly initialize or shrink its accepted backlog and README progress |
config |
which judges, thresholds and budget would run, and what they cost |
explain A B |
why a pair is, or is not, reported |
detect --out candidates.json |
CI job 1: propose pairs; no judge, no secrets, no store |
judge --candidates candidates.json |
CI job 2: judge them, store the verdicts, report |
report --from report.json --format F |
render a report as text, github, markdown, json, sarif or check-run |
bench --gold gold.jsonl [--comparer] |
measure the judge, or the comparer, on a gold set |
bench --replay N [--preset P] [--fail-at X] [--label K] |
what check would have done on each of the last N commits of the default branch; with --label, what it would have caught, missed and blocked wrongly |
--report report.json and --output comment.md write the report and the PR comment from any command that
judges. Without a judge, dry-lint lists the candidate pairs and never fails. With TYPESAFE_AI_API_KEY set, Jev
judges them; to use another judge, pass --judge command --judge-command "your-llm-cli"
(judges).
| To | Read |
|---|---|
| Fully adopt hooks, PR/README stickies and a shrinking backlog | Adoption playbook |
| Set it up with an agent | the one prompt above; the agent follows skills/dry-lint/SKILL.md |
| See the PR comment before installing | Example report |
| Put judged findings on pull requests | GitHub Action setup |
| Add structural matching | The optional Dryer comparer (compared on gigaverse-backend) |
| Find copies across related repositories | Workspace scans and shared ownership |
| Avoid cloning peer repositories in CI | Versioned function indexes |
| Audit existing duplication, shrink its baseline and show cleanup in your README | Repository sweeps and ratchets |
How it works
dry-lint is a fixed core (the pipeline, the file formats, the verdict store's rules and the reports) with four plugin slots: how functions are found, how they are compared, how a pair is judged, and where verdicts are kept (design, plugins).
-
Detector (local, no model, about 4.5 s on 10,000 functions). It finds the functions the diff touched. The comparer proposes each one's nearest look-alikes in other files; the built-in one is a TF-IDF fingerprint of what a function does: the names it calls, the attributes it touches, the words in its identifiers, its loops,
tryblocks andawaits. One shared policy consumes language-adapter facts: Python special methods, recognized forwarding wrappers, a function that calls the other (resolved within the file), declared patterns and inlinedistinct-from. Inheritance alone does not exclude repeated logic. -
Judge (separate and pluggable). Jev answers three typed questions per pair in about 0.3 s:
- Is it one concept?
- Do the two already behave differently?
- Which side should own the single implementation?
Any LLM CLI, or any program, can be the judge instead, and a second judge can take the scores the first is least sure about.
-
Verdict store (a cache, not a reviewed file). Each verdict is kept per pair with a structure hash of each function, which comments and formatting do not change. Python also normalizes local renames; TypeScript conservatively re-judges them to preserve binding semantics. Most cosmetic pushes cost zero judge calls.
Research on profiles, judging budgets and discovery across repeated runs is in Discovery over time and the four-cent discovery trial.
When it is right not to merge them
Some look-alikes are deliberate. Silence them where the decision belongs:
- Inline: put
# dry-lint: distinct-from src/text.py::shorten_textin the new function. The reason sits next to the code it explains, and moves or disappears with it. - A whole function: put
# dry-lint: ignorein it (generated code, a deliberate copy). It is left out of every pair, on either side. - Families, and copies kept on purpose: declare a pattern in
.dry-lint.toml, for deliberate per-resource instances or for one concept a project keeps in two places (say, a module that vendors a helper so it imports nothing):
# .dry-lint.toml
exclude = ["*/tests/*", "tests/*", "*/migrations/*"]
[[patterns]]
members = "src/*/api/*_api.py::create_router"
reason = "one router per resource"
[[patterns]]
members = ["pkg/funcutils.py::_indent", "pkg/strutils.py::indent"]
reason = "funcutils vendors strutils.indent so it imports nothing"
A pair matches a pattern when both of its functions do: each side's path::Qualified.name is compared with
fnmatch against members, one glob or a list. Keep globs narrow, since a broad one silences real duplicates too,
and check each with dry-lint explain A B, which prints rule: declared pattern: <reason> for a match. Do not
put copies kept on purpose in the baseline instead: a baseline entry accepts both functions exactly as they are, so
the day someone fixes a bug in both copies, the changed pair fails as new debt. Machine "not a duplicate" verdicts
stay in the store and do not need to be checked in.
Measured
On 600 gigaverse-ai pull requests, against a 250-pair gold set labelled blind by three vendors' models (docs/benchmark.md):
| Changed functions per commit | median 1, p90 13 |
| Judge calls per PR (uncached) | 2.5 |
| Findings per PR at the default threshold | about 0.2 |
Jev reuse-v2: ranking quality |
AUC 0.97 |
preset jev+opus, failing at 0.55, within $0.04 a pull request |
98% precision, 85% recall; about $0.005 per pull request on average |
preset jev+sonnet, failing at 0.7 |
97% precision, 84% recall; about $0.0035 per pull request |
preset jev+codex (ChatGPT subscription), failing at 0.7 |
96% precision, 85% recall; no per-call cost |
preset jev, failing at 0.8 |
94% precision, 73% recall; 15% of pull requests fail |
| Known duplicates found and scored ≥ 0.8 | 11 of 13 |
| Verdict store for the whole repository | about 1,900 pairs, 0.75 MB |
The spending ledger, checked against a model
The campaign ledger that admits and settles paid judging is also a Quint model. CI replays generated histories against the real ledger and requires every deliberately broken ledger to be caught (campaign contract). The block below is the latest complete run, checked by pytest-quint-connect on every change that runs the contract.
✅ 1 contract · 25/25 cases · 4/4 mutants caught · 20 histories
| Cases passed | Mutants caught | ||
|---|---|---|---|
| ✅ | campaign campaign/test_campaign_contract.py::test_campaign20 histories (4 witnesses, 16 samples, seed 11) · every action covered · Quint 0.33.1 |
25/25 | 4/4 |
🐞 1 real bug found by this contract
| Contract | Fixed in | Regression test | |
|---|---|---|---|
campaign |
settle() accepted an already settled reservation: an answered attempt could turn failed and protected exploration credit was refunded again found by witness secondSettleIsRefusedTest · mutant double-settle reintroduces it: 13 of 20 histories diverge |
gigaverse-app/dry-lint#157 | tests/test_discovery.py::test_a_reservation_settles_exactly_once |
🧪 4 mutants (planted fake bugs), all caught
| Contract | Mutant | Caught by | At | |
|---|---|---|---|---|
campaign |
double-settle |
settle() accepts an already settled reservation and refunds its credit again reintroduces a real bug found earlier |
witness-secondSettleIsRefusedTest |
state 4, after settle(actual=0, cand='', cost=0, idx=0, kind='', success=False) |
campaign |
credit-per-call |
every advance() mints exploration credit, not only a new revision's first | witness-creditMintedOncePerRevisionTest |
state 2, after advance(actual=0, cand='', cost=0, idx=0, kind='', success=False) |
campaign |
residual-skips-pass |
residual reserve() does not wait for the revision's protected attempts to be answered | witness-residualWaitsForTheProtectedPassTest |
state 2, after reserve(actual=0, cand='c2', cost=1, idx=0, kind='residual', success=False) |
campaign |
no-dedupe |
reserve() admits the same pair twice on one revision | witness-residualWaitsForTheProtectedPassTest |
state 5, after reserve(actual=0, cand='c2', cost=1, idx=0, kind='residual', success=False) |
What campaign says
Actions, and the code each one drives:
init: a new CampaignStore on an empty ledgerpush: a new CampaignStore for the next immutable revision on the same ledgeradvance: CampaignStore.advancereserve: CampaignStore.reservereserveFamily: CampaignStore.reserve_familysettle: CampaignStore.settleinspect: read only
Invariant withinBudget, checked while sampling histories.
Witnesses, scenarios replayed exactly as written: creditMintedOncePerRevisionTest, secondSettleIsRefusedTest, residualWaitsForTheProtectedPassTest, familyNeedsAnEnteredRevisionTest.
Bounds: seed 11 · max_samples 300 · max_steps 10 · n_traces 16.
Witness creditMintedOncePerRevisionTest, step by step: the observation the model starts from, then what it expects each action to change.
| State | Action | Model expects |
|---|---|---|
0 |
init(actual=0, cand='', cost=0, idx=0, kind='', success=False) |
{ attempts: [], credit: 0, outcome: NoOutcome, rev: 0, revisions: 0 } |
1 |
advance(actual=0, cand='', cost=0, idx=0, kind='', success=False) |
credit: 0 → 2revisions: 0 → 1 |
2 |
advance(actual=0, cand='', cost=0, idx=0, kind='', success=False) |
unchanged |
3 |
push(actual=0, cand='', cost=0, idx=0, kind='', success=False) |
rev: 0 → 1 |
4 |
advance(actual=0, cand='', cost=0, idx=0, kind='', success=False) |
credit: 2 → 4revisions: 1 → 2 |
5 |
inspect(actual=0, cand='', cost=0, idx=0, kind='', success=False) |
unchanged |
Generated by pytest-quint-connect from contract receipts; what a passing run proves.
Settings
Settings live in .dry-lint.toml at the repository root, as top-level keys with tables such as [budget] and
[[patterns]]. The same keys also work under [tool.dry-lint] in pyproject.toml ([tool.dry-lint.budget],
[[tool.dry-lint.patterns]]); when both files exist, .dry-lint.toml wins. Judges and thresholds come from the
preset (docs/judges.md); anything set here wins over it. dry-lint config prints the result,
including how many source files the scope covers:
| Setting | Default | |
|---|---|---|
include / exclude |
everything / tests, migrations, scripts | fnmatch over tracked paths; setting exclude replaces the defaults |
patterns |
none | [[patterns]] entries with members (a glob or a list) and a reason: deliberate look-alikes |
neighbours |
3 | candidates per changed function |
preset |
"auto" |
judges and their measured thresholds together: jev+opus, jev+claude-code, jev+sonnet, jev+claude-code-sonnet, jev+codex, sonnet, claude-code, jev, none; auto picks by the credentials present |
drop_below / report_at / fail_at |
from the preset | separate below, reported at, failing at (--fail-at overrides it); jev+opus is 0.5 / 0.55 / 0.55, with Jev's answers that Opus did not see held to Jev's 0.8 |
drift_at |
0.8 | a duplicate whose behaves_differently reaches this is drifted |
budget |
{ usd = 0.04, subscription_calls = 20 } |
most judging spends on a pull request across all its pushes, at list price, subscriptions included (--budget-usd); and calls per run to subscription judges |
prices |
built-in table | USD per million input and output tokens, by model |
reopen_margin |
0.05 | for a comparer that permits similarity reuse (no built-in one does), how much closer a "separate" pair must get before it is judged again |
max_findings |
10 | rows in the PR comment |
extractors |
["python", "typescript"] |
.py, .ts, .tsx, .mts, .cts |
comparer |
"tfidf" |
options min_similarity (0.5), min_similarity_small (0.3) under small_function_lines (6) |
judge / escalate |
from the preset | name your own judge to run it alone, or escalate = "none" to turn the second judge off |
store |
"dir" |
.git/dry-lint/verdicts/, or { use = "s3", uri = "s3://bucket/prefix" } |
A plugin slot takes a name, or a table with use and the plugin's options:
comparer = { use = "tfidf", min_similarity = 0.45 }.
The counter
The sign at the top counts every duplicate dry-lint has kept out of a codebase: a duplicate a pull request introduced, dry-lint reported, and a later push removed before merging. A rewrite is one whose structure differs from the function it duplicates, so a copy-paste checker would not see it; a drifted copy already behaved differently; a re-check skipped is a verdict the store already held. Actions from November 2026 on measure these; until a pull request they measured has merged, the sign shows them as "–", never as zero.
When a pull request merges, the action's run on the default branch sends its counts to a
Cloudflare Worker: duplicates kept out (how many had drifted, how many were rewrites, and their lines),
caught and dismissed, pushes, functions checked, look-alikes compared, verdicts reused, judgments, judging spend
and the dry-lint version. No code, names, paths or people are sent. The repository is pseudonymous: it is sent
as its counter key, the SHA-256 of its numeric GitHub id, which ties its pull requests together but which its name
does not lead to; a private repository's id is visible only to people who can see the repository. Each pull
request is counted once. Opt out with share-totals: "false".
Separately, a repository can opt in to dry-lint's benchmark with share-goldens: "true": each merged pull
request's settled pairs (duplicates kept out, pairs dismissed after being reported) are kept as pointers in a
dry-lint-goldens artifact in its own repository, and collected only from public repositories registered in
docs/goldens/adopters.toml. See sharing goldens.
A repository whose audit keeps a README block gets its sign
there automatically, beside the old duplicates it has cleaned up and still has. To show it anywhere else, take its counter key from the
log of a dry-lint run on your default branch
(dry-lint: this repository's counter key is ...). name only labels the sign; the counter never looks a name up:
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://dry-lint-counter.gigaverse-oss.workers.dev/v1/sign.svg?theme=dark&key=KEY&name=OWNER/NAME">
<img alt="Duplicates dry-lint kept out of OWNER/NAME" src="https://dry-lint-counter.gigaverse-oss.workers.dev/v1/sign.svg?key=KEY&name=OWNER/NAME" width="100%">
</picture>
or a badge, with metric=kept-out, drifted, lines, pulls, functions or repositories:

Lint
Lint is what is left behind when you dry things. It carries a hair dryer for blowing duplicated code away.
uv run --with pillow python scripts/make_assets.py rebuilds the avatar, the mark, the banners and the README
hero from docs/assets/lint.png.
License
Apache 2.0. See CONTRIBUTING.md to work on dry-lint itself.
Metadata
Release files for dry-lint 1.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dry_lint-1.9.0.tar.gz | 26.5 MB | With provenance | Details for dry_lint-1.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dry_lint-1.9.0-py3-none-any.whl | Python 3 | none | any | Details for dry_lint-1.9.0-py3-none-any.whl |
Total release size: 26.7 MB
Release files / dry_lint-1.9.0.tar.gz
| Download URL | dry_lint-1.9.0.tar.gz |
|---|---|
| Size | 26.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44f0794261733d64e23adf5a3b6c7df4a3413bdb5a0abfac8c1dba68ddc67bc1
|
|
BLAKE2b-256 checksum How to use checksums |
5a5d5261a7eb91ea8fe178a17134738c5a62658cace6217689cd97cc906c6e00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logRelease files / dry_lint-1.9.0-py3-none-any.whl
| Download URL | dry_lint-1.9.0-py3-none-any.whl |
|---|---|
| Size | 239.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cfdcfcaa000b09dece2ae0e5ed13da051cdc12b57e22edf2e5d49dcc4db20c8a
|
|
BLAKE2b-256 checksum How to use checksums |
8044849e03d6cc4e3cfccf7bd98d566ed648df0e6f93939d992d8f5e5a6da72b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logSecurity for dry-lint 1.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for dry_lint-1.9.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.