EL4CTEO/shrink-anything
Rust CLI and MCP server for test-gated removal of dead code and unused assets
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Tracked from daily D1 telemetry snapshots. Hover any data point for exact daily star counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
shrink-anything is a Rust CLI whose binary entry point is src/main.rs. It looks for names mentioned only within their own definitions rather than building a whole-program call graph. It also reads templates, configuration, and other text files for references. Language rules live in src/lang.rs; manifest dependencies include clap for CLI parsing, ignore for file traversal, aho-corasick and regex for matching, and toml_edit for TOML editing.
scan is read-only. cut applies candidate edits in batches and validates changed files with the language runtime's parser where supported. It keeps a batch only if the project check exits successfully and the observed test count does not drop below baseline. Failing batches are split to isolate and restore breaking edits. The same binary runs the MCP server via shrink-anything mcp; judgment calls can go to Claude, Codex, or another command that reads a prompt on stdin.
Key Capabilities & Differentiators
The v0.1.1 feature table and language list cover 18 languages for dead-code and duplicate detection, including TypeScript, Python, Rust, Go, C#, and Lua/Luau. Dead-file analysis covers a narrower set: Python, JS/TS, PHP, Ruby, Dart, and Lua/Luau. Dependency checks span npm, pnpm, Yarn, Bun, Cargo, pip, and Go modules. Asset scanning looks for unreferenced media and duplicate files; weigh dist breaks down build output by file kind and identifies heavy or duplicate files.
Duplicate consolidation is delegated to an agent rather than handled as an automatic deletion. verify reruns the project check against the original test-count baseline, while report produces Markdown and an SVG card for a pull request. With deliberately planted dead code, the TypeScript demo went from 106 to 58 lines and from three dependencies to one; the static-site build went from 913 KB to 398 KB. These examples illustrate the workflow, not typical savings for production repositories.
Trade-offs & Limitations
The advantage over a language-specific linter or unused-dependency checker is the workflow: one pass can surface several kinds of removal candidates and apply test-gated edits with rollback. The trade-off is precision. Textual mentions can preserve truly dead code, and computed references or convention-loaded entry points can evade matching. Library mode preserves public names, and --lib or --app can override the inferred mode. Risky candidates are generally deferred to an agent or require --aggressive; assets served directly from folders such as public/ or static/ need that flag for removal.
The test-count floor helps catch a drop in the number of tests run, but it does not prove that the same tests ran or that they covered the affected behavior. Narrow unit suites are particularly weak evidence for deleting framework-discovered code or runtime assets. Batch splitting can also multiply test runs when checks are slow or flaky. Start with scan-only output in under-tested projects, and add build or integration checks before accepting deletions that affect runtime behavior.
Hardware & Deployment Guide
Install locally with npm i -g @el4cteo/shrink-anything or cargo install shrink-anything. The Cargo manifest uses edition 2024 and requires Rust 1.88 or later for source builds. For a conservative first run, use doctor to inspect available parsers, package managers, and agents, review scan, and then run shrink-anything cut -- npm test or substitute an equivalent project check. The baseline check must pass before cuts begin.
CLI, built-in MCP, and a Claude Code plugin are available integration paths. The core workflow does not require model inference; it depends on the project's toolchain and validation command. Parser checks cover Python, Node, Ruby, PHP, Lua, and Bash when the corresponding parser is available. Version 0.1.1 fixed false dead-code reports and cuts for non-ASCII identifiers by aligning mention and definition tokenization on Unicode \w. It also fixed retention for dynamic prefixes and folder paths containing non-ASCII letters.
verify rechecks the original baseline.weigh dist groups output by file kind and identifies the heaviest and duplicate files.undo restores the latest cut byte for byte; undo --all restores all recorded cuts.Maintainers of applications or mixed-language repositories with reliable build and test commands who want to review and apply reversible cleanup batches, with optional agent help.
Critical behavior is poorly tested, runtime discovery dominates, or you need authoritative symbol-level reachability analysis. In those cases, use scan for triage or prefer a language-specific analyzer.
Quick Start & Installation
npm i -g @el4cteo/shrink-anything # or: cargo install shrink-anything
Comparison vs. Top Coding, Skills & MCP Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| shrink-anything ★ | 479 | +262 | Rust | MIT | Rust CLI and MCP server for test-gated removal of dead code and unused assets |
| qwen-code | 31.1k | +141 | TypeScript | Apache-2.0 | TypeScript coding agent with swappable models and MCP for repository-scale work |
| gemini-cli | 109.5k | +442 | TypeScript | Apache-2.0 | A Node.js terminal agent for enterprise Gemini coding workflows and MCP tools |
| cc-haha | 15.7k | +146 | TypeScript | — | Local-first Electron workbench for coding agents, Git worktrees, and MCP |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/EL4CTEO/shrink-anything.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about shrink-anything
How does the tool fit into Claude Code, and can I use it without an agent?
claude mcp add shrink-anything -- shrink-anything mcp. Use shrink_scan to inspect candidates without editing, then invoke the cut and verification tools with a project check you trust. MCP is optional: the CLI can run directly, and judgment calls can be handed off through .shrink/TASK.md without launching an agent from the CLI.Does cleanup require GPU or VRAM, and what determines runtime cost?
Can a company run or redistribute it under the MIT license?
When should I choose this over a language-specific dead-code analyzer?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy