io.github.om-tajne/pkgdiet
Put your node_modules on a diet - find unused dependencies, analyze health, and reduce size
Open source Open in the app JSON README (API)
About
Put your node_modules on a diet - find unused dependencies, analyze health, and reduce size
Details
- Kind
- MCP servers
- Topic
- Government & public data
- Publisher
- om-tajne
- Origin
- official
- Category
- ferramentas
- Transport
- local
- Version
- 1.2.1
- Stars
- 4
- Last push
- 2026-09-02T09:40:51Z
- Repository state
- ativo
- Language
- JavaScript
- License
- MIT
- Added
- 2026-09-01 21:00:09
- Updated
- 2026-09-01 21:00:09
- Origin id
io.github.om-tajne/pkgdiet
README
# ๐ฅ PkgDiet
[](https://www.npmjs.com/package/pkgdiet)
[](https://www.npmjs.com/package/pkgdiet)
[](LICENSE)
[](https://nodejs.org)
[](https://glama.ai/mcp/servers/om-tajne/pkgdiet)
Put your `node_modules` on a diet.
PkgDiet is a proactive dependency governance tool that helps you find unused dependencies, analyze package health, and reduce `node_modules` size. It doesn't just ask *"is it safe?"* โ it asks *"is it optimal?"*
> **Our Vision:** PkgDiet's mission is to become an open standard for dependency intelligence in AI-assisted software development. Our goal is simple: whenever a developer, CI pipeline, or compatible AI agent needs to evaluate, install, replace, or audit a dependency, PkgDiet should provide trusted, machine-readable insights through transparent, opt-in integrations.
---
## Quick Start
Run it instantly in any Node.js project (no installation required):
```bash
npx pkgdiet
```
To clean up unused dependencies automatically:
```bash
npx pkgdiet --fix
```
---
## What You Get
PkgDiet scans your codebase's AST and NPM registry data in seconds to give you a pristine, actionable report:
```text
- Scanning imports...
โ Scanned 141 files, found 54 imports
- Checking health of 44 packages...
โ Health check complete: 10 issues found
- Analyzing dependency sizes...
โ Size analysis complete: 40.5 MB total
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ ๐ฅ PkgDiet v1.2.3 โ
โ Put your node_modules on a diet... โ
โ Project: express โ
โ Dependencies: 44 direct โ 141 files scanned โ
โ node_modules: 40.5 MB โ
โ Overall Score: 67/100 โ ๏ธ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
๐๏ธ UNUSED DEPENDENCIES (1 found โ saves ~21.2 KB)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โซ hbs dev 21.2 KB โ npm uninstall hbs
๐ฅ HEALTH WARNINGS (10 issues)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Package Score Issue
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ด pbkdf2-password 29 Unmaintained (4yr) ยท Single maintainer ยท Low downloads
๐ด encodeurl 57 Unmaintained (2yr)
๐ก once 70 Single maintainer
๐ฆ SIZE ANALYSIS
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Package Install Size % of node_modules
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ง eslint 2.77 MB 6.8%
๐ง mocha 2.22 MB 5.5%
โ 42 other packages under 5% โ no action needed
๐ก BETTER ALTERNATIVES (1 suggestion)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ body-parser โ express.json() built into Express 4.16+, no separate install needed
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Action summary: 1 to remove ยท 10 to investigate ยท 1 to swap
Run pkgdiet --fix to remove unused ยท --json for full machine-readable output
```
---
## Features
- **AST-Based Unused Detection:** Safely flags installed packages that are never imported (handles TypeScript, JSX, dynamic imports, and NPM scripts).
- **Health & Rot Scoring:** Detects the "Bus Factor" (single maintainer) and abandoned packages before they become technical debt.
- **Smart Alternatives:** Recommends modern, lightweight replacements for legacy bloat (e.g., `dayjs` instead of `moment`, `picocolors` instead of `chalk`).
- **Pre-Install Gate:** Run `pkgdiet check <package>` to evaluate a library *before* adding it to your project.
- **MCP Server for AI Agents:** Give compatible AI coding assistants the ability to evaluate dependency health using PkgDiet's machine-readable data before recommending or installing packages. Install globally in one click: `npx pkgdiet mcp-install`
- **CI/CD Ready:** Use `pkgdiet ci` to parse `package-lock.json` diffs in GitHub Actions and block PRs that introduce unhealthy dependencies.
---
## Configuration
PkgDiet works out of the box with zero configuration. However, teams can enforce custom policies by running `npx pkgdiet init` to generate a `.pkgdietrc.json`:
```json
{
"minHealthScore": 60,
"maxNodeModulesSizeMB": 300,
"ignoreRules": ["chalk"],
"telemetry": false
}
```
### Telemetry (Local Only)
By default, PkgDiet writes anonymous, **purely local** usage metrics to a `.pkgdiet-metrics.json` file in your repository to track the amount of time and disk space saved. **No data is ever sent off your machine.** You can disable this local logging entirely by adding `"telemetry": false` to your `.pkgdietrc.json` or by setting the `PKGDIET_TELEMETRY_DISABLED=1` environment variable.
---
## Commands
| Command | Description |
|---|---|
| `npx pkgdiet` | Run full repository audit |
| `npx pkgdiet --fix` | Preview unused dependencies and apply approved removals |
| `npx pkgdiet check <pkg>` | Check health/size of a single package |
| `npx pkgdiet init` | Generate config and GitHub Actions workflows |
| `npx pkgdiet ci` | Run PR gate checks based on lockfile diffs |
| `npx pkgdiet mcp` | Start the JSON-RPC server for AI agents |
| `npx pkgdiet mcp-install` | Auto-configure MCP for Claude Desktop |
---
## License
MIT ยฉ [Om Tajne](https://github.com/om-tajne)