noah-cursor 1.2.0 → 1.4.0

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.
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: nestjs-knip-fix
3
+ description: >-
4
+ Runs Knip on NestJS projects, constructs fixes for unused files, exports, and
5
+ dependencies, and verifies that implementations, features, and functionalities
6
+ are not broken after changes. Use when the user runs /nestjs-knip-fix, asks
7
+ to run knip on NestJS, clean up unused NestJS code, or fix Knip findings
8
+ without regressions.
9
+ disable-model-invocation: true
10
+ ---
11
+
12
+ # /nestjs-knip-fix
13
+
14
+ Run **`npx knip`** on a **NestJS** app, fix **all** findings, and prove behavior still works.
15
+
16
+ Do **not** stop after the first issue type. Do **not** mass-ignore. Prefer root-cause removals and export cleanups. After every batch of edits, re-verify so implementations, features, and functionalities are not broken.
17
+
18
+ ## Workflow
19
+
20
+ Copy this checklist and track progress:
21
+
22
+ ```
23
+ NestJS Knip Fix Progress:
24
+ - [ ] 1. Confirm NestJS project + verification commands
25
+ - [ ] 2. Ensure Knip config (Nest-aware)
26
+ - [ ] 3. Baseline knip scan
27
+ - [ ] 4. Triage findings (priority order)
28
+ - [ ] 5. Fix in batches (explain → edit → verify)
29
+ - [ ] 6. Re-scan until clean (or document intentional leftovers)
30
+ - [ ] 7. Final verification + report
31
+ ```
32
+
33
+ ### 1. Confirm NestJS project + verification commands
34
+
35
+ From the project root:
36
+
37
+ 1. Confirm NestJS (`@nestjs/core` in `package.json`, usually `nest-cli.json` / `src/main.ts`) — abort if not.
38
+ 2. Detect verification commands (prefer existing scripts):
39
+
40
+ ```bash
41
+ npm test # or pnpm / yarn / bun
42
+ npm run test:e2e
43
+ npm run build # nest build / tsc
44
+ npm run lint
45
+ npx tsc --noEmit
46
+ ```
47
+
48
+ Record the chosen commands before editing.
49
+
50
+ ### 2. Ensure Knip config (Nest-aware)
51
+
52
+ If the project has no `knip.json` / `knip.ts` / `knip` field in `package.json`, copy the skill template into the project root as `knip.json`:
53
+
54
+ - Template: [`config/knip.nestjs.json`](config/knip.nestjs.json)
55
+
56
+ Adjust `entry` / `project` for monorepos (`apps/*`, `libs/*`) when needed. Prefer extending the template over inventing a blank config.
57
+
58
+ Do not overwrite an existing Knip config unless the user asks — merge Nest entry patterns into the existing config instead.
59
+
60
+ ### 3. Baseline knip scan
61
+
62
+ ```bash
63
+ npx knip --no-progress
64
+ ```
65
+
66
+ If a local config path is required:
67
+
68
+ ```bash
69
+ npx knip --config knip.json --no-progress
70
+ ```
71
+
72
+ Optional production-only pass (after the default scan is clean or when the user asks):
73
+
74
+ ```bash
75
+ npx knip --production --no-progress
76
+ ```
77
+
78
+ Capture output for triage. Default for this skill is a **full** workspace scan unless the user scopes it.
79
+
80
+ ### 4. Triage findings
81
+
82
+ Work findings in this priority:
83
+
84
+ 1. **Unused dependencies / devDependencies** — remove from `package.json` only after confirming Nest/CLI/plugins do not need them
85
+ 2. **Unlisted dependencies** — add the real import to `dependencies` / `devDependencies` (do not rely on transitive deps)
86
+ 3. **Unused files** — delete only when not dynamically loaded (`i18n`, `assets`, `path.join(__dirname, …)`, Nest schematics paths)
87
+ 4. **Unused exports** — remove `export` or delete dead symbols; keep Nest decorators’ public APIs (`@Module` providers/controllers/imports that Knip misunderstands → fix config, don’t gut the module)
88
+ 5. **Duplicate / enum / namespace export noise** — resolve carefully; suppress only as last resort
89
+
90
+ **NestJS cautions**
91
+
92
+ - Controllers, providers, guards, interceptors, pipes, filters registered only via module metadata must stay reachable from entry modules — if Knip says unused, verify `*.module.ts` wiring first.
93
+ - Do not remove `main.ts`, `app.module.ts`, or Nest CLI schematics entrypoints.
94
+ - Spec / e2e files: prefer config `ignore` / project patterns over deleting tests.
95
+
96
+ ### 5. Fix in batches (explain → edit → verify)
97
+
98
+ For each batch:
99
+
100
+ 1. **Explain** what Knip reported and why the change is safe.
101
+ 2. **Edit** the minimum (package.json, exports, delete files).
102
+ 3. **Verify** with build + unit tests (and e2e when relevant).
103
+ 4. If verification fails: **revert or repair** before continuing.
104
+
105
+ #### Fix construction rules
106
+
107
+ - Preserve HTTP routes, DTO contracts, swagger models, queues, cron jobs, and microservice patterns.
108
+ - Prefer removing unused exports over deleting whole Nest providers that are still registered.
109
+ - Run `npm install` / lockfile update after dependency changes.
110
+ - Keep diffs small. No drive-by refactors.
111
+
112
+ #### Ignores (last resort)
113
+
114
+ Use Knip `ignore`, `ignoreDependencies`, or `ignoreBinaries` only for true false positives (Nest dynamic modules, intentional public SDK barrels). Document each ignore in the final report.
115
+
116
+ ### 6. Re-scan until clean
117
+
118
+ ```bash
119
+ npx knip --no-progress
120
+ ```
121
+
122
+ Repeat until exit 0 or only approved ignores remain.
123
+
124
+ ### 7. Final verification + report
125
+
126
+ ```markdown
127
+ ## NestJS Knip fix report
128
+
129
+ ### Scan
130
+ - Baseline: <summary>
131
+ - Final: <clean | remaining>
132
+
133
+ ### Fixed
134
+ - <issue type> — <what changed>
135
+
136
+ ### Ignores / config
137
+ - none | <item> — reason
138
+
139
+ ### Verification
140
+ - <command> — pass/fail
141
+ ```
142
+
143
+ ## Safety
144
+
145
+ - Do not commit or push unless the user asks.
146
+ - Do not delete `.env` or secrets.
147
+ - Stop and ask before removing large feature modules or public API packages.
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "https://unpkg.com/knip@5/schema.json",
3
+ "entry": [
4
+ "src/main.ts",
5
+ "src/main.js",
6
+ "apps/**/src/main.ts",
7
+ "src/**/*.module.ts",
8
+ "apps/**/*.module.ts",
9
+ "libs/**/src/index.ts",
10
+ "test/**/*.ts",
11
+ "test/**/*.js"
12
+ ],
13
+ "project": [
14
+ "src/**/*.{ts,js}",
15
+ "apps/**/*.{ts,js}",
16
+ "libs/**/*.{ts,js}",
17
+ "test/**/*.{ts,js}"
18
+ ],
19
+ "ignore": [
20
+ "**/*.spec.ts",
21
+ "**/*.e2e-spec.ts",
22
+ "dist/**",
23
+ "coverage/**"
24
+ ],
25
+ "ignoreDependencies": [
26
+ "@nestjs/schematics",
27
+ "@nestjs/testing"
28
+ ]
29
+ }
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: node-doctor-fix
3
+ description: >-
4
+ Runs the bundled node-doctor tool (Knip + package hygiene) on generic Node.js
5
+ projects, constructs fixes for all findings, and verifies that implementations,
6
+ features, and functionalities are not broken after changes. Use when the user
7
+ runs /node-doctor-fix, asks to doctor a Node.js package/CLI, clean unused
8
+ Node exports/deps, or fix node-doctor findings without regressions.
9
+ disable-model-invocation: true
10
+ ---
11
+
12
+ # /node-doctor-fix
13
+
14
+ Run the bundled **`node-doctor`** tool on a **generic Node.js** project (library, CLI, or service — not Nest/Next-first apps), fix **all** findings, and prove behavior still works.
15
+
16
+ `node-doctor` = **Knip** (unused files / exports / dependencies) using [`config/node-doctor.knip.json`](config/node-doctor.knip.json) when the project has no Knip config, **plus** package hygiene checks (`bin` / `main` / `exports` / script paths / `engines.node`).
17
+
18
+ Do **not** mass-ignore. Prefer root-cause fixes. After every batch of edits, re-verify so implementations, features, and functionalities are not broken.
19
+
20
+ ## Workflow
21
+
22
+ Copy this checklist and track progress:
23
+
24
+ ```
25
+ Node Doctor Fix Progress:
26
+ - [ ] 1. Confirm Node project + route frameworks elsewhere
27
+ - [ ] 2. Baseline node-doctor scan
28
+ - [ ] 3. Triage findings (priority order)
29
+ - [ ] 4. Fix in batches (explain → edit → verify)
30
+ - [ ] 5. Re-scan until clean (or document intentional leftovers)
31
+ - [ ] 6. Final verification + report
32
+ ```
33
+
34
+ ### 1. Confirm Node project + route frameworks elsewhere
35
+
36
+ From the project root:
37
+
38
+ 1. Confirm `package.json` exists.
39
+ 2. If the app is primarily **NestJS** → use `/nestjs-knip-fix` instead.
40
+ 3. If the app is primarily **React** → use `/react-doctor-fix` (optionally Knip later).
41
+ 4. Detect verification commands:
42
+
43
+ ```bash
44
+ npm test
45
+ npm run typecheck # or npx tsc --noEmit
46
+ npm run lint
47
+ npm run build
48
+ node ./dist/index.js --help # CLIs when applicable
49
+ ```
50
+
51
+ ### 2. Baseline node-doctor scan
52
+
53
+ Resolve the skill directory (installed under `.cursor/skills/node-doctor-fix` or this registry path), then:
54
+
55
+ ```bash
56
+ node <skillDir>/scripts/node-doctor.mjs . --json > .node-doctor-baseline.json
57
+ node <skillDir>/scripts/node-doctor.mjs .
58
+ ```
59
+
60
+ Examples:
61
+
62
+ ```bash
63
+ node .cursor/skills/node-doctor-fix/scripts/node-doctor.mjs .
64
+ node skills/node-doctor-fix/scripts/node-doctor.mjs .
65
+ ```
66
+
67
+ Flags:
68
+
69
+ - `--json` — machine-readable findings
70
+ - `--knip-only` — skip package hygiene
71
+ - `--hygiene-only` — skip Knip
72
+
73
+ If the project already has `knip.json` / `package.json#knip`, node-doctor uses that for Knip; otherwise it uses the bundled [`config/node-doctor.knip.json`](config/node-doctor.knip.json).
74
+
75
+ Delete temporary report files before finishing (or keep them untracked).
76
+
77
+ ### 3. Triage findings
78
+
79
+ Priority:
80
+
81
+ 1. **Broken package entrypoints** — missing `bin` / `main` / `exports` / script paths (hygiene errors)
82
+ 2. **Unlisted dependencies** — add real imports to package.json
83
+ 3. **Unused dependencies** — remove only when not required by tooling/config plugins
84
+ 4. **Unused files** — delete when not dynamically required
85
+ 5. **Unused exports / types** — remove or stop exporting
86
+ 6. **Hygiene warnings** — e.g. missing `engines.node`
87
+
88
+ ### 4. Fix in batches (explain → edit → verify)
89
+
90
+ For each batch:
91
+
92
+ 1. **Explain** the finding and why the fix is safe.
93
+ 2. **Edit** minimally (`package.json`, exports, delete dead files).
94
+ 3. **Verify** with test / typecheck / build / CLI smoke.
95
+ 4. On failure: **revert or repair** before continuing.
96
+
97
+ #### Fix construction rules
98
+
99
+ - Preserve public package API (`exports`, documented CLI flags, published bin names).
100
+ - Do not remove files loaded dynamically (`fs.readFile`, runtime plugin paths) without proof.
101
+ - Update the lockfile after dependency changes.
102
+ - Do not convert the project into Nest/Next-specific structure.
103
+
104
+ #### Ignores (last resort)
105
+
106
+ Prefer fixing. If Knip false-positives remain, add narrow `ignore` / `ignoreDependencies` to the **project** Knip config (create one from the bundled config rather than silencing the tool). Document every ignore.
107
+
108
+ ### 5. Re-scan until clean
109
+
110
+ ```bash
111
+ node <skillDir>/scripts/node-doctor.mjs .
112
+ ```
113
+
114
+ Exit code must be `0` (or only approved documented leftovers remain).
115
+
116
+ ### 6. Final verification + report
117
+
118
+ ```markdown
119
+ ## Node doctor fix report
120
+
121
+ ### Scan
122
+ - Baseline: <N findings>
123
+ - Final: <clean | N remaining>
124
+
125
+ ### Fixed
126
+ - <type> — summary
127
+
128
+ ### Ignores / config
129
+ - none | item — reason
130
+
131
+ ### Verification
132
+ - <command> — pass/fail
133
+ ```
134
+
135
+ ## Tool reference
136
+
137
+ | Path | Role |
138
+ |------|------|
139
+ | `scripts/node-doctor.mjs` | CLI analyser |
140
+ | `config/node-doctor.knip.json` | Default Knip config for generic Node |
141
+
142
+ ## Safety
143
+
144
+ - Do not commit or push unless the user asks.
145
+ - Do not commit secrets.
146
+ - Stop and ask before deleting public API surface or major packages.
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://unpkg.com/knip@5/schema.json",
3
+ "entry": [
4
+ "{index,cli,main,app,server}.{js,cjs,mjs,ts,cts,mts}",
5
+ "src/{index,cli,main,app,server}.{js,cjs,mjs,ts,cts,mts}",
6
+ "bin/**/*.{js,cjs,mjs,ts}",
7
+ "scripts/**/*.{js,cjs,mjs,ts}"
8
+ ],
9
+ "project": [
10
+ "**/*.{js,cjs,mjs,ts,cts,mts}!"
11
+ ],
12
+ "ignore": [
13
+ "**/dist/**",
14
+ "**/build/**",
15
+ "**/coverage/**",
16
+ "**/.next/**",
17
+ "**/node_modules/**"
18
+ ],
19
+ "ignoreBinaries": [
20
+ "noah-cursor"
21
+ ]
22
+ }