You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2651a71
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: scripts/find-unused.README.md
+21-8Lines changed: 21 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# find-unused.sh
2
2
3
-
Wrapper around [knip](https://knip.dev) that detects unused files and cross-references them against CI configs, package.json scripts, convention-based usage, and file-based routing directories to reduce false positives.
3
+
Wrapper around [knip](https://knip.dev) that detects unused files and cross-references them against CI configs, build configs, package.json scripts, tsconfig files, convention-based usage, file-based routing directories, and sibling repo CI/CD pipelines to reduce false positives.
4
4
5
5
## Usage
6
6
@@ -10,17 +10,30 @@ bash scripts/find-unused.sh
10
10
11
11
Requires `npx` (knip is fetched automatically). A fake `DATABASE_URL` is injected so config resolution doesn't fail.
12
12
13
+
The script auto-detects whether it's running inside a factory layout (`../../.._repos/`). When inside a factory, it cross-references sibling repos. When standalone, it skips sibling checks gracefully and still runs all internal checks.
14
+
13
15
## What it does
14
16
15
17
1.**Runs `knip --include files`** to get a list of unused files across the monorepo.
- Build scripts (`.mjs`, `.ts`, `.sh` across all workspaces)
24
+
-`.opencode` skill scripts
25
+
- All `package.json` files (for script references)
26
+
- All `tsconfig*.json` files (for path aliases and includes)
27
+
3.**Cross-references** each file against:
28
+
-**Internal infra** — all indexed config/build files, searching by filename and relative path
19
29
-**Convention patterns** — filenames like `postinstall`, `drizzle.config`, Tauri hooks
20
-
-**File-based routing dirs** — Nuxt/Next server routes and API routes that are entry points by convention
21
-
3.**Outputs a sorted list** (oldest first) with two categories:
22
-
-`✗`**Likely safe to remove** — no references found anywhere
23
-
-`⚠`**Review before removing** — referenced in CI, infra, convention, or routing
30
+
-**File-based routing dirs** — Next.js server routes, app routes, and API routes that are entry points by convention
31
+
-**Sibling repo CI/CD** — workflows, Dockerfiles, and build scripts in sibling repos and factory-level CI, with smart filtering to avoid false positives on generic filenames (e.g., `index`, `utils`, `config`)
32
+
4.**Displays results in two buckets** (oldest first within each):
33
+
-`✗`**Safe to remove** — no references found anywhere (red)
34
+
-`⚠`**Review before removing** — referenced in infra/CI (yellow) or sibling CI (cyan)
35
+
36
+
A progress indicator shows the current file being checked during cross-referencing.
24
37
25
38
Certain paths are ignored entirely (scripts, dev tools) — see the `IGNORE_PREFIXES` array in the script.
0 commit comments