Skip to content
/ modkill Public

πŸ”ͺ Murder your node_modules. Free gigabytes in seconds. Smart CLI that finds & removes old JavaScript project dependencies with style.

License

Notifications You must be signed in to change notification settings

udede/modkill

Repository files navigation

πŸ”ͺ modkill

modkill poster

npm version downloads tests coverage license node

πŸš€ Murder your node_modules. Free your disk. Lightning fast.

πŸ“Έ Demo

$ modkill --path ~/Projects --depth 4

βœ” Scan complete: 42 candidate(s)

Project (relative path below)                     Size         Age
β—‰ old-project                                   1.98 GB       482d
  old-project/frontend
β—‰ abandoned-poc                                  856 MB       127d
  experiments/abandoned-poc
β—― active-project                                 328 MB         3d
  work/active-project

Total to free: 2.8 GB
? Proceed to delete 2 folders? (y/N)

🎯 Why modkill?

Every developer's disk is littered with forgotten node_modules folders:

  • Gigabytes wasted: Each project can have 100MB-2GB of dependencies
  • Accumulation: Old projects, experiments, tutorials pile up over months
  • Hidden bloat: Nested in various directories, hard to find manually

modkill solves this with:

  • ⚑ Fast parallel scanning using optimized filesystem traversal
  • 🧠 Smart detection of abandoned projects by age and size
  • πŸ›‘οΈ Safe by default with dry-run, trash, and restore logs
  • 🎨 Beautiful UX with interactive selection and progress indicators
  • πŸ”§ Flexible with JSON output for automation

πŸ“¦ Installation

# Quick one-time use
npx @lisandrof/modkill

# Global install
npm install -g @lisandrof/modkill

# Using Yarn
yarn global add @lisandrof/modkill

# Using pnpm
pnpm add -g @lisandrof/modkill

Requirements

  • Node.js 18.0.0 or higher
  • macOS, Linux, or Windows
  • 50MB free RAM

πŸš€ Quick Start

# Interactive mode - select what to delete
modkill

# Scan your entire home directory
modkill --path ~ --depth 4

# Auto-clean old modules (>30 days)
modkill --auto

# Preview without deleting anything
modkill --dry-run

# Clean current project only
modkill --current

πŸ“– Commands & Options

Basic Commands

Command Description
modkill Interactive mode with checkbox selection
modkill --auto Automatically clean old modules (>30 days)
modkill --dry-run Preview what would be deleted
modkill --current Clean only current directory

Options

Option Type Default Description
--path <dir> string . Root directory to scan
--depth <n> number 6 Max recursion depth
--min-age <days> number 0 Only show modules older than N days
--min-size <mb> number 0 Only show modules larger than N MB
--sort <by> string size One of: size, age, name, path
--json boolean false Output JSON for scripting
--yes boolean false Skip confirmation (interactive mode only)
--help boolean false Show help

Advanced Examples

# Auto-clean with age and size filters
modkill --path ~/Projects --min-age 60 --min-size 100

# Auto-clean with custom thresholds
modkill --auto --min-age 90 --min-size 200

# Generate JSON report for analysis
modkill --dry-run --json --path ~ > report.json

# Clean current directory (no confirmation by design)
modkill --current

# Auto-clean only large modules (>200MB)
modkill --min-size 200

# Focus on abandoned projects (oldest first, interactive)
modkill --path ~ --sort age

# Deep scan of an external drive
modkill --path /Volumes/Backup --depth 10

🎨 Interactive Mode Features

Smart Table Display

  • Project name with color coding:
    • πŸ”΄ Red: >60 days old
    • 🟑 Yellow: 30-60 days old
    • 🟒 Green: <30 days old
  • Size in human-readable format (KB, MB, GB)
  • Age in days or months
  • Path shown as subtitle (relative to scan root)

Selection Interface

  • Space: Select/deselect item
  • A: Toggle all
  • I: Invert selection
  • Enter: Proceed with deletion
  • Ctrl+C: Cancel

Safety Features

  • βœ… Interactive preview with confirmation prompt
  • πŸ—‘οΈ Moves to OS trash (recoverable)
  • πŸ“ Creates restore log in system temp directory (modkill-restore-[timestamp].log)
  • ⚠️ Dry-run mode available for risk-free preview
  • 🚫 Skips system directories automatically

How it decides

  • Filter: applies --min-age and --min-size when provided
  • Sorting: default by size (use --sort age|name|path to override)
  • Pre-selection (interactive): auto-selects items older than 30 days
  • Scoring: weighted formula ageScoreΓ—0.5 + sizeScoreΓ—0.4 + orphanBonusΓ—0.1
  • Colors: 🟒 ≀30d, 🟑 31–60d, πŸ”΄ >60d

πŸ“Š JSON Output Schema

[
  {
    "path": "/absolute/path/to/node_modules",
    "sizeBytes": 134217728,
    "mtimeMs": 1699564800000,
    "hasPackageJson": true,
    "ageDays": 45.5,
    "score": 67.3
  }
]

Fields:

  • path: Absolute path to node_modules folder
  • sizeBytes: Total size in bytes
  • mtimeMs: Last modified timestamp (milliseconds)
  • hasPackageJson: Whether parent has package.json
  • ageDays: Days since last modification
  • score: Heuristic priority score (weighted by age, size, and orphan status)

⚑ Performance

Metric Result
Scan home (277GB) 52.7s
Memory usage (peak) <50MB
Single project scan 0.21s
Parallel scanning βœ… Ready

Benchmarks

Tested on M-series Mac:

# Scan home directory (277GB, depth 6)
βœ“ Found 54 node_modules totaling 18GB in 52.7s

# Scan projects directory
βœ“ Found 11 node_modules totaling 4.7GB in 47.9s

# Scan current project
βœ“ Found 1 node_modules in 0.21s

πŸ› οΈ Development

Setup

# Clone repository
git clone https://github.com/udede/modkill.git
cd modkill

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Link for local testing
npm link

Scripts

Script Description
npm run dev Watch mode with auto-rebuild
npm run build Build for production
npm test Run all tests
npm run lint Lint and fix code
npm run format Format with Prettier
npm run bench Run benchmarks

Project Structure

modkill/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ cli.ts              # CLI entry point
β”‚   β”œβ”€β”€ core/               # Core logic
β”‚   β”‚   β”œβ”€β”€ scanner.ts      # Filesystem traversal
β”‚   β”‚   β”œβ”€β”€ analyzer.ts     # Filtering & scoring
β”‚   β”‚   └── cleaner.ts      # Safe deletion
β”‚   β”œβ”€β”€ commands/           # Command handlers
β”‚   └── ui/                 # UI components
β”œβ”€β”€ tests/                  # Test suites
└── dist/                   # Built files

πŸ§ͺ Testing

# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Run specific suite
npm test scanner

# E2E tests
npm run test:e2e

🀝 Contributing

We love contributions! This project uses automated releases with changesets.

Quick Start

  1. Fork the repository
  2. Create your feature branch (git checkout -b feat/amazing-feature)
  3. Make your changes
  4. Add tests for new features
  5. Create a changeset: npm run changeset
  6. Commit your changes (including the changeset file)
  7. Push and open a Pull Request

For detailed guidelines, see:

Automated Releases

This project uses GitHub Actions for automated releases:

  • βœ… CI runs on every PR
  • βœ… Changesets bot creates release PRs automatically
  • βœ… Packages publish to npm automatically when release PR is merged
  • βœ… Changelog is auto-generated

No manual npm publish needed! πŸŽ‰

πŸ“ Changelog

See CHANGELOG.md for version history.

πŸ† Comparison

Feature modkill npkill node-prune
Speed ⚑⚑⚑⚑⚑ Parallel ⚑⚑⚑ ⚑⚑
Interactive UI βœ… Rich & colorful βœ… Basic ❌
Safe deletion βœ… Trash + log ⚠️ Permanent ⚠️ Permanent
JSON output βœ… ❌ ❌
Custom filters βœ… Age, size ⚠️ Limited ❌
Monorepo aware βœ… Depth control ⚠️ ❌
Windows support βœ… βœ… ⚠️

πŸ› Troubleshooting

Common Issues

Permission denied

# Run with sudo if scanning system directories
sudo modkill --path /usr/local

Slow scanning

# Reduce depth for faster scans
modkill --depth 3

# Auto-clean only large folders (>100MB) for faster cleanup
modkill --min-size 100

Not finding modules

# Increase depth
modkill --depth 10

# Check specific path
modkill --path ./my-project

πŸ“„ License

MIT Β© Francesco Lisandro


Made with ❀️ by developers, for developers
⭐ Star on GitHub

About

πŸ”ͺ Murder your node_modules. Free gigabytes in seconds. Smart CLI that finds & removes old JavaScript project dependencies with style.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •