Source: the EL4CTEO/shrink-anything README, surfaced by a practitioner post the same day. MIT licensed, npm and crates.io, early repo. Benchmark numbers are the project's own.
The problem it names
Coding agents write code faster than anyone deletes it. Functions nothing calls, files nothing imports, packages nothing uses, assets nothing shows: the agent reads all of it on the next task, CI builds it, users download it. The framing that makes this more than a lint rule is the token one — every line removed is a line the agent stops reading. The README claims 46% fewer tokens to read on its demo app.
The mechanism
One command: shrink-anything go --agent claude -- npm test, where the part after -- is any command of yours that fails when the app is broken. Or step by step: scan (changes nothing), cut -- <check>, task --agent <cli> for the judgment calls, weigh dist, verify, undo, report, doctor.
The safety design is the interesting part, and it is the same shape as record-and-replay porting tools:
Your check is the oracle. A cut stays only if your command exits 0 and at least as many tests run as before — that second condition is what stops a deletion from silently removing test cases. A check that already fails is refused, because it can prove nothing.
Batch, then bisect. Cuts go in as a batch; if the check fails, the batch is split until the single breaking cut is found and put back alone. Every state left on disk has passed.
Parse before test. Each edited file goes through the language's own parser before the check runs, so syntax damage fails fast rather than as a confusing test error.
Tests are never edited, and
undorestores files byte for byte.What can't be proven isn't cut. Public methods, library exports, subclasses a framework may register, files in convention-loaded folders go to the agent with a reason, or sit behind
--aggressive.
The README's own demo is the honest case: a test reaches a function through a name read from a data file, nothing in the code mentions it, the cut broke the test, and that one cut was put back.
Detection by counting names, not call graphs
| What | How it decides | Scope |
|---|---|---|
| Dead code | every mention of the name is inside its own definition; any other mention anywhere — another file, a string, a template, a config — keeps it | 19 languages |
| Dead files | no other file names it | Python, JS/TS, PHP, Ruby, Dart, Lua |
| Unused dependencies | nothing imports it or runs its commands | npm, pnpm, yarn, bun, Cargo, pip, Go modules |
| Dead weight | an image, font or sound no code, config or README names; duplicate files | any project |
| Duplicates | the same code twice, however named or laid out | 19 languages, merged by the agent |
The design choice: counting mentions instead of building a call graph. A count can only miss dead code, never invent it, and it behaves the same in every language. Every text file — HTML, Vue, Svelte, YAML, SQL, templates — is read for mentions, so a function used only from a template survives. Adding a language is one table entry describing comments, strings, block ends and definitions: about twenty lines.
This is a deliberate trade of recall for soundness, which is the right direction when the action is deletion. It also means the tool is weakest exactly where dynamic dispatch is heaviest — reflection, string-built names, dependency-injection containers — and that is where the test gate is doing all the work.
Reported results
| Project | Before | After |
|---|---|---|
| TypeScript cart | 106 lines, 5 files, 3 deps | 58 lines, 3 files, 1 dep (−45%) |
| Python shop | 142 lines, 8 files | 86 lines, 7 files (−39%) |
| Go store | 89 lines | 55 lines (−38%) |
| Static site build output | 913 KB | 398 KB (−56%) |
These are demo projects with planted dead code, which the README says, and it adds that real projects should expect less per run and more over time. Treat them as a demonstration that the loop works, not as an expected reduction.
Failure modes to plan for
A weak test suite silently authorizes deletion. The proof is exactly as strong as the check. The README is explicit: a project with no tests gets a scan, not a cut you should trust. Coverage, not line count, is the gate on how aggressively to run this.
Flaky tests are the dangerous case, worse than failing ones: a flake during a batch sends the bisection after the wrong cut, and a flake on a passing cut keeps something that should have gone back. Run it on a green, stable suite.
Bisection cost. Splitting a failing batch means re-running the suite repeatedly; on a slow suite the loop is expensive, which argues for a fast subset as the check and the full suite as the final
verify.Assets served as-is. Files under
public/orstatic/may be linked from outside the repo, so they need--aggressive— the one category where the test gate cannot see the dependency at all.Library versus app. In a library, public names belong to users. The tool guesses from a published
package.json, alib.rs, the absence ofpackage main, and says what it guessed; override with--libor--app. Getting this wrong in a published library is an API break that no test catches.The agent-assisted path is a different risk class.
task --agenthands duplicates and public methods to a model and keeps its work only if the check agrees. The check is still the gate, but the diff is now a model's refactor rather than a deletion.
Review checklist before running it on a real repo
Is the suite green and non-flaky right now? Run it twice.
Does the check fail when the app is actually broken — not just when it fails to compile?
Is this a library? If so, is
--libset, and are public exports the contract you think they are?Start with
scanand read the list. Anything surprising on it is a sign the mention-counting missed a dynamic path.Keep
--aggressiveoff for the first pass, and treat its output as a reviewed list rather than a commit.Review the resulting diff as a human change. "Tests passed" is the floor, not the review.
Integration
A Claude Code plugin, a built-in MCP server exposing eight tools (shrink_scan, shrink_cut, shrink_task, shrink_verify, shrink_undo, shrink_report, shrink_weigh, shrink_status), and a skill that teaches any agent the loop. --agent accepts any command that reads a prompt on stdin, and without it the task file is handed to whatever you use — a reasonable hedge against tying a build step to one vendor's CLI.
Related
R217 — the same author's earlier tool, which ports hot functions to Rust and keeps the port only if replayed real calls agree: identical structure, opposite direction (make it faster rather than make it smaller), same insistence that a recorded check decides.
R124 — porting an app unit by unit behind a recorded-behavior gate; the shared idea is that an automated edit is acceptable only when something independent of the edit can refuse it.
R220 — accepting agent code on evidence rather than line-by-line review; a deletion tool is the cleanest case of that argument, and also where "the check passed" is most tempting to over-trust.
R037 — comprehension debt and generated maps: this attacks the same debt by removing what has to be comprehended rather than describing it.