junkdoctor
v1.0.1
Published
Find and safely clean node_modules, .next, venv, dist, and other project junk folders
Maintainers
Readme
JunkDoctor
Your smart project junk cleaner.
JunkDoctor finds heavy folders developers usually delete — node_modules, .next, venv, dist, caches, and more — measures disk use, and helps you safely clean them from the CLI or an interactive menu.
Repository: github.com/foisalislambd/JunkDoctor
Table of contents
- Features
- Install
- Quick start
- CLI reference
- Interactive UI (TUI)
- Safety system
- How scanning works
- Development
- Architecture
- Requirements
- Contributing
- License
Features
| Feature | Description |
|---------|-------------|
| Multi-target scan | Finds node_modules, .next, venv, dist, caches, and more |
| Disk analysis | Async size measurement for every junk type |
| One-shot clean | clean --everything removes all supported junk safely |
| Path scope | clean --in <folder> only cleans inside a chosen directory |
| Safety layer | Risk levels (LOW / MEDIUM / HIGH), blocked system paths |
| Dry-run | Preview destructive actions without changes |
| Interactive TUI | Menu with scan, browse, and clean shortcuts |
| Fast scanning | fdir + bounded parallel I/O |
Install
From npm
npm install -g junkdoctorAfter install, run junkdoctor or jd in your terminal.
From source
git clone https://github.com/foisalislambd/JunkDoctor.git
cd JunkDoctor
npm install
npm run build
npm linkAfter linking, run junkdoctor or jd (same as the global install).
Quick start
Easiest path: open the menu and pick what you need.
junkdoctorYou get a simple menu:
- Find my projects — scan for junk folders
- Browse all projects — list + quick actions
- Show biggest folders — what eats the most disk
- Clean old node_modules — idle 90+ days
- Clean old .next / Python envs
- Clean ALL junk types — one place for everything
# Or use short CLI commands
junkdoctor doctor # scan + tips
junkdoctor scan # find projects + junk
junkdoctor targets # list cleanable folder types
junkdoctor biggest # top disk users
junkdoctor clean --everything --dry-run # preview: all junk types
junkdoctor clean --target node_modules --all # only node_modules everywhere
junkdoctor clean --target venv --all # only Python venvs
junkdoctor clean --target python --all # venv + __pycache__
junkdoctor clean --in D:\work --everything --dry-run # only inside a folder
junkdoctor clean --next --stale # idle .next caches
junkdoctor reinstall ./my-app # fresh Node installTip: always try --dry-run before a real clean.
CLI reference
Default command
Running junkdoctor with no subcommand opens the interactive TUI.
Commands
| Command | Description |
|---------|-------------|
| scan [paths...] | Discover projects and measure all junk folders |
| analyze | Health summary from cached scan |
| biggest | List largest projects by total junk size |
| clean | Remove junk folders with safety checks |
| targets | List supported cleanable folder types |
| reinstall <path> | Delete node_modules and reinstall dependencies |
| doctor | Quick scan + recommendations |
| ui / tui | Open interactive terminal UI |
| cache-path | Show where scan cache is stored |
| clear-cache | Clear the saved scan cache |
| --help | Show help |
| --version | Show version |
scan options
| Flag | Description |
|------|-------------|
| --all | Include current directory + all default home dev roots |
Examples:
junkdoctor scan
junkdoctor scan ~/projects
junkdoctor scan --allbiggest options
| Flag | Description |
|------|-------------|
| -n, --limit <number> | Number of projects to show (default: 20) |
clean options
| Flag | Description |
|------|-------------|
| --dry-run | Preview only — nothing deleted |
| --force | Skip LOW/MEDIUM confirmations (HIGH still requires typing DELETE) |
| --stale | Only caches not modified in 90+ days |
| --min-mb <n> | Minimum size in MB (still excludes global and HIGH-risk) |
| --all | All eligible non-global, non-high-risk matches |
| --everything | Clean every supported junk type |
| --target <list> | Types: node_modules, next, venv, python, dist, all, … |
| --next | Alias for --target next |
| --in <path> | Only clean inside this folder (scans it first) |
Default behavior (no flags): stale node_modules, non-global, non-high-risk only.
Supported targets: node_modules, next, venv (venv/.venv/env), pycache, dist/build, .turbo, .cache/.parcel-cache, coverage, .nuxt/.output, target (Rust). Aliases: python → venv+pycache, all → everything.
Global and high-risk folders are never included in bulk clean.
Global packages (separate):
junkdoctor clean --global --dry-run # preview other global packages
junkdoctor clean --global # remove them (junkdoctor stays)The whole global node_modules folder is never deleted. junkdoctor itself is always protected.
Examples:
junkdoctor clean --everything --dry-run
junkdoctor clean --target node_modules --all
junkdoctor clean --target venv,dist --all --dry-run
junkdoctor clean --target python --all
junkdoctor clean --in D:\work --everything --dry-run
junkdoctor clean --in ~/projects --target node_modules --all
junkdoctor clean --next --stale
junkdoctor clean --min-mb 500 --target next --allreinstall options
| Flag | Description |
|------|-------------|
| --dry-run | Preview only |
| --force | Skip confirmations |
junkdoctor reinstall C:\path\to\project
junkdoctor reinstall ./my-app --dry-runInteractive UI (TUI)
Launch:
junkdoctor
# or
junkdoctor uiMain menu (start here)
Everything important is one pick away:
| Menu item | What it does | |-----------|----------------| | Find / Scan again | Discover projects and measure sizes | | Browse all projects | Scroll list + quick keys | | Show biggest folders | Top space users | | Clean old node_modules | Idle packages (90+ days) | | Clean old .next caches | Idle Next.js build caches | | Clean old Python envs | Idle venv / pycache | | Clean ALL junk types | Every supported folder type | | Clean global npm packages | Other global packages only — junkdoctor never removed |
Project list shortcuts
| Key | Action |
|-----|--------|
| ↑ / ↓ or j / k | Move selection |
| A | Clean ALL junk folders on the current list/page |
| D | Delete node_modules for selected project |
| N | Delete .next for selected project |
| I | Reinstall dependencies |
| V | View details |
| Enter / Space | Full action menu (includes Clean ALL for that project) |
| / | Search by name or path |
| R | Rescan |
| H / Esc | Back to main menu |
| Q | Quit |
On clean pages (node_modules / .next / venv / everything), the top menu item is Clean ALL on this page, or press A.
Bulk clean wizard
Clean ALL opens a step-by-step flow:
- Review — projects, folders, space to free, type breakdown, biggest targets
- Preview only (recommended) — nothing deleted
- Clean all now — progress
7 of 12, then a Finished summary
Global and high-risk folders are never included.
On single-project confirm: choose Preview only first if you are unsure — nothing is deleted.
Safety system
JunkDoctor is built to prevent accidents.
| Risk | Behavior |
|------|----------|
| LOW | Standard yes/no confirmation (CLI) |
| MEDIUM | Confirmation + warnings (outside home, large cache, etc.) |
| HIGH | Must type DELETE to confirm; global node_modules blocked; excluded from bulk clean |
Automatically blocked
- Windows:
Windows,System32,Program Files, etc. - Global / system
node_modules— hard-blocked (cannot delete or reinstall), including%APPDATA%\npm\node_modulesand packages inside it - System root drives
--force skips LOW/MEDIUM prompts only — HIGH-risk actions still require typing DELETE. Global node_modules stays blocked even with --force.
Always preview first
junkdoctor clean --dry-run
junkdoctor reinstall ./app --dry-runHow scanning works
By default, junkdoctor scans common folders under your home directory:
Desktop, Documents, Projects, code, GitHub, dev, and similar paths (see src/utils/paths.ts).
For each package.json found (skipping nested node_modules):
- Detect package manager from lockfiles
- Measure
node_modulessize (if present) - Measure
.nextsize (if present — Next.js) - Assign risk score
- Cache results locally (
junkdoctor cache-path)
junkdoctor scan --all # Also scan cwd + all default rootsDevelopment
git clone https://github.com/foisalislambd/JunkDoctor.git
cd JunkDoctor
npm install| Script | Description |
|--------|-------------|
| npm run build | Compile TypeScript to dist/ |
| npm start | Run CLI (node dist/cli.js) |
| npm run dev | Watch + rebuild + launch TUI |
| npm run build:watch | Watch + rebuild only |
| npm run typecheck | TypeScript check without emit |
Architecture
src/
├── cli.ts # CLI entry (commander)
├── cli/commands/ # scan, analyze, clean, doctor, …
├── cli/display.ts # Terminal tables & summaries
├── core/
│ ├── scanner.ts # Filesystem crawl
│ ├── project-meta.ts # Per-project metadata + risk
│ ├── analyzer.ts # Health summaries
│ ├── disk-usage.ts # Async directory sizing
│ ├── package-manager.ts # npm/yarn/pnpm/bun
│ └── global-prefix.ts # Global npm path
├── safety/ # Path guard + confirmations
├── services/
│ ├── actions.ts # Delete / reinstall single project
│ └── bulk-clean.ts # Bulk plan + execute (CLI + TUI)
├── store/cache.ts # Scan persistence (conf)
└── tui/ # Ink React terminal UI
├── App.tsx
└── components/Requirements
- Node.js 18+
- npm (for global prefix detection; projects may use yarn/pnpm/bun)
Contributing
Issues and pull requests are welcome. See CONTRIBUTING.md for setup, PR checklist, and guidelines.
Please follow the Code of Conduct. Security issues: see SECURITY.md.
