reclaim-cli
v0.4.0
Published
Finds stale local projects and reclaims disk space from their build artifacts
Downloads
315
Maintainers
Readme
reclaim-cli
Finds projects you haven't touched in a while and reclaims the disk space taken by their
regenerable build output (node_modules, .build, DerivedData, Gradle build, …).
Source files are never touched.
macOS, Linux and Windows. Supports Node.js, Swift (SwiftPM / Xcode) and Android (Gradle) projects.
Install
npm install -g reclaim-cli
reclaim-cli init # folders, thresholds, daily schedule, terminal reminderTo run from source instead: npm ci && npm run build && npm link.
How it works
- Scan – walks your watched folders and finds project roots (outermost marker wins, so a monorepo is one project).
- Judge – a project is stale when its most recent sign of life is older than
staleAfterDays(default 60). Signs of life: newest source-file mtime (artifact folders excluded), last commit, last change to.git/HEAD/.git/index. - Measure – sizes the artifacts of stale projects (
duon macOS/Linux, recursive walk on Windows). - Remind – the daily job updates the
pendingfile in the state dir and sends a native notification (node-notifier: Notification Center / toasts /notify-send) when at leastminReclaimableMBcan be reclaimed. A tiny shell hook prints that line when you open a terminal. - Clean –
reclaim-cli review(interactive) orreclaim-cli cleanremoves only artifacts.
What counts as an artifact
| Type | Always removed | Removed only if git-ignored |
|---|---|---|
| Node | node_modules, .next, .nuxt, .turbo, .svelte-kit, .parcel-cache | dist, build, out, coverage |
| Swift | .build, matching ~/Library/Developer/Xcode/DerivedData/<project>-<hash> | .swiftpm, Pods, Carthage/Build |
| Android | build, .gradle, .cxx next to a Gradle file | – |
Safety
- Stale projects with uncommitted changes or unpushed commits (repos with a remote) are listed
but skipped. Disable with
reclaim-cli config set skipDirty false. - A removal must be strictly inside its project (or DerivedData for Xcode); symlinks are never followed.
reclaim-cli clean --dry-runshows exactly what would be removed. Every removal is logged (reclaim-cli log).
Commands
reclaim-cli init interactive setup
reclaim-cli add|remove <folder> manage watched folders
reclaim-cli ignore <path> [--remove] never report a project at/below this path
reclaim-cli scan [--all] [--json] [--quiet] [--notify]
reclaim-cli review pick projects to clean interactively
reclaim-cli clean [paths…] [--dry-run] [-y]
reclaim-cli schedule install|uninstall|status [--at HH:mm]
reclaim-cli hook install|print terminal reminder + completion for new shells
reclaim-cli completion <zsh|bash|powershell> print the completion script
reclaim-cli snooze <3d|12h> | --clear mute reminders
reclaim-cli log [-n 20] history of removals
reclaim-cli config get [key] | set <key> <value>Terminal reminder and shell completion
reclaim-cli init offers to set this up, or run it yourself:
reclaim-cli hook installThis writes a per-platform hook script (zsh on macOS, bash on Linux, PowerShell on Windows) and sources it from your shell rc file. The script is
pure shell, so opening a terminal never starts Node and nothing breaks if reclaim-cli is not on your PATH.
On the first prompt it prints the pending reminder (compatible with Powerlevel10k's instant prompt, reminders
older than 3 days are ignored) and registers tab completion for reclaim-cli:
- commands and subcommands, with descriptions (
reclaim-cli sch<TAB>,reclaim-cli schedule <TAB>) - flags with descriptions (
reclaim-cli scan --<TAB>) - folders for
add,remove,ignoreandclean; setting names forconfig get|set, andtrue/falsefor boolean settings
The completion is generated from the CLI's own command tree. After upgrading, run
reclaim-cli hook install again to refresh it. It needs zsh's completion system (compinit), which
frameworks such as oh-my-zsh already enable.
Prefer to wire it up yourself? source <(reclaim-cli completion zsh) after compinit does the same.
Daily schedule
reclaim-cli schedule install installs a daily job (launchd on macOS, systemd/cron on Linux, Task Scheduler on Windows) that runs
reclaim-cli scan --notify --quiet at scheduleAt. The agent stores the absolute path to Node and to
reclaim-cli; if you switch Node versions, run reclaim-cli schedule install again (reclaim-cli schedule status
tells you when it's broken). If notifications are blocked, enable them under
System Settings → Notifications (Notification Center / toasts / notify-send).
Configuration
~/.config/reclaim-cli/config.json on macOS/Linux (%APPDATA%/reclaim-cli on Windows; state in ~/.local/state/reclaim-cli/, %LOCALAPPDATA%/reclaim-cli on Windows). Override locations with
RECLAIM_CLI_CONFIG_DIR / RECLAIM_CLI_STATE_DIR.
| Key | Default | |
|---|---|---|
| roots | [] | folders to scan |
| staleAfterDays | 60 | idle days before a project is stale |
| minReclaimableMB | 500 | minimum total before reminding |
| scheduleAt | "10:00" | daily scan time |
| notify | true | native notification from the daily scan |
| skipDirty | true | skip projects with uncommitted/unpushed work |
| maxDepth | 4 | how deep to look for project roots |
| types | ["node","swift","android"] | enabled project types |
| ignore | [] | paths to skip |
Extending
- New project type: implement
ProjectType(src/core/types.ts) insrc/types/and register it insrc/types/index.ts. - New scheduler/hook: implement
Scheduler/ShellHookfor your OS insrc/platform/<os>/and wire it insrc/platform/index.ts(paths, scheduler, notifier, shell hook).
Development
npm run dev # rebuild on change
npm test # vitest
npm run typecheck
npm run lint # biomeReleasing
Releases are published to npm from GitHub with trusted publishing
(no npm token). The workflow is .github/workflows/release.yml.
npm version patch|minor|major # bumps package.json, commits, tags vX.Y.Z
git push --follow-tags
gh release create vX.Y.Z --generate-notesPublishing the GitHub Release triggers the workflow, which checks that the tag matches
package.json, runs lint, typecheck, tests and build, then runs npm publish. Mark the release as a
pre-release to publish it under the next dist-tag instead of latest.
License
MIT
