Find your next open-source project

Search by name, purpose, or keyword — or paste a GitHub repository URL

EL4CTEO/shrink-anything

Developer Tools

A CLI that deletes dead code, files, dependencies and assets, keeping each cut only if your test suite still passes.

This repo is an agent skill pack · 1 skillsSkill list and install →
110
8
Rust
MIT
1 day old

What it does

Coding agents add code faster than anyone removes it, so unused functions, files, dependencies and assets accumulate in the repo and in every agent context. shrink-anything scans a codebase for those leftovers, deletes them, and after every cut runs a check command you supply. A cut is kept only when the check exits 0 and runs at least as many tests as before; a check that already fails is refused. Broken cuts are restored byte for byte, and undo reverses the last cut (or all cuts with --all).

It covers dead code in 19 languages (including Python, TypeScript, Go, Rust, Java, C#, PHP, Ruby, Swift, Dart, Lua and Luau), dead files, unused dependencies across npm/pnpm/yarn/bun, Cargo, pip and Go modules, and unused or duplicated assets. Detection counts name mentions instead of building a call graph: every mention of a name inside its own definition is ignored, but any mention elsewhere (another file, string, template or config) keeps it. That is deliberately conservative — it can miss dead code but should not invent it.

Quick start

Install from npm or crates.io:

npm i -g @el4cteo/shrink-anything   # or: cargo install shrink-anything

Then run the whole loop with your own test command:

shrink-anything go --agent claude -- npm test

Use whatever command fails when the app is broken — pytest, cargo test, go test ./.... Without --agent, judgment calls are written to .shrink/TASK.md for you to hand to an agent. The subcommands can also be run separately:

Command Purpose
scan List candidates without changing files
cut -- <check> Delete dead items, split failing batches, restore the single bad cut
task --agent claude Hand ambiguous cases (duplicates, public methods) to the agent, keeping only what the check accepts
weigh dist Report build size by file kind and find duplicates
verify Re-run the check against the original test count
undo Restore the last cut, byte for byte
report Generate a Markdown and SVG report card for a PR
doctor Show installed parsers, package managers and agents

Before the check runs, edited files are parsed with each language's own parser for Python, Node, Ruby, PHP, Lua and Bash. Tests are never modified. The examples/ directory contains demo projects with planted dead code that you can run yourself.

Size and assets

weigh summarizes where a build's weight comes from; cut --size dist -- "npm run build && npm test" cuts, rebuilds and re-weighs. Assets under folders served as-is such as public/ or static/ are only touched with --aggressive, since pages outside the repository may link to them.

Agent integrations

The binary also ships an MCP server with eight tools (shrink_scan, shrink_cut, shrink_task, shrink_verify, shrink_undo, shrink_report, shrink_weigh, shrink_status), a Claude Code plugin, and a skill file that teaches any agent the loop.

Constraints

  • The check is the proof. A project without tests only gets a reliable scan; without a passing check there is nothing to verify cuts against.
  • Public API conservatism. In a library, public names are kept; the tool guesses library vs. app per language (published package.json, a lib.rs, no package main) and reports its guess. Override with --lib or --app.
  • Unprovable cuts are deferred. Public methods, library exports, framework-registered subclasses and convention-loaded files go to the agent or require --aggressive.
  • Mention-based detection. Because it counts names rather than resolving a call graph, some genuinely dead code can be missed; expect multiple runs on real projects, with safe cuts automatic and the rest a reviewed list.
  • Build artifacts. Only build output is affected by --size; source and tests remain untouched.
  • Licensed MIT.

HotRepo's take

On 2026-11-24 the project entered HotRepo's new-project board for Rust, gaining 6 stars in roughly 2.5 hours (102 to 106 overall) with 8 forks. That is an early signal for a repository created one day earlier, not evidence of adoption. What makes it worth watching is the verification design rather than the star count: tying every deletion to the user's own test suite and rejecting an already-failing check avoids the usual risk of automated cleanup breaking a build. The demo numbers (for example, a TypeScript cart reduced from 106 to 58 lines) come from planted examples, so real-world yield will depend on test coverage, which the project itself acknowledges.

Written by AI from the project's public information and HotRepo's records, updated . The project's own docs are the source of truth.