{"slug": "shrink-anything-finds-it-deletes-it-and-runs-your-own-tests-after-every-cut", "title": "Shrink-anything finds it, deletes it, and runs your own tests after every cut", "summary": "A new open-source tool, shrink-anything, deletes dead code, files, dependencies and duplicate assets and keeps each cut only if the project's own test command still exits 0 with at least as many tests running as before, restoring any breaking cut byte for byte. The tool counts name mentions rather than building a call graph, covers dead code in 19 languages, dead files in Python, JS/TS, PHP, Ruby, Dart and Lua/Luau, and unused dependencies across npm, pnpm, yarn, bun, Cargo, pip and Go modules, and can hand judgment calls such as duplicates and public methods to an agent via --agent claude or --agent codex. On its bundled demo projects shrink-anything cut a TypeScript cart from 106 lines, 5 files and 3 dependencies to 58 lines, 3 files and 1 dependency (−45%), a Python shop from 142 to 86 lines (−39%) and a Go store from 89 to 55 lines (−38%), with the demo app reporting 46% fewer tokens for an agent to read.", "body_md": "**Less code. Same tests passing.**\n\nCoding agents write code faster than anyone deletes it. Functions nothing calls, files nothing imports, packages nothing uses, images nothing shows: your agent reads all of it, your CI builds it, your users download it.\n\n**shrink-anything** finds it, deletes it, and runs *your own tests* after every cut. What passes stays. What breaks is put back. One command, fully reversible.\n\nEvery line it removes is a line your agent stops reading on the next task. The report counts that too: on the demo app, 46% fewer tokens to read.\n\n```\nnpm i -g @el4cteo/shrink-anything      # or: cargo install shrink-anything\nshrink-anything go --agent claude -- npm test     # or: -- pytest / cargo test / go test ./... / anything that fails when your app is broken\n```\n\nOr step by step:\n\n| command | what it does | \n|---|---|\n| `scan` | lists what could go. Changes nothing | \n| `cut -- <check>` | deletes what's dead and runs your check: what passes stays, what breaks is put back | \n| `task --agent claude` | hands the judgment calls (duplicates, public methods) to your agent, and keeps its work only if the check agrees | \n| `weigh dist` | where the weight of a build is: by kind of file, the heaviest files, what's in there twice | \n| `verify` | runs your check now, against the test count from before the first cut | \n| `undo` | takes the last cut back, byte for byte ( `--all` for every cut) | \n| `report` | markdown + SVG card for your PR | \n| `doctor` | what's installed: parsers, package managers, agents | \n\n`--agent` takes `claude`, `codex`, or any command that reads a prompt on stdin. Without it, hand `.shrink/TASK.md` to whatever you use.\n\nNothing in that code mentions `secretly_used`: a test reaches it through a name it reads from a data file. The cut broke that test, so it was put back, alone.\n\n- **Your check decides.** A cut stays only if your command exits 0*and* at least as many tests run as before. A check that already fails is refused: it can't prove anything.\n- **One bad cut doesn't sink the rest.** Cuts go in as a batch. If the check fails, the batch is split until the one cut that breaks it is found and put back. Every state left on disk has passed.\n- **Parsed before it's tested.** Each edited file goes through the language's own parser (Python, Node, Ruby, PHP, Lua, Bash) before your check runs.\n- **Tests are never touched** , and`shrink-anything undo` restores every file byte for byte.\n- **What can't be proven isn't cut.** A public method, an export of a library, a subclass a framework may register, a file in a folder loaded by convention: these go to your agent with the reason, or behind`--aggressive` .\n\nThe proof is as strong as your check. A project with no tests gets a scan, not a cut you should trust.\n\n|  | how it decides | where | \n|---|---|---|\n| **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 | \n| **dead files** | no other file names it | Python, JS/TS, PHP, Ruby, Dart, Lua/Luau | \n| **unused dependencies** | nothing imports it or runs its commands | npm · pnpm · yarn · bun · Cargo · pip · Go modules | \n| **dead weight** | an image, font or sound no code, config or README names; the same file stored twice | any project | \n| **duplicates** | the same code twice, whatever it's called and however it's laid out | 19 languages, merged by your agent | \n\nIt counts names instead of building a call graph. A count can only miss dead code, never invent it, and it works the same in every language.\n\nThe demo projects in [`examples/`](https://github.com/EL4CTEO/shrink-anything/blob/main/examples), each with planted dead code. Run them yourself.\n\n| project | before | after | \n|---|---|---|\n| TypeScript cart | 106 lines, 5 files, 3 dependencies | **58 lines, 3 files, 1 dependency** (−45%) | \n| Python shop | 142 lines, 8 files | **86 lines, 7 files** (−39%) | \n| Go store | 89 lines | **55 lines** (−38%) | \n| Static site (build output) | 913 KB | **398 KB** (−56%) | \n\nOn real projects expect less per run and more over time: the safe cuts go on their own, the rest is a reviewed list.\n\n```\nshrink-anything weigh dist                                   # where the weight is\nshrink-anything cut --size dist -- \"npm run build && npm test\"   # cut, rebuild, weigh again\n```\n\n`--size` takes a build folder or a binary and reports it before and after. Fewer dependencies and less code mean a smaller bundle; unused assets are cut like dead code. Assets in a folder served as it is (`public/`, `static/`) need `--aggressive`: a page outside your repo may link to them.\n\n- **Claude Code plugin** :`/plugin marketplace add EL4CTEO/shrink-anything` , then`/plugin install shrink-anything@shrink-anything` and`/shrink-anything:shrink npm test`\n- **MCP server** (Claude Code, Codex, Cursor…), built into the binary:`claude mcp add shrink-anything -- shrink-anything mcp` . 8 tools:`shrink_scan` ,`shrink_cut` ,`shrink_task` ,`shrink_verify` ,`shrink_undo` ,`shrink_report` ,`shrink_weigh` ,`shrink_status` .\n- **Skill** :[`skills/shrink-anything`](https://github.com/EL4CTEO/shrink-anything/blob/main/skills/shrink-anything/SKILL.md) teaches any agent the loop.\n\nDead code and duplicates: Python · JavaScript · TypeScript · Rust · Go · Java · Kotlin · C# · C · C++ · PHP · Ruby · Swift · Dart · Lua · Luau · Elixir · Shell. Every other text file (HTML, Vue, Svelte, YAML, SQL, templates…) is read for mentions, so a function used only from a template stays.\n\nA language is one entry in a table ([`src/lang.rs`](https://github.com/EL4CTEO/shrink-anything/blob/main/src/lang.rs)): how its comments and strings look, how a block ends, what a definition looks like. Adding one is a pull request of about twenty lines.\n\nIn a library, public names belong to its users, so they're kept. shrink-anything guesses per language (a published `package.json`, a `lib.rs`, no `package main`) and says what it guessed. Override with `--lib` or `--app`.\n\nMIT", "url": "https://wpnews.pro/news/shrink-anything-finds-it-deletes-it-and-runs-your-own-tests-after-every-cut", "canonical_source": "https://github.com/EL4CTEO/shrink-anything", "published_at": "2026-11-27 07:40:52+00:00", "updated_at": "2026-11-27 08:13:59.401552+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["shrink-anything", "@el4cteo/shrink-anything", "Claude", "Codex", "npm", "Cargo", "pip", "Go modules"], "also_reported_by": [], "takeaway": "shrink-anything keeps a deletion only if your own test command exits 0 with at least as many tests as before, splitting failed batches to isolate the one breaking cut, and on its demo TypeScript cart it removed 48 of 106 lines (−45%) and 2 of 3 dependencies.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/shrink-anything-finds-it-deletes-it-and-runs-your-own-tests-after-every-cut", "markdown": "https://wpnews.pro/news/shrink-anything-finds-it-deletes-it-and-runs-your-own-tests-after-every-cut.md", "text": "https://wpnews.pro/news/shrink-anything-finds-it-deletes-it-and-runs-your-own-tests-after-every-cut.txt", "jsonld": "https://wpnews.pro/news/shrink-anything-finds-it-deletes-it-and-runs-your-own-tests-after-every-cut.jsonld"}}