Commands
Find potentially unused files and assets, ranked by confidence.
Finds files in public/ src/ app/ pages/ components/ assets/ styles/ (per workspace package) that nothing references: images, SVGs, fonts, stylesheets, JS/TS modules, media and other static files.
broom clean # report (never deletes)broom clean --dry-run # exactly what cleanup would delete (high confidence)broom clean --dry-run --confidence mediumbroom clean --fix # choose files interactively, then confirmbroom clean --fix --yes # delete high-confidence files without promptingbroom clean --json broom clean Found 8 potentially unused files. components/ OldButton.tsx high 63 B public/ logo-old.svg medium 59 B public/images/ banner-old.webp medium 4 KB src/icons/ unused-icon.svg high 512 B src/lib/ unused-helper.ts high 32 B src/locales/ en.json low 18 B es.json low 17 B src/styles/ legacy.css high 24 B Potential savings: 4.7 KB (631 B high, 4.1 KB medium, 35 B low) Dry run (high confidence and above) would delete components/OldButton.tsx 63 B not imported by any analyzed file would delete src/icons/unused-icon.svg 512 B no import, URL or path reference found would delete src/lib/unused-helper.ts 32 B not imported by any analyzed file would delete src/styles/legacy.css 24 B no import, URL or path reference found 4 files, 631 B. No files were changed. Run with --fix to choose files to delete.require, import(), require.resolve, new URL('./x', import.meta.url), import.meta.glob, require.contextsrc="/logo.svg"), resolved relative to the file, the package's public/, the package root and src/`./locales/${lang}.json`) as patterns@import, @use, @forward, url() (comments ignored)paths and baseUrl, the common @/ and ~/ aliases, and workspace package namesEntry points declared in package.json (main, module, exports, bin, …), Next.js App Router special files, pages/ routes, routes/, root/src index|main|server.*, *.config.*, .d.ts, tests and stories, middleware/instrumentation, and well-known public files (favicon.ico, robots.txt, sitemap.xml, manifest.json, .well-known/, …).
| Level | Meaning |
|---|---|
high | No import, URL, path or name reference found anywhere. |
medium | No reference, but the file is in public/ (reachable by URL), the project has dynamic imports with unknown targets, or some files could not be parsed. |
low | Not resolvable, but its file name appears somewhere or it matches a dynamic path pattern. |
| Flag | Description |
|---|---|
--dry-run | Show exactly which files cleanup would delete, without deleting. |
--fix | Interactively choose files to delete. Always asks first. |
--confidence <level> | Minimum confidence for --dry-run/--fix: high (default), medium or low. |
-y, --yes | With --fix: delete matching files without prompting. |
Before deleting, each file is re-checked: it must still be a regular file (not a symlink), have the same size and modification time as during the scan, and resolve inside the project. Anything else is skipped and reported. Case mismatches (import './Logo.png' for logo.png) are treated as used and reported, since they break on case-sensitive filesystems.
Found a problem in these docs? Open an issue on GitHub.