depshred 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/LICENSE +21 -0
- package/README.md +200 -2
- package/SKILLS.md +74 -0
- package/bin/depshred.js +7 -0
- package/package.json +47 -4
- package/skills/README.md +22 -0
- package/skills/agents/AGENTS.md +57 -0
- package/skills/antigravity/SKILL.md +60 -0
- package/skills/claude/CLAUDE.md +55 -0
- package/skills/cline/.clinerules +55 -0
- package/skills/copilot/copilot-instructions.md +55 -0
- package/skills/cursor/depshred.mdc +61 -0
- package/skills/depshred/SKILL.md +60 -0
- package/skills/windsurf/depshred.md +55 -0
- package/src/audit.js +222 -0
- package/src/cli.js +195 -0
- package/src/interactive.js +182 -0
- package/src/locator.js +272 -0
- package/src/registry.js +149 -0
- package/src/reporter.js +88 -0
- package/src/rules/alt-rules.js +30 -0
- package/src/rules/index.js +38 -0
- package/src/rules/native-rules.js +118 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Planned
|
|
11
|
+
- Interactive prompt to automatically execute `npm uninstall <pkg>` for confirmed removals.
|
|
12
|
+
- Generation of `depshred-migration.md` summary reports.
|
|
13
|
+
- Lockfile parsing (`package-lock.json`, `pnpm-lock.yaml`) to detect phantom dependencies.
|
|
14
|
+
- Official GitHub Action (`depshred/action`) for automated pull request checks.
|
|
15
|
+
- AST-powered automated code import rewriting.
|
|
16
|
+
|
|
17
|
+
## [1.0.0] - 2026-10-09
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- Universal dependency auditing scanning 100% of declared packages in `package.json`.
|
|
21
|
+
- Native Node.js standard library replacement detection for Node 18, 20, and 22+ built-ins (`dotenv`, `uuid`, `rimraf`, `mkdirp`, `nodemon`, `axios`, `glob`, `querystring`).
|
|
22
|
+
- Unused dependency detection mapping 0-import packages with copy-ready `npm uninstall` commands.
|
|
23
|
+
- `package.json` script command scanning to prevent false-positive unused warnings on CLI tools.
|
|
24
|
+
- Smart dormancy checking (>3 years) distinguishing self-contained zero-dependency modules from rotting software.
|
|
25
|
+
- Live npm registry metadata harvesting (unpacked size, transitive dependency counts, dormancy, deprecations).
|
|
26
|
+
- Zero-clutter metadata caching in OS temporary directory (`os.tmpdir()`) with 24-hour TTL.
|
|
27
|
+
- CLI execution modes: default interactive terminal explorer, `--check` CI exit code mode, `--strict`, and structured `--json` output.
|
|
28
|
+
- `--init-skill` command to automatically install agent vetting skills into Cursor, Copilot, Windsurf, Claude Code, Cline, and universal workspaces.
|
|
29
|
+
- Multi-IDE pre-flight vetting skill catalog in `skills/` and root `SKILLS.md`.
|
|
30
|
+
- Near-zero external dependencies architecture using Node.js standard library APIs and `picocolors`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 depshred contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,201 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/gozajpeg/depshred/master/assets/depshred.webp" width="200" alt="depshred logo">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h1 align="center">depshred</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<em>Clean up your node_modules. Stop installing stuff Node already has.</em>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://img.shields.io/badge/run_with-npx_depshred-111111?style=flat-square" alt="Run with npx">
|
|
13
|
+
<img src="https://img.shields.io/badge/node.js-18%2B_%7C_20%2B_%7C_22%2B-111111?style=flat-square" alt="Node Support">
|
|
14
|
+
<img src="https://img.shields.io/badge/version-1.0.1-111111?style=flat-square" alt="version 1.0.0">
|
|
15
|
+
<img src="https://img.shields.io/badge/license-MIT-111111?style=flat-square" alt="MIT license">
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
Ever look at your `node_modules` folder and wonder why it takes up half your hard drive?
|
|
21
|
+
|
|
22
|
+
When you follow tutorials or ask AI to write code, it is super easy to end up with 30 different packages installed for things modern Node can already do by itself. Stuff like `dotenv`, `uuid`, or `rimraf` do not need to be in your project anymore. Node already knows how to do all of that.
|
|
23
|
+
|
|
24
|
+
`depshred` looks through your project, finds packages you do not actually need, and shows you how to swap them for simple code that comes with Node.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
You do not even need to install anything first. Just open your terminal inside your project folder and run:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx depshred
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
If your project lives in another folder, just tell it where:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx depshred ./path/to/your-project
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Using pnpm or bun instead of npm? That works too:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pnpm dlx depshred
|
|
46
|
+
bunx depshred
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## What it looks like
|
|
52
|
+
|
|
53
|
+
Here is what you see when you run it in your terminal:
|
|
54
|
+
|
|
55
|
+
<p align="center">
|
|
56
|
+
<img src="https://raw.githubusercontent.com/gozajpeg/depshred/master/assets/view01.webp" width="100%" alt="depshred terminal interface">
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
You get an easy list you can move through with your arrow keys:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
+--------------------------------------------------------------------------+
|
|
63
|
+
| depshred v1.0.1 (Node v20.12.0) |
|
|
64
|
+
| Target: ./my-project |
|
|
65
|
+
+--------------------------------------------------------------------------+
|
|
66
|
+
| Total Scanned: 24 dependencies |
|
|
67
|
+
| |
|
|
68
|
+
| [CRITICAL] 2 packages have native Node.js replacements (saves ~182 KB) |
|
|
69
|
+
| [UNUSED] 1 package has 0 imports (run: npm uninstall rimraf) |
|
|
70
|
+
| [WARN] 1 package is dormant >3y (0 sub-deps, self-contained) |
|
|
71
|
+
| [OK] 20 packages are lean and actively maintained |
|
|
72
|
+
+--------------------------------------------------------------------------+
|
|
73
|
+
|
|
74
|
+
Select a dependency to inspect (Use arrow keys, Enter to inspect):
|
|
75
|
+
> [CRITICAL] dotenv Native Node.js built-in available (saves ~72 KB)
|
|
76
|
+
[CRITICAL] uuid Native Node.js built-in available (saves ~110 KB)
|
|
77
|
+
[UNUSED] rimraf 0 imports found in project source code
|
|
78
|
+
[WARN] ms Dormant >3 years | 0 sub-dependencies (self-contained)
|
|
79
|
+
[OK] fastify Active, schema-compiled and lean
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## What it checks for
|
|
85
|
+
|
|
86
|
+
When you run `depshred`, it checks three main things:
|
|
87
|
+
|
|
88
|
+
1. **Stuff Node already has built in**
|
|
89
|
+
Do you really need `dotenv` when Node can load `.env` files on its own? Do you need `uuid` when Node has `crypto.randomUUID()`? `depshred` finds every file and exact line number where you use these, and shows you the quick built-in way to replace them.
|
|
90
|
+
|
|
91
|
+
2. **Packages you installed but never use**
|
|
92
|
+
Ever ran `npm install` for a test or a guide, forgot about it, and left it sitting in your `package.json`? `depshred` scans your whole project. If you never imported it anywhere, it tells you straight up: `npm uninstall <package>`.
|
|
93
|
+
|
|
94
|
+
3. **Old or abandoned packages**
|
|
95
|
+
It checks npm to see how big each package is and whether anyone has touched it in the last 3 years. If a package is small, has zero other packages inside it, and just works, `depshred` lets you know so you do not have to worry.
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
Your package.json
|
|
99
|
+
|
|
|
100
|
+
+------------------+------------------+
|
|
101
|
+
| | |
|
|
102
|
+
v v v
|
|
103
|
+
1. Already in Node? 2. Used in code? 3. npm check
|
|
104
|
+
(dotenv, uuid, etc.) (0 imports found) (file size, age)
|
|
105
|
+
| | |
|
|
106
|
+
v v v
|
|
107
|
+
Use Node built-ins Safe to delete Good to know
|
|
108
|
+
(saves disk space) (npm uninstall) (see how big it is)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Extra options
|
|
114
|
+
|
|
115
|
+
Need to run it inside a script or change how it works? Here are the flags you can use:
|
|
116
|
+
|
|
117
|
+
| Flag | What it does |
|
|
118
|
+
| :--- | :--- |
|
|
119
|
+
| `--check` | Checks your project and stops with an error if it finds bad or useless packages. Great for GitHub Actions. |
|
|
120
|
+
| `--strict` | Like `--check`, but also stops on small warnings. |
|
|
121
|
+
| `--json` | Prints results as JSON so you can read them with code. |
|
|
122
|
+
| `--no-interactive` | Skips the arrow-key menu and just prints a plain table. |
|
|
123
|
+
| `--path <folder>` | Checks a different folder instead of where you are right now. |
|
|
124
|
+
| `--dormant-years <num>` | How many years without updates before calling a package old (defaults to 3). |
|
|
125
|
+
| `--ignore <names>` | Comma-separated names of packages you want to skip. |
|
|
126
|
+
| `--init-skill [app]` | Adds instructions to your AI editor so it stops installing packages you do not need. |
|
|
127
|
+
| `--help`, `-h` | Shows all available flags. |
|
|
128
|
+
| `--version`, `-v` | Shows the version number. |
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Teach your AI editor to stop installing junk
|
|
133
|
+
|
|
134
|
+
If you use AI coding tools like Cursor, Claude, Windsurf, or GitHub Copilot, you have probably seen them run `npm install` for every single little thing. Most of the time, Node already has what they are trying to download.
|
|
135
|
+
|
|
136
|
+
You can teach your AI helper to check first before installing:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Pick your editor from a menu:
|
|
140
|
+
npx depshred --init-skill
|
|
141
|
+
|
|
142
|
+
# Or pick your editor directly:
|
|
143
|
+
npx depshred --init-skill cursor # For Cursor (.cursor/rules)
|
|
144
|
+
npx depshred --init-skill copilot # For GitHub Copilot (.github)
|
|
145
|
+
npx depshred --init-skill windsurf # For Windsurf (.windsurf/rules)
|
|
146
|
+
npx depshred --init-skill claude # For Claude Code (CLAUDE.md)
|
|
147
|
+
npx depshred --init-skill cline # For Cline (.clinerules)
|
|
148
|
+
npx depshred --init-skill antigravity # For Antigravity (.agents/skills)
|
|
149
|
+
npx depshred --init-skill agents # For general agents (AGENTS.md)
|
|
150
|
+
npx depshred --init-skill all # Sets up all of them at once
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Want to see all the skill files and how they work? Check out [SKILLS.md](SKILLS.md).
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Save your settings
|
|
158
|
+
|
|
159
|
+
If there is a package you want `depshred` to leave alone, you can save your preferences right inside your `package.json`:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"depshred": {
|
|
164
|
+
"ignore": ["fast-deep-equal"],
|
|
165
|
+
"dormantYears": 4
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## What projects work with it?
|
|
173
|
+
|
|
174
|
+
Pretty much any modern Node.js project:
|
|
175
|
+
|
|
176
|
+
- **Any framework:** Express, Fastify, Next.js, NestJS, Koa, or plain Node scripts.
|
|
177
|
+
- **Any module style:** Both `import` (ES Modules) and `require` (CommonJS).
|
|
178
|
+
- **JavaScript and TypeScript:** `.js`, `.ts`, `.jsx`, `.tsx`, `.mjs`, `.cjs`.
|
|
179
|
+
- **Projects with multiple folders:** Works with monorepos using the `--path` flag.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Questions you might have
|
|
184
|
+
|
|
185
|
+
**Does it change my code automatically?**
|
|
186
|
+
No. `depshred` never touches your code behind your back. It shows you the file, the line number, and the built-in Node replacement. You decide what to change and when.
|
|
187
|
+
|
|
188
|
+
**Does it need a database or send my code to some server?**
|
|
189
|
+
No. Everything runs right on your computer. It only talks to the public npm website to check package sizes and update dates. It saves that info in your computer's temporary folder for a day so it stays fast.
|
|
190
|
+
|
|
191
|
+
**What if an old package works fine and does not need updates?**
|
|
192
|
+
Not every old package is broken. Some small tools are simply finished and do not need changes. `depshred` checks if the package has zero sub-packages. If it is small and self-contained, it gives you a soft heads-up, not a red error. You can also add it to your ignore list.
|
|
193
|
+
|
|
194
|
+
**Does it work with Python or Go?**
|
|
195
|
+
No, this is built only for Node.js and npm projects.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
[MIT](LICENSE).
|
package/SKILLS.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# depshred: Universal Agent Skill Catalog & Pre-Flight Vetting
|
|
2
|
+
|
|
3
|
+
`depshred` provides a standardized dependency hygiene skill for AI coding agents and human developers. It enforces pre-flight vetting to prevent unnecessary `npm install` operations when Node.js natively handles the requested functionality.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The Mandatory 4-Step Pre-Flight Vetting Order
|
|
8
|
+
|
|
9
|
+
When tasked with adding functionality to a Node.js project, an agent MUST NOT blindly run `npm install <package>`. Follow this order:
|
|
10
|
+
|
|
11
|
+
### Step 0: The Native Standard Library Check (Zero Packages)
|
|
12
|
+
|
|
13
|
+
Before reaching for npm, verify if modern Node.js already includes this functionality natively:
|
|
14
|
+
|
|
15
|
+
| Wanted Functionality | DO NOT Install | USE INSTEAD (Node Standard Library) | Minimum Node |
|
|
16
|
+
| :--- | :--- | :--- | :--- |
|
|
17
|
+
| Environment variables | `dotenv` | Native CLI flag `node --env-file=.env` | Node 20.6.0+ |
|
|
18
|
+
| UUID generation | `uuid` | `crypto.randomUUID()` from `node:crypto` | Node 15.6.0+ |
|
|
19
|
+
| Recursive folder deletion | `rimraf` | `fs.rmSync(path, { recursive: true, force: true })` | Node 14.14.0+ |
|
|
20
|
+
| Recursive directory creation | `mkdirp` | `fs.mkdirSync(path, { recursive: true })` | Node 10.12.0+ |
|
|
21
|
+
| Development file watching | `nodemon` | `node --watch server.js` | Node 18.11.0+ |
|
|
22
|
+
| HTTP requests | `axios`, `node-fetch` | Native global `fetch()` | Node 18.0.0+ |
|
|
23
|
+
| File glob matching | `glob` | `fs.globSync(pattern)` from `node:fs` | Node 22.0.0+ |
|
|
24
|
+
| URL query parameters | `querystring` | `URLSearchParams` / `new URL()` | Node 10.0.0+ |
|
|
25
|
+
|
|
26
|
+
If the target Node version supports the native feature, **do not install any package**. Write the native implementation directly.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### Step 1: The Existing Codebase & Unused Dependency Check
|
|
31
|
+
|
|
32
|
+
Before adding any package, inspect what is already in the project:
|
|
33
|
+
1. **Check for Unused Packages:** Grep `package.json` against project imports. If dead, unimported dependencies exist, flag them for cleanup rather than adding more clutter.
|
|
34
|
+
2. **Reuse Existing Dependencies:** If a library is already installed (e.g. `fastify`, utility libraries), leverage its built-in modules instead of adding a competing package.
|
|
35
|
+
3. **Check Internal Utilities:** Check `src/utils/` or shared helpers. Never add an external dependency for logic that already exists in the codebase.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### Step 2: Vetting New Dependencies (When an install is truly necessary)
|
|
40
|
+
|
|
41
|
+
If no native API or existing helper exists, vet the candidate package before running install:
|
|
42
|
+
1. **Check Maintenance & Dormancy:**
|
|
43
|
+
- Avoid packages that have not published updates in >3 years, unless they are confirmed feature-complete, zero-dependency modules (e.g. self-contained parsers).
|
|
44
|
+
- Check for official npm deprecation warnings.
|
|
45
|
+
2. **Check Transitive Dependency Fan-out:** Prefer zero-dependency or single-purpose packages over monolithic bundles that pull in dozens of nested sub-dependencies.
|
|
46
|
+
3. **Prefer Modern Lightweight Equivalents:**
|
|
47
|
+
- Date manipulation: Use native `Intl.DateTimeFormat`, `date-fns`, or `dayjs` over legacy `moment`.
|
|
48
|
+
- Terminal styling: Use `picocolors` (sub-7KB, zero dependencies) over heavy `chalk` chains.
|
|
49
|
+
- Utility helpers: Use native ES6+ methods (`map`, `filter`, `structuredClone`) or `es-toolkit` over monolithic `lodash`.
|
|
50
|
+
- Password hashing: Prefer native `crypto.scrypt` or pure JS `bcryptjs` over packages requiring node-gyp C++ compilation unless explicitly required for performance.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### Step 3: Post-Change Verification
|
|
55
|
+
|
|
56
|
+
After adding or removing dependencies:
|
|
57
|
+
1. Verify `package.json` and lockfile are clean and committed.
|
|
58
|
+
2. Run project tests or `node --check` to ensure no broken imports remain.
|
|
59
|
+
3. If `depshred` is available, run `npx depshred --check` to verify that no new dependency bloat or unused packages were introduced.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Multi-IDE & Agent Export Formats
|
|
64
|
+
|
|
65
|
+
For IDE-specific and agent-native configurations, use the tailored rule files located in the [`skills/`](skills/) folder:
|
|
66
|
+
|
|
67
|
+
| IDE / Agent | Configuration File | Target Path in User Project |
|
|
68
|
+
| :--- | :--- | :--- |
|
|
69
|
+
| **Cursor** | [`skills/cursor/depshred.mdc`](skills/cursor/depshred.mdc) | `.cursor/rules/depshred.mdc` |
|
|
70
|
+
| **GitHub Copilot** | [`skills/copilot/copilot-instructions.md`](skills/copilot/copilot-instructions.md) | `.github/copilot-instructions.md` |
|
|
71
|
+
| **Windsurf (Codeium)** | [`skills/windsurf/depshred.md`](skills/windsurf/depshred.md) | `.windsurf/rules/depshred.md` or `.windsurfrules` |
|
|
72
|
+
| **Claude Code** | [`skills/claude/CLAUDE.md`](skills/claude/CLAUDE.md) | `CLAUDE.md` |
|
|
73
|
+
| **Cline / Roo Code** | [`skills/cline/.clinerules`](skills/cline/.clinerules) | `.clinerules` |
|
|
74
|
+
| **Universal / Antigravity** | [`skills/depshred/SKILL.md`](skills/depshred/SKILL.md) | `.agents/skills/depshred/SKILL.md` |
|
package/bin/depshred.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "depshred",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Shred dependency bloat. Embrace modern Node.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/cli.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"depshred": "bin/depshred.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"src",
|
|
13
|
+
"skills",
|
|
14
|
+
"README.md",
|
|
15
|
+
"CHANGELOG.md",
|
|
16
|
+
"SKILLS.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18.0.0"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"start": "node ./bin/depshred.js",
|
|
24
|
+
"test": "node --test test/*.test.js"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"dependencies",
|
|
28
|
+
"audit",
|
|
29
|
+
"bloat",
|
|
30
|
+
"unused-dependencies",
|
|
31
|
+
"cli",
|
|
32
|
+
"e18e",
|
|
33
|
+
"nodejs",
|
|
34
|
+
"npm"
|
|
35
|
+
],
|
|
36
|
+
"author": "gozajpeg",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/gozajpeg/depshred.git"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/gozajpeg/depshred/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/gozajpeg/depshred#readme",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"picocolors": "^1.1.1"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/skills/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# depshred Agent Skills & IDE Rules Catalog
|
|
2
|
+
|
|
3
|
+
This directory contains pre-configured dependency hygiene and pre-flight vetting instructions formatted for all major AI coding agents and IDEs.
|
|
4
|
+
|
|
5
|
+
## Supported IDEs & Agents
|
|
6
|
+
|
|
7
|
+
| IDE / Agent | Configuration File | Native Location |
|
|
8
|
+
| :--- | :--- | :--- |
|
|
9
|
+
| **Cursor** | `skills/cursor/depshred.mdc` | `.cursor/rules/depshred.mdc` |
|
|
10
|
+
| **GitHub Copilot / VS Code** | `skills/copilot/copilot-instructions.md` | `.github/copilot-instructions.md` |
|
|
11
|
+
| **Windsurf (Codeium)** | `skills/windsurf/depshred.md` | `.windsurf/rules/depshred.md` or `.windsurfrules` |
|
|
12
|
+
| **Claude Code (Anthropic)** | `skills/claude/CLAUDE.md` | `CLAUDE.md` |
|
|
13
|
+
| **Cline / Roo Code** | `skills/cline/.clinerules` | `.clinerules` |
|
|
14
|
+
| **Universal / Antigravity** | `skills/depshred/SKILL.md` | `.agents/skills/depshred/SKILL.md` |
|
|
15
|
+
|
|
16
|
+
## How It Works
|
|
17
|
+
|
|
18
|
+
Each configuration prevents AI agents from blindly executing `npm install <package>` by enforcing a mandatory 4-step pre-flight check:
|
|
19
|
+
1. **Step 0:** Native Node.js standard library check (zero external packages).
|
|
20
|
+
2. **Step 1:** Existing codebase and unused dependency inspection.
|
|
21
|
+
3. **Step 2:** Vetting new dependencies (avoiding dormancy >3 years, checking sub-dependencies, preferring lightweight alternatives).
|
|
22
|
+
4. **Step 3:** Post-change verification (`depshred --check`).
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# depshred: AI Coding Agent Operating Instructions
|
|
2
|
+
|
|
3
|
+
This file instructs AI coding agents (Claude, Cursor, Copilot, Antigravity, OpenHands, Devin) on how to work on and maintain the `depshred` codebase.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Architecture & Design Principles
|
|
8
|
+
|
|
9
|
+
* **Pure Node.js ES Modules:** `"type": "module"`. No CommonJS, no Babel, no TypeScript compilation step.
|
|
10
|
+
* **Zero Build Step:** Code in `src/` runs directly in Node.js.
|
|
11
|
+
* **Near-Zero External Dependencies:** Only `picocolors` is allowed in `dependencies`. Never add external dependencies for tasks that the Node.js standard library handles.
|
|
12
|
+
* **Standard Library First:**
|
|
13
|
+
* CLI options: `node:util.parseArgs`
|
|
14
|
+
* File walking & reading: `node:fs` / `node:fs/promises`
|
|
15
|
+
* Path resolution: `node:path`
|
|
16
|
+
* OS temporary caching: `node:os` (`tmpdir()`)
|
|
17
|
+
* UUID & hashing: `node:crypto`
|
|
18
|
+
* Networking: Native global `fetch()`
|
|
19
|
+
* Testing: Native `node:test` (`node --test`)
|
|
20
|
+
* **Zero Emojis:** Strictly zero emojis across all code, terminal output, and documentation files.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 2. Essential Commands
|
|
25
|
+
|
|
26
|
+
* **Run CLI locally:** `node ./bin/depshred.js`
|
|
27
|
+
* **Run Self-Audit:** `node ./bin/depshred.js --check`
|
|
28
|
+
* **Run Test Suite:** `npm test` or `node --test test/*.test.js`
|
|
29
|
+
* **Test Fixtures:** `node ./bin/depshred.js ./test/fixtures/legacy-app --check`
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 3. Mandatory Pre-Flight Dependency Vetting Order
|
|
34
|
+
|
|
35
|
+
When asked to add functionality to this or any Node.js project, NEVER blindly run `npm install <package>`. Follow this 4-step order:
|
|
36
|
+
|
|
37
|
+
### Step 0: The Native Standard Library Check
|
|
38
|
+
Before reaching for npm, verify if modern Node.js already includes this natively:
|
|
39
|
+
- `dotenv` -> Native CLI flag `node --env-file=.env` (Node 20.6.0+)
|
|
40
|
+
- `uuid` -> Native `crypto.randomUUID()` (Node 15.6.0+)
|
|
41
|
+
- `rimraf` -> Native `fs.rmSync(path, { recursive: true, force: true })` (Node 14.14.0+)
|
|
42
|
+
- `mkdirp` -> Native `fs.mkdirSync(path, { recursive: true })` (Node 10.12.0+)
|
|
43
|
+
- `nodemon` -> Native file watcher `node --watch server.js` (Node 18.11.0+)
|
|
44
|
+
- `axios` / `node-fetch` -> Native global `fetch()` (Node 18.0.0+)
|
|
45
|
+
- `glob` -> Native `fs.globSync(pattern)` (Node 22.0.0+)
|
|
46
|
+
- `querystring` -> Native `URLSearchParams` / `new URL()` (Node 10.0.0+)
|
|
47
|
+
|
|
48
|
+
### Step 1: Existing Codebase Check
|
|
49
|
+
Check `package.json` and internal utilities in `src/` before adding any new package.
|
|
50
|
+
|
|
51
|
+
### Step 2: Vetting New Dependencies
|
|
52
|
+
- Avoid packages with no updates in >3 years unless confirmed zero-dependency, feature-complete modules.
|
|
53
|
+
- Prefer lightweight alternatives (`picocolors` over `chalk`, `dayjs` over `moment`).
|
|
54
|
+
|
|
55
|
+
### Step 3: Post-Change Verification
|
|
56
|
+
- Run tests: `npm test`.
|
|
57
|
+
- Verify clean audit: `node ./bin/depshred.js --check`.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: depshred
|
|
3
|
+
description: Pre-installation dependency hygiene and vetting for Node.js. Forces agents to check for native Node.js standard library built-ins, existing project utilities, and lightweight alternatives before running npm install or yarn/pnpm add.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# depshred: Agent Dependency Hygiene & Pre-Flight Vetting
|
|
7
|
+
|
|
8
|
+
When an agent is tasked with adding functionality to a Node.js project, it MUST NOT blindly run `npm install <package>`. Follow this mandatory 4-step pre-flight vetting order:
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Step 0: The Native Standard Library Check (Zero Packages)
|
|
13
|
+
|
|
14
|
+
Before reaching for npm, verify if modern Node.js already includes this functionality natively:
|
|
15
|
+
|
|
16
|
+
| Wanted Functionality | DO NOT Install | USE INSTEAD (Node Standard Library) | Minimum Node |
|
|
17
|
+
| :--- | :--- | :--- | :--- |
|
|
18
|
+
| Environment variables | `dotenv` | Native CLI flag `node --env-file=.env` | Node 20.6.0+ |
|
|
19
|
+
| UUID generation | `uuid` | `crypto.randomUUID()` from `node:crypto` | Node 15.6.0+ |
|
|
20
|
+
| Recursive folder deletion | `rimraf` | `fs.rmSync(path, { recursive: true, force: true })` | Node 14.14.0+ |
|
|
21
|
+
| Recursive directory creation | `mkdirp` | `fs.mkdirSync(path, { recursive: true })` | Node 10.12.0+ |
|
|
22
|
+
| Development file watching | `nodemon` | `node --watch server.js` | Node 18.11.0+ |
|
|
23
|
+
| HTTP requests | `axios`, `node-fetch` | Native global `fetch()` | Node 18.0.0+ |
|
|
24
|
+
| File glob matching | `glob` | `fs.globSync(pattern)` from `node:fs` | Node 22.0.0+ |
|
|
25
|
+
| URL query parameters | `querystring` | `URLSearchParams` / `new URL()` | Node 10.0.0+ |
|
|
26
|
+
|
|
27
|
+
If the target Node version supports the native feature, **do not install any package**. Write the native implementation directly.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Step 1: The Existing Codebase & Unused Dependency Check
|
|
32
|
+
|
|
33
|
+
Before adding any package, inspect what is already in the project:
|
|
34
|
+
1. **Check for Unused Packages:** Grep `package.json` against project imports. If dead, unimported dependencies exist, note them for cleanup rather than adding more clutter.
|
|
35
|
+
2. **Reuse Existing Dependencies:** If a library is already installed (e.g. `fastify`, utility libraries), leverage its built-in modules instead of adding a competing package.
|
|
36
|
+
3. **Check Internal Utilities:** Check `src/utils/` or shared helpers. Never add an external dependency for logic that already exists in the codebase.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Step 2: Vetting New Dependencies (When an install is truly necessary)
|
|
41
|
+
|
|
42
|
+
If no native API or existing helper exists, vet the candidate package before running install:
|
|
43
|
+
1. **Check Maintenance & Dormancy:**
|
|
44
|
+
- Avoid packages that have not published updates in >3 years, unless they are confirmed feature-complete, zero-dependency modules (e.g. self-contained parsers).
|
|
45
|
+
- Check for official npm deprecation warnings.
|
|
46
|
+
2. **Check Transitive Dependency Fan-out:** Prefer zero-dependency or single-purpose packages over monolithic bundles that pull in dozens of nested sub-dependencies.
|
|
47
|
+
3. **Prefer Modern Lightweight Equivalents:**
|
|
48
|
+
- Date manipulation: Use native `Intl.DateTimeFormat`, `date-fns`, or `dayjs` over legacy `moment`.
|
|
49
|
+
- Terminal styling: Use `picocolors` (sub-7KB, zero dependencies) over heavy `chalk` chains.
|
|
50
|
+
- Utility helpers: Use native ES6+ methods (`map`, `filter`, `structuredClone`) or `es-toolkit` over monolithic `lodash`.
|
|
51
|
+
- Password hashing: Prefer native `crypto.scrypt` or pure JS `bcryptjs` over packages requiring node-gyp C++ compilation unless explicitly required for performance.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Step 3: Post-Change Verification
|
|
56
|
+
|
|
57
|
+
After adding or removing dependencies:
|
|
58
|
+
1. Verify `package.json` and lockfile are clean and committed.
|
|
59
|
+
2. Run project tests or `node --check` to ensure no broken imports remain.
|
|
60
|
+
3. If `depshred` is available, run `npx depshred --check` to verify that no new dependency bloat or unused packages were introduced.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# depshred: Agent Dependency Hygiene & Pre-Flight Vetting
|
|
2
|
+
|
|
3
|
+
When an agent is tasked with adding functionality to a Node.js project, it MUST NOT blindly run `npm install <package>`. Follow this mandatory 4-step pre-flight vetting order:
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Step 0: The Native Standard Library Check (Zero Packages)
|
|
8
|
+
|
|
9
|
+
Before reaching for npm, verify if modern Node.js already includes this functionality natively:
|
|
10
|
+
|
|
11
|
+
| Wanted Functionality | DO NOT Install | USE INSTEAD (Node Standard Library) | Minimum Node |
|
|
12
|
+
| :--- | :--- | :--- | :--- |
|
|
13
|
+
| Environment variables | `dotenv` | Native CLI flag `node --env-file=.env` | Node 20.6.0+ |
|
|
14
|
+
| UUID generation | `uuid` | `crypto.randomUUID()` from `node:crypto` | Node 15.6.0+ |
|
|
15
|
+
| Recursive folder deletion | `rimraf` | `fs.rmSync(path, { recursive: true, force: true })` | Node 14.14.0+ |
|
|
16
|
+
| Recursive directory creation | `mkdirp` | `fs.mkdirSync(path, { recursive: true })` | Node 10.12.0+ |
|
|
17
|
+
| Development file watching | `nodemon` | `node --watch server.js` | Node 18.11.0+ |
|
|
18
|
+
| HTTP requests | `axios`, `node-fetch` | Native global `fetch()` | Node 18.0.0+ |
|
|
19
|
+
| File glob matching | `glob` | `fs.globSync(pattern)` from `node:fs` | Node 22.0.0+ |
|
|
20
|
+
| URL query parameters | `querystring` | `URLSearchParams` / `new URL()` | Node 10.0.0+ |
|
|
21
|
+
|
|
22
|
+
If the target Node version supports the native feature, **do not install any package**. Write the native implementation directly.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Step 1: The Existing Codebase & Unused Dependency Check
|
|
27
|
+
|
|
28
|
+
Before adding any package, inspect what is already in the project:
|
|
29
|
+
1. **Check for Unused Packages:** Grep `package.json` against project imports. If dead, unimported dependencies exist, note them for cleanup rather than adding more clutter.
|
|
30
|
+
2. **Reuse Existing Dependencies:** If a library is already installed (e.g. `fastify`, utility libraries), leverage its built-in modules instead of adding a competing package.
|
|
31
|
+
3. **Check Internal Utilities:** Check `src/utils/` or shared helpers. Never add an external dependency for logic that already exists in the codebase.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Step 2: Vetting New Dependencies (When an install is truly necessary)
|
|
36
|
+
|
|
37
|
+
If no native API or existing helper exists, vet the candidate package before running install:
|
|
38
|
+
1. **Check Maintenance & Dormancy:**
|
|
39
|
+
- Avoid packages that have not published updates in >3 years, unless they are confirmed feature-complete, zero-dependency modules (e.g. self-contained parsers).
|
|
40
|
+
- Check for official npm deprecation warnings.
|
|
41
|
+
2. **Check Transitive Dependency Fan-out:** Prefer zero-dependency or single-purpose packages over monolithic bundles that pull in dozens of nested sub-dependencies.
|
|
42
|
+
3. **Prefer Modern Lightweight Equivalents:**
|
|
43
|
+
- Date manipulation: Use native `Intl.DateTimeFormat`, `date-fns`, or `dayjs` over legacy `moment`.
|
|
44
|
+
- Terminal styling: Use `picocolors` (sub-7KB, zero dependencies) over heavy `chalk` chains.
|
|
45
|
+
- Utility helpers: Use native ES6+ methods (`map`, `filter`, `structuredClone`) or `es-toolkit` over monolithic `lodash`.
|
|
46
|
+
- Password hashing: Prefer native `crypto.scrypt` or pure JS `bcryptjs` over packages requiring node-gyp C++ compilation unless explicitly required for performance.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Step 3: Post-Change Verification
|
|
51
|
+
|
|
52
|
+
After adding or removing dependencies:
|
|
53
|
+
1. Verify `package.json` and lockfile are clean and committed.
|
|
54
|
+
2. Run project tests or `node --check` to ensure no broken imports remain.
|
|
55
|
+
3. If `depshred` is available, run `npx depshred --check` to verify that no new dependency bloat or unused packages were introduced.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# depshred: Agent Dependency Hygiene & Pre-Flight Vetting
|
|
2
|
+
|
|
3
|
+
When an agent is tasked with adding functionality to a Node.js project, it MUST NOT blindly run `npm install <package>`. Follow this mandatory 4-step pre-flight vetting order:
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Step 0: The Native Standard Library Check (Zero Packages)
|
|
8
|
+
|
|
9
|
+
Before reaching for npm, verify if modern Node.js already includes this functionality natively:
|
|
10
|
+
|
|
11
|
+
| Wanted Functionality | DO NOT Install | USE INSTEAD (Node Standard Library) | Minimum Node |
|
|
12
|
+
| :--- | :--- | :--- | :--- |
|
|
13
|
+
| Environment variables | `dotenv` | Native CLI flag `node --env-file=.env` | Node 20.6.0+ |
|
|
14
|
+
| UUID generation | `uuid` | `crypto.randomUUID()` from `node:crypto` | Node 15.6.0+ |
|
|
15
|
+
| Recursive folder deletion | `rimraf` | `fs.rmSync(path, { recursive: true, force: true })` | Node 14.14.0+ |
|
|
16
|
+
| Recursive directory creation | `mkdirp` | `fs.mkdirSync(path, { recursive: true })` | Node 10.12.0+ |
|
|
17
|
+
| Development file watching | `nodemon` | `node --watch server.js` | Node 18.11.0+ |
|
|
18
|
+
| HTTP requests | `axios`, `node-fetch` | Native global `fetch()` | Node 18.0.0+ |
|
|
19
|
+
| File glob matching | `glob` | `fs.globSync(pattern)` from `node:fs` | Node 22.0.0+ |
|
|
20
|
+
| URL query parameters | `querystring` | `URLSearchParams` / `new URL()` | Node 10.0.0+ |
|
|
21
|
+
|
|
22
|
+
If the target Node version supports the native feature, **do not install any package**. Write the native implementation directly.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Step 1: The Existing Codebase & Unused Dependency Check
|
|
27
|
+
|
|
28
|
+
Before adding any package, inspect what is already in the project:
|
|
29
|
+
1. **Check for Unused Packages:** Grep `package.json` against project imports. If dead, unimported dependencies exist, note them for cleanup rather than adding more clutter.
|
|
30
|
+
2. **Reuse Existing Dependencies:** If a library is already installed (e.g. `fastify`, utility libraries), leverage its built-in modules instead of adding a competing package.
|
|
31
|
+
3. **Check Internal Utilities:** Check `src/utils/` or shared helpers. Never add an external dependency for logic that already exists in the codebase.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Step 2: Vetting New Dependencies (When an install is truly necessary)
|
|
36
|
+
|
|
37
|
+
If no native API or existing helper exists, vet the candidate package before running install:
|
|
38
|
+
1. **Check Maintenance & Dormancy:**
|
|
39
|
+
- Avoid packages that have not published updates in >3 years, unless they are confirmed feature-complete, zero-dependency modules (e.g. self-contained parsers).
|
|
40
|
+
- Check for official npm deprecation warnings.
|
|
41
|
+
2. **Check Transitive Dependency Fan-out:** Prefer zero-dependency or single-purpose packages over monolithic bundles that pull in dozens of nested sub-dependencies.
|
|
42
|
+
3. **Prefer Modern Lightweight Equivalents:**
|
|
43
|
+
- Date manipulation: Use native `Intl.DateTimeFormat`, `date-fns`, or `dayjs` over legacy `moment`.
|
|
44
|
+
- Terminal styling: Use `picocolors` (sub-7KB, zero dependencies) over heavy `chalk` chains.
|
|
45
|
+
- Utility helpers: Use native ES6+ methods (`map`, `filter`, `structuredClone`) or `es-toolkit` over monolithic `lodash`.
|
|
46
|
+
- Password hashing: Prefer native `crypto.scrypt` or pure JS `bcryptjs` over packages requiring node-gyp C++ compilation unless explicitly required for performance.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Step 3: Post-Change Verification
|
|
51
|
+
|
|
52
|
+
After adding or removing dependencies:
|
|
53
|
+
1. Verify `package.json` and lockfile are clean and committed.
|
|
54
|
+
2. Run project tests or `node --check` to ensure no broken imports remain.
|
|
55
|
+
3. If `depshred` is available, run `npx depshred --check` to verify that no new dependency bloat or unused packages were introduced.
|