Clean Up a JavaScript Repo Without Guessing What to Delete

Clean Up a JavaScript Repo Without Guessing What to Delete

A repository can look tidy in a file browser and still be carrying dead weight: files nobody reaches, exports nobody imports, forgotten dependencies and build output that should not be there. The hard part is not spotting clutter. It is knowing what is safe to move without breaking something relied on indirectly.

I built RepoClean to make that decision easier to inspect. It finds likely dead code and repository junk, explains why each item was flagged, and leaves the final choice with you. Nothing moves until you approve the exact files.

Repository clutter is a judgement problem

Unused files are not always obviously unused. A module might be reachable through an entry point, an export might be imported in an unexpected place, and a file that looks obsolete might still be referenced by a test or a legacy path. A broad search can help, but it does not give you one organised view of these different signals.

RepoClean runs twelve detectors in a single pass. They cover files unreachable from every entry point; exported symbols nobody imports; packages never imported or invoked; unreferenced images, fonts and styles; and leftovers such as operating-system, editor, merge and log files. It also looks for committed build or cache output, byte-identical duplicates, oversized binaries, empty files, conditionals that cannot run, and imports that resolve to nothing.

One category needs particular care: “possibly obsolete” means something is still alive, but only through tests or legacy signals. That is a prompt to investigate, not a conclusion that the file is safe to remove. I designed the report to show evidence for each finding rather than ask you to trust a label.

The practical decision RepoClean supports is narrow: which files are worth reviewing, and which of those are you willing to move out of the working repository? It is not a mandate to make every project smaller.

Evidence first, approval always

Under the hood, RepoClean walks the repository in parallel, respects .gitignore, and flags committed build output and junk as it indexes files. It detects a likely stack, shows the evidence and lets you confirm it. The parser then builds a dependency graph from imports, re-exports, lazy imports, require() and import.meta.glob.

Reachability, symbol usage, text references, naming and @deprecated tags contribute to a confidence score from 0 to 100. That score is useful context, not permission to delete. Negative evidence matters too: a dynamic reference lowers confidence, while a public entry point blocks removal. Public folders, dynamic references and live importers can force human review; blockers beat scores.

That distinction matters because automated detection and automated deletion are not the same thing. RepoClean produces findings automatically, but you review them. The site states that zero files are deleted without approval. A dry run comes first, and the files you approve go to .repoclean/trash with a manifest. They are not permanently deleted; repoclean restore brings them back.

The command-line engine runs on your computer. The site says it does not send the repository anywhere, and does not send telemetry, update checks or crash reports. The hosted scanner at repoclean.xyz can show a report for its bundled example or a public repository, but it does not modify those files. Cleaning happens on your machine.

How I recommend getting started

Start with a repository where you can review the result calmly, rather than making clean-up part of a release rush. My suggested sequence is:

  1. Make sure your working tree is clean. RepoClean refuses to touch a git working tree with uncommitted changes. That is a useful safeguard, not an inconvenience to bypass casually.

  2. Install the tool. You need Node.js 18 or newer. Run npm install -g @presencedigital/repoclean, then run repoclean from the repository. It opens a page on 127.0.0.1 on your machine, where you can review what it found and choose what to move. As an alternative, npx @presencedigital/repoclean does the same thing without a global install.

  3. Confirm the stack and inspect the evidence. RepoClean detects stacks including React, Vue, Next.js, Nuxt and Vite, as well as custom setups. Check the detected stack rather than assuming it is right. Treat lower-confidence findings, dynamic references and anything reachable through tests or legacy signals as questions to answer.

  4. Begin with a dry run and a small selection. If you are using the terminal, start from the root of the checkout: repoclean scan . --summary --out report.json, followed by repoclean clean . --report report.json. The clean command is a dry run unless you explicitly apply it. Read the report and approve only files you understand.

  5. Apply deliberately, then keep the recovery path handy. When the report is reviewed, repoclean clean . --report report.json --apply moves the approved files to the reversible trash. If you need them back, run repoclean restore .. Review the project afterwards using your normal checks before treating the clean-up as finished.

If you need to confirm the detected stack once, the terminal also supports repoclean init . --framework react --build-tool vite, which saves that choice to .repoclean.json. Use the values that match your project; the example above is not a universal setting.

Who should use it, and where to be cautious

RepoClean is for teams maintaining JavaScript or TypeScript repositories who suspect accumulated clutter and want an evidence-led review before moving files. It is also useful when a repository has committed build output or obvious leftovers that are distracting from normal maintenance.

Wait if the repository is in the middle of a migration, if nobody can explain its entry points, or if you cannot review the findings and check the project afterwards. A confidence score cannot capture every convention in a team’s codebase. Dynamic loading and public interfaces are especially good reasons to slow down, read the evidence and keep a human in the loop.

The engine is built with Rust and oxc, and the package is installed through npm; a Rust toolchain is not required. The npm install downloads a small launcher and one matching platform package containing the prebuilt binary. Supported platforms are macOS Apple silicon and Intel, Linux x64 with glibc or musl (including Alpine), and Windows x64.

I built RepoClean around a simple rule: finding candidates is automation’s job; deciding what is safe to remove is yours. Try the hosted report at repoclean.xyz, or install RepoClean and run it on a repository on your own machine. Start with the evidence, approve a small list, and keep the restore command within reach.

// Share this post

Newsletter

New articles, in your inbox

One email when we publish. No digests and no product pitches. Unsubscribe any time. Privacy policy