vercel-doctor 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aniket-508
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 ADDED
@@ -0,0 +1,172 @@
1
+ <picture>
2
+ <source media="(prefers-color-scheme: dark)" srcset="./assets/vercel-doctor-readme-logo-dark.svg">
3
+ <source media="(prefers-color-scheme: light)" srcset="./assets/vercel-doctor-readme-logo-light.svg">
4
+ <img alt="Vercel Doctor" src="./assets/vercel-doctor-readme-logo-light.svg" width="180" height="40">
5
+ </picture>
6
+
7
+ Reduce your Vercel bill with one command.
8
+
9
+ Scans your Next.js codebase for patterns that increase your Vercel bill — long function durations, uncached routes, unoptimized images, expensive cron jobs, and more — then outputs actionable diagnostics.
10
+
11
+ ### [See it in action →](https://vercel-doctor.com)
12
+
13
+ https://github.com/user-attachments/assets/e03596de-4b68-4a3e-8623-51c765647b26
14
+
15
+ ## How it works
16
+
17
+ Vercel Doctor detects your framework and project setup, then runs two analysis passes **in parallel**:
18
+
19
+ 1. **Billing lint** — detects patterns that inflate your Vercel invoice:
20
+ - **Function duration**: sequential `await`s, blocking `after()` calls, side effects in GET handlers
21
+ - **Caching**: missing cache policies, `force-dynamic` / `no-store` overrides, SSR where SSG would work
22
+ - **Image optimization**: unoptimized images, overly broad remote patterns, missing `sizes` prop
23
+ - **Edge functions**: heavy imports, sequential awaits that burn CPU time
24
+ - **Static assets**: large files that should be served from an external CDN
25
+ - **Platform usage**: Vercel Cron vs. GitHub Actions / Cloudflare Workers, Fluid Compute, Bun runtime
26
+ 2. **Dead code** — detects unused files, exports, types, and duplicates that slow cold starts.
27
+
28
+ Diagnostics are filtered through your config to produce actionable results.
29
+
30
+ ## Install
31
+
32
+ Run this at your project root:
33
+
34
+ ```bash
35
+ npx -y vercel-doctor@latest .
36
+ ```
37
+
38
+ Use `--verbose` to see affected files and line numbers:
39
+
40
+ ```bash
41
+ npx -y vercel-doctor@latest . --verbose
42
+ ```
43
+
44
+ ## Install for your coding agent
45
+
46
+ Teach your coding agent Vercel cost optimization rules:
47
+
48
+ ```bash
49
+ curl -fsSL https://vercel-doctor.com/install-skill.sh | bash
50
+ ```
51
+
52
+ Supports Cursor, Claude Code, Amp Code, Codex, Gemini CLI, OpenCode, Windsurf, and Antigravity.
53
+
54
+ ## Options
55
+
56
+ ```
57
+ Usage: vercel-doctor [directory] [options]
58
+
59
+ Options:
60
+ -v, --version display the version number
61
+ --no-lint skip linting
62
+ --no-dead-code skip dead code detection
63
+ --verbose show file details per rule
64
+ --score output only the score
65
+ -y, --yes skip prompts, scan all workspace projects
66
+ --project <name> select workspace project (comma-separated for multiple)
67
+ --diff [base] scan only files changed vs base branch
68
+ --offline skip telemetry (anonymous, not stored, only used to calculate score)
69
+ --no-ami skip Ami-related prompts
70
+ --fix open Ami to auto-fix all issues
71
+ -h, --help display help for command
72
+ ```
73
+
74
+ ## Configuration
75
+
76
+ Create a `vercel-doctor.config.json` in your project root to customize behavior:
77
+
78
+ ```json
79
+ {
80
+ "ignore": {
81
+ "rules": ["vercel-doctor/nextjs-no-img-element", "knip/exports"],
82
+ "files": ["src/generated/**"]
83
+ }
84
+ }
85
+ ```
86
+
87
+ You can also use the `"vercelDoctor"` key in your `package.json` instead:
88
+
89
+ ```json
90
+ {
91
+ "vercelDoctor": {
92
+ "ignore": {
93
+ "rules": ["vercel-doctor/nextjs-no-img-element"]
94
+ }
95
+ }
96
+ }
97
+ ```
98
+
99
+ If both exist, `vercel-doctor.config.json` takes precedence.
100
+
101
+ ### Config options
102
+
103
+ | Key | Type | Default | Description |
104
+ | -------------- | ------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
105
+ | `ignore.rules` | `string[]` | `[]` | Rules to suppress, using the `plugin/rule` format shown in diagnostic output (e.g. `vercel-doctor/async-parallel`, `knip/exports`) |
106
+ | `ignore.files` | `string[]` | `[]` | File paths to exclude, supports glob patterns (`src/generated/**`, `**/*.test.tsx`) |
107
+ | `lint` | `boolean` | `true` | Enable/disable lint checks (same as `--no-lint`) |
108
+ | `deadCode` | `boolean` | `true` | Enable/disable dead code detection (same as `--no-dead-code`) |
109
+ | `verbose` | `boolean` | `false` | Show file details per rule (same as `--verbose`) |
110
+ | `diff` | `boolean \| string` | — | Force diff mode (`true`) or pin a base branch (`"main"`). Set to `false` to disable auto-detection. |
111
+
112
+ CLI flags always override config values.
113
+
114
+ ## Node.js API
115
+
116
+ You can also use Vercel Doctor programmatically:
117
+
118
+ ```js
119
+ import { diagnose } from "vercel-doctor/api";
120
+
121
+ const result = await diagnose("./path/to/your/nextjs-project");
122
+
123
+ console.log(result.score); // { score: 82, label: "Good" } or null
124
+ console.log(result.diagnostics); // Array of Diagnostic objects
125
+ console.log(result.project); // Detected framework, React version, etc.
126
+ ```
127
+
128
+ The `diagnose` function accepts an optional second argument:
129
+
130
+ ```js
131
+ const result = await diagnose(".", {
132
+ lint: true, // run lint checks (default: true)
133
+ deadCode: true, // run dead code detection (default: true)
134
+ });
135
+ ```
136
+
137
+ Each diagnostic has the following shape:
138
+
139
+ ```ts
140
+ interface Diagnostic {
141
+ filePath: string;
142
+ plugin: string;
143
+ rule: string;
144
+ severity: "error" | "warning";
145
+ message: string;
146
+ help: string;
147
+ line: number;
148
+ column: number;
149
+ category: string;
150
+ }
151
+ ```
152
+
153
+ ## Contributing
154
+
155
+ Want to contribute? Check out the codebase and submit a PR.
156
+
157
+ ```bash
158
+ git clone https://github.com/Aniket-508/vercel-doctor
159
+ cd vercel-doctor
160
+ pnpm install
161
+ pnpm -r run build
162
+ ```
163
+
164
+ Run locally:
165
+
166
+ ```bash
167
+ node packages/vercel-doctor/dist/cli.js /path/to/your/nextjs-project
168
+ ```
169
+
170
+ ### License
171
+
172
+ Vercel Doctor is MIT-licensed open-source software.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export { };