{
  "markdown": "# 🥗 PkgDiet\n\n[![npm version](https://img.shields.io/npm/v/pkgdiet)](https://www.npmjs.com/package/pkgdiet)\n[![npm downloads](https://img.shields.io/npm/dm/pkgdiet)](https://www.npmjs.com/package/pkgdiet)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)\n[![Node.js >=18](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)\n[![PkgDiet MCP Server Score](https://glama.ai/mcp/servers/om-tajne/pkgdiet/badges/score.svg)](https://glama.ai/mcp/servers/om-tajne/pkgdiet)\n\nPut your `node_modules` on a diet.\n\nPkgDiet 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?\"*\n\n> **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.\n\n---\n\n## Quick Start\n\nRun it instantly in any Node.js project (no installation required):\n\n```bash\nnpx pkgdiet\n```\n\nTo clean up unused dependencies automatically:\n```bash\nnpx pkgdiet --fix\n```\n\n---\n\n## What You Get\n\nPkgDiet scans your codebase's AST and NPM registry data in seconds to give you a pristine, actionable report:\n\n```text\n- Scanning imports...\n✓ Scanned 141 files, found 54 imports\n- Checking health of 44 packages...\n✓ Health check complete: 10 issues found\n- Analyzing dependency sizes...\n✓ Size analysis complete: 40.5 MB total\n\n╭──────────────────────────────────────────────────────╮\n│ 🥗 PkgDiet v1.2.3                                    │\n│ Put your node_modules on a diet...                   │\n│ Project: express                                     │\n│ Dependencies: 44 direct │ 141 files scanned          │\n│ node_modules: 40.5 MB                                │\n│    Overall Score:  67/100  ⚠️                        │\n│    ████████████████████░░░░░░░░░░                    │\n╰──────────────────────────────────────────────────────╯\n\n🗑️  UNUSED DEPENDENCIES (1 found — saves ~21.2 KB)\n────────────────────────────────────────────────────────\n   ⚫ hbs                      dev      21.2 KB      → npm uninstall hbs\n\n🏥  HEALTH WARNINGS (10 issues)\n────────────────────────────────────────────────────────\n   Package                    Score    Issue\n   ──────────────────────────────────────────────────────────────────────\n   🔴 pbkdf2-password          29       Unmaintained (4yr) · Single maintainer · Low downloads\n   🔴 encodeurl                57       Unmaintained (2yr)\n   🟡 once                     70       Single maintainer\n\n📦  SIZE ANALYSIS\n────────────────────────────────────────────────────────\n   Package                      Install Size    % of node_modules\n   ─────────────────────────────────────────────────────────────────\n   🟧 eslint                     2.77 MB         6.8%\n   🟧 mocha                      2.22 MB         5.5%\n   ✓  42 other packages under 5% — no action needed\n\n💡  BETTER ALTERNATIVES (1 suggestion)\n────────────────────────────────────────────────────────\n   🔌 body-parser → express.json() built into Express 4.16+, no separate install needed\n\n────────────────────────────────────────────────────────\n  Action summary: 1 to remove · 10 to investigate · 1 to swap\n  Run pkgdiet --fix to remove unused · --json for full machine-readable output\n```\n\n---\n\n## Features\n\n- **AST-Based Unused Detection:** Safely flags installed packages that are never imported (handles TypeScript, JSX, dynamic imports, and NPM scripts).\n- **Health & Rot Scoring:** Detects the \"Bus Factor\" (single maintainer) and abandoned packages before they become technical debt.\n- **Smart Alternatives:** Recommends modern, lightweight replacements for legacy bloat (e.g., `dayjs` instead of `moment`, `picocolors` instead of `chalk`).\n- **Pre-Install Gate:** Run `pkgdiet check <package>` to evaluate a library *before* adding it to your project.\n- **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`\n- **CI/CD Ready:** Use `pkgdiet ci` to parse `package-lock.json` diffs in GitHub Actions and block PRs that introduce unhealthy dependencies.\n\n---\n\n## Configuration\n\nPkgDiet works out of the box with zero configuration. However, teams can enforce custom policies by running `npx pkgdiet init` to generate a `.pkgdietrc.json`:\n\n```json\n{\n  \"minHealthScore\": 60,\n  \"maxNodeModulesSizeMB\": 300,\n  \"ignoreRules\": [\"chalk\"],\n  \"telemetry\": false\n}\n```\n\n### Telemetry (Local Only)\nBy 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.\n\n---\n\n## Commands\n\n| Command | Description |\n|---|---|\n| `npx pkgdiet` | Run full repository audit |\n| `npx pkgdiet --fix` | Preview unused dependencies and apply approved removals |\n| `npx pkgdiet check <pkg>` | Check health/size of a single package |\n| `npx pkgdiet init` | Generate config and GitHub Actions workflows |\n| `npx pkgdiet ci` | Run PR gate checks based on lockfile diffs |\n| `npx pkgdiet mcp` | Start the JSON-RPC server for AI agents |\n| `npx pkgdiet mcp-install` | Auto-configure MCP for Claude Desktop |\n\n---\n\n## License\n\nMIT © [Om Tajne](https://github.com/om-tajne)\n\n",
  "bytes": 5828,
  "sha": "8368cb39d546be7b7e3084dbe80a2b169c43a1152454acd33b7b0c20d1d6ea02",
  "repo_slug": "om-tajne/pkgdiet",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_om_tajne_pkgdiet_b712c2fe/readme"
}