# Repository Briefing: EL4CTEO/shrink-anything
> Source: https://repoforai.com/repo/EL4CTEO/shrink-anything (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/EL4CTEO/shrink-anything
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: Rust
- **License**: MIT
- **Engineering Health**: A (87/100 · Maintenance 35/35 · Adoption 12/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v0.1.1 (2026-11-25) — https://github.com/EL4CTEO/shrink-anything/releases
- **Review Snapshot**: 2026-11-28
- **Deployment / Stack Signals**: MCP, CLI
- **Momentum**: 479 ★ total (+9 24h / +262 7d) · 31 forks
- **Topics**: `ai-agents`, `bundle-size`, `claude-code`, `cli`, `code-cleanup`, `dead-code`, `mcp`, `refactoring`, `rust`, `unused-dependencies`
- **When to Use**: Best for: 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. Skip if: 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.

## Overview
```text
### Architecture & 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.
```

## Key Capabilities
```text
- Batch rollback: A failing cut batch is bisected so individual breaking edits can be isolated and restored.
- Verification: Acceptance requires exit status 0 and no drop in the observed test count; `verify` rechecks the original baseline.
- Ecosystem coverage: Dependency scans cover npm, pnpm, Yarn, Bun, Cargo, pip, and Go modules; dead-file scanning is narrower.
- Agent integration: MCP exposes scanning, cutting, task handoff, verification, undo, reporting, build weighing, and status.
- Build analysis: `weigh dist` groups output by file kind and identifies the heaviest and duplicate files.
- Reversibility: `undo` restores the latest cut byte for byte; `undo --all` restores all recorded cuts.
```

## Quick Start / Clone
```bash
npm i -g @el4cteo/shrink-anything      # or: cargo install shrink-anything
```
